DeepakJ Posted July 26, 2007 Share Posted July 26, 2007 Could someone please help me figure out what is wrong with this script? I fixed the initial error but a new one popped up . Parse error: syntax error, unexpected $end in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\verification.php on line 23 <html><head><title>AlibreCam Verification System</title></head> <center><h3>AlibreCam Verification System</h3></center> <center><TABLE border=0 cellpadding=3><form name="input" action="verification.php" method="get"> <tr><td><center>Customer ID:</center></td> <td><input type="text" name="user"></td></tr> <tr><td colspan=2><center><input type="submit" value="Submit"></center></td></tr> </form><br></table><br> <?php include("connectioninfo.php"); $customer = $_GET['user']; $query= sprintf("SELECT * FROM invoiceid WHERE customerid=%s,$customer); $query= mysql_real_escape_string($query); $cResult = mysql_query($query); $value=0; while($row=mysql_fetch_array($cResult)){ $value=$value+$row[numoflicenses]; } echo 'Total number of licenses purchased: '.$value; ?> </html> Link to comment https://forums.phpfreaks.com/topic/61937-solved-php-parse-error-syntax-error-line-21-unexpected-t_string/ Share on other sites More sharing options...
csplrj Posted July 26, 2007 Share Posted July 26, 2007 Change this line $value=$value+$row[numoflicenses]; to $value=$value+$row['numoflicenses']; Bye for now CSJakharia Link to comment https://forums.phpfreaks.com/topic/61937-solved-php-parse-error-syntax-error-line-21-unexpected-t_string/#findComment-308398 Share on other sites More sharing options...
DeepakJ Posted July 26, 2007 Author Share Posted July 26, 2007 That doesn't work. I get another error if I do that. Link to comment https://forums.phpfreaks.com/topic/61937-solved-php-parse-error-syntax-error-line-21-unexpected-t_string/#findComment-308401 Share on other sites More sharing options...
yarnold Posted July 26, 2007 Share Posted July 26, 2007 <html><head><title>AlibreCam Verification System</title></head> <center><h3>AlibreCam Verification System</h3></center> <center><TABLE border=0 cellpadding=3><form name="input" action="verification.php" method="get"> <tr><td><center>Customer ID:</center></td> <td><input type="text" name="user"></td></tr> <tr><td colspan=2><center><input type="submit" value="Submit"></center></td></tr> </form><br></table><br> <?php include("connectioninfo.php"); $customer = $_GET['user']; $query= sprintf("SELECT * FROM invoiceid WHERE customerid=%s,$customer"); $query= mysql_real_escape_string($query); $cResult = mysql_query($query); $value=0; while($row=mysql_fetch_array($cResult)){ $value=$value+$row['numoflicenses']; } echo "Total number of licenses purchased: ".$value; ?> </html> Link to comment https://forums.phpfreaks.com/topic/61937-solved-php-parse-error-syntax-error-line-21-unexpected-t_string/#findComment-308402 Share on other sites More sharing options...
DeepakJ Posted July 26, 2007 Author Share Posted July 26, 2007 Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\verification.php on line 19 Thats the error I get when I change the variable to ['x'] Link to comment https://forums.phpfreaks.com/topic/61937-solved-php-parse-error-syntax-error-line-21-unexpected-t_string/#findComment-308405 Share on other sites More sharing options...
teng84 Posted July 26, 2007 Share Posted July 26, 2007 the select statement is missing " quote at the end of it Link to comment https://forums.phpfreaks.com/topic/61937-solved-php-parse-error-syntax-error-line-21-unexpected-t_string/#findComment-308408 Share on other sites More sharing options...
DeepakJ Posted July 26, 2007 Author Share Posted July 26, 2007 <html><head><title>AlibreCam Verification System</title></head> <center><h3>AlibreCam Verification System</h3></center> <center><TABLE border=0 cellpadding=3><form name="input" action="verification.php" method="get"> <tr><td><center>Customer ID:</center></td> <td><input type="text" name="user"></td></tr> <tr><td colspan=2><center><input type="submit" value="Submit"></center></td></tr> </form><br></table><br> <?php $hostname = "localhost"; $username = "root"; $password = "xxxxxxxx"; $dbname = "licensinginformation"; mysql_connect($hostname, $username, $password) or DIE("Unable to connect to MySQL server $hostname"); $selected = mysql_select_db($dbname) or DIE("Could not select requested db $dbname"); ; $customer = $_GET['user']; $query= sprintf("SELECT * FROM invoiceid WHERE customerid=%s",$customer); $query= mysql_real_escape_string($query); $cResult = mysql_query($query); $value=0; while($row=mysql_fetch_array($cResult)){ $value=$value+$row['numoflicenses']; } echo "Total number of licenses purchased: ".$value; ?> </html> Thanks for the help but now it is saying " Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\verification.php on line 25" Link to comment https://forums.phpfreaks.com/topic/61937-solved-php-parse-error-syntax-error-line-21-unexpected-t_string/#findComment-308410 Share on other sites More sharing options...
teng84 Posted July 26, 2007 Share Posted July 26, 2007 $query= "SELECT * FROM invoiceid WHERE customerid=".$customer.""; try Link to comment https://forums.phpfreaks.com/topic/61937-solved-php-parse-error-syntax-error-line-21-unexpected-t_string/#findComment-308413 Share on other sites More sharing options...
DeepakJ Posted July 26, 2007 Author Share Posted July 26, 2007 Same error, I don't think it works. Link to comment https://forums.phpfreaks.com/topic/61937-solved-php-parse-error-syntax-error-line-21-unexpected-t_string/#findComment-308415 Share on other sites More sharing options...
DeepakJ Posted July 26, 2007 Author Share Posted July 26, 2007 It seems like the format of my query is off but it seems fine. The thing says it isn't able to perform that function on it. Link to comment https://forums.phpfreaks.com/topic/61937-solved-php-parse-error-syntax-error-line-21-unexpected-t_string/#findComment-308426 Share on other sites More sharing options...
DeepakJ Posted July 26, 2007 Author Share Posted July 26, 2007 Please help Link to comment https://forums.phpfreaks.com/topic/61937-solved-php-parse-error-syntax-error-line-21-unexpected-t_string/#findComment-308446 Share on other sites More sharing options...
Trium918 Posted July 26, 2007 Share Posted July 26, 2007 Are you stilll getting an error? If so, what is it? Link to comment https://forums.phpfreaks.com/topic/61937-solved-php-parse-error-syntax-error-line-21-unexpected-t_string/#findComment-308449 Share on other sites More sharing options...
Trium918 Posted July 26, 2007 Share Posted July 26, 2007 Try this! <html><head><title>AlibreCam Verification System</title></head> <center><h3>AlibreCam Verification System</h3></center> <center><TABLE border=0 cellpadding=3><form name="input" action="verification.php" method="get"> <tr><td><center>Customer ID:</center></td> <td><input type="text" name="user"></td></tr> <tr><td colspan=2><center><input type="submit" value="Submit"></center></td></tr> </form> </table> <?php $hostname = "localhost"; $username = "root"; $password = "xxxxxxxx"; $dbname = "licensinginformation"; mysql_connect($hostname, $username, $password) or DIE("Unable to connect to MySQL server $hostname"); $selected = mysql_select_db($dbname) or DIE("Could not select requested db $dbname"); $customer = $_GET['user']; $query= sprintf("SELECT * FROM invoiceid WHERE customerid='$customer'"); //$query= mysql_real_escape_string($query); $cResult = mysql_query($query); $value=0; while($row=mysql_fetch_array($cResult)){ $value=$value+$row['numoflicenses']; } echo "Total number of licenses purchased: ".$value; ?> </html> Link to comment https://forums.phpfreaks.com/topic/61937-solved-php-parse-error-syntax-error-line-21-unexpected-t_string/#findComment-308453 Share on other sites More sharing options...
teng84 Posted July 26, 2007 Share Posted July 26, 2007 do this first $cResult = mysql_query($query) or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/61937-solved-php-parse-error-syntax-error-line-21-unexpected-t_string/#findComment-308454 Share on other sites More sharing options...
DeepakJ Posted July 27, 2007 Author Share Posted July 27, 2007 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\verification.php on line 25" This is the error: I entered that, same error, no death message. Link to comment https://forums.phpfreaks.com/topic/61937-solved-php-parse-error-syntax-error-line-21-unexpected-t_string/#findComment-308481 Share on other sites More sharing options...
teng84 Posted July 27, 2007 Share Posted July 27, 2007 can you paste your code now Link to comment https://forums.phpfreaks.com/topic/61937-solved-php-parse-error-syntax-error-line-21-unexpected-t_string/#findComment-308491 Share on other sites More sharing options...
DeepakJ Posted July 27, 2007 Author Share Posted July 27, 2007 <html><head><title>AlibreCam Verification System</title></head> <center><h3>AlibreCam Verification System</h3></center> <center><TABLE border=0 cellpadding=3><form name="input" action="verification.php" method="get"> <tr><td><center>Customer ID:</center></td> <td><input type="text" name="user"></td></tr> <tr><td colspan=2><center><input type="submit" value="Submit"></center></td></tr> </form><br></table><br> <?php $hostname = "localhost"; $username = "root"; $password = "98989lol"; $dbname = "licensinginformation"; $value=0; $customer = $_GET['user']; mysql_connect($hostname, $username, $password) or DIE("Unable to connect to MySQL server $hostname"); $selected = mysql_select_db($dbname) or DIE("Could not select requested db $dbname"); $query= sprintf("SELECT * FROM invoiceid WHERE customerid=%s",$customer); //$query= "SELECT * FROM invoiceid WHERE //customerid==".$customer.""; (doesn't work) $query= mysql_real_escape_string($query); $cResult= mysql_query($query); while($row=mysql_fetch_array($cResult)){ $value=$value+$row['numoflicenses']; } echo "Total number of licenses purchased: ".$value; ?> </html> Here is my current code Link to comment https://forums.phpfreaks.com/topic/61937-solved-php-parse-error-syntax-error-line-21-unexpected-t_string/#findComment-308927 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.