SQL Problem with PHP

Sharky Forums


Results 1 to 5 of 5

Thread: SQL Problem with PHP

Threaded View

  1. #1
    Great White Shark vertices's Avatar
    Join Date
    Sep 2000
    Location
    Palm Coast, FL
    Posts
    6,001

    SQL Problem with PHP

    I need to use 4 SQL SELECT statements on one PHP Page. I've been trying this:
    Code:
    <?php 
    
    if (isset($HTTP_GET_VARS["benchmark"])){
    	$benchmark = $HTTP_GET_VARS["benchmark"];
    } // end if
    
    if ($benchmark == "3dmark01") {
     $benchname= "2001";
    }
    
    if ($benchmark == "3dmark03") {
     $benchname= "2003";
    }
    
    if ($benchmark == "3dmark05") {
     $benchname= "2005";
    }
    
    $dbServer = "localhost"; 
    $dbDatabase = "xxxx"; 
    $dbUser = "xxxx"; 
    $dbPass = "xxxx"; 
    $sConn = @mysql_connect($dbServer, $dbUser, $dbPass)
    or die("Couldn't connect to database server"); 
    $dConn = @mysql_select_db($dbDatabase, $sConn)
    or die("Couldn't connect to database $dbDatabase"); 
      
     	$query  = "SELECT  MIN(score), MAX(score), AVG(score) FROM $benchmark";
    	$result = mysql_query($query) or die("Error: " . mysql_error()); 
    	
    	$query2  = "SELECT cpu, MIN(score), MAX(score), AVG(score) FROM $benchmark WHERE cpu="intel" GROUP BY cpu";
    	$result2 = mysql_query($query2) or die("Error: " . mysql_error()); 
            
            $query3  = "SELECT cpu, MIN(score), MAX(score), AVG(score) FROM $benchmark WHERE cpu="amd" GROUP BY cpu";
    	$result3 = mysql_query($query3) or die("Error: " . mysql_error()); 
    	
    	$query4  = "SELECT video, MIN(score), MAX(score), AVG(score) FROM $benchmark GROUP BY video";
    	$result4 = mysql_query($query4) or die("Error: " . mysql_error());

    I am using these on different parts of the page. The page is basically a large averages page.

    I currently get the following error when I add more than 1 of these SELECT statements:

    Parse error: parse error, unexpected T_STRING

    This error always is on the line where $query2 starts.

    It works fine with only the first statement but when I add the second I get the error.

    Anyone have a solution for me?

    Thanx in advance.
    Last edited by vertices; 10-04-2004 at 01:01 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •