DeepakJ Posted July 27, 2007 Share Posted July 27, 2007 Can someone help me find out whats wrong with this code. <html><head><title>AlibreCam Verification System</title></head> <center><TABLE border=0 cellpadding=3><form name="input" action="linput.php" method="get"> <tr> <td>Customer ID:</td> <td><input type="text" name="user"></td> </tr> <tr> <td>Product ID:</td> <td> <input type="text" name="user1"></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 = "xxxxxx"; $dbname = "xxxxxxxxx"; $customerid = $_GET['user']; $productid = $_GET['user1']; 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"); $queryb = "SELECT * FROM invoiceid,productid WHERE invoiceid.invoicenum=productid.invoicenum && customerid='$customerid'"; $bResult = mysql_query($queryb) or die(mysql_error()); $productcounter=0; while($row=mysql_fetch_array($bResult)){ $productcounter = $productcounter + 1; $numoflicenses[] = $row['numoflicenses']; $invoicetracker[] = $row['invoicenum']; } $adder = 0; foreach ($numoflicenses as $num => $value){ $adder=$adder+$numoflicenses; if ($adder > $productcounter){ $queryc="UPDATE productid SET productid=$productid WHERE invoicenum=$invoicetracker[$num]"; mysql_query($queryc) or die(mysql_error()); } } ?> </html> Error: Notice: Undefined variable: numoflicenses in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\InputMaintainance\linput.php on line 40 Warning: Invalid argument supplied for foreach() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\InputMaintainance\linput.php on line 40 Link to comment https://forums.phpfreaks.com/topic/62107-syntax-error/ Share on other sites More sharing options...
tibberous Posted July 27, 2007 Share Posted July 27, 2007 Whats the error your getting? We can't run it without the database. Link to comment https://forums.phpfreaks.com/topic/62107-syntax-error/#findComment-309220 Share on other sites More sharing options...
DeepakJ Posted July 27, 2007 Author Share Posted July 27, 2007 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 Link to comment https://forums.phpfreaks.com/topic/62107-syntax-error/#findComment-309221 Share on other sites More sharing options...
DeepakJ Posted July 27, 2007 Author Share Posted July 27, 2007 Please help. I think the problem lies with the second query. Link to comment https://forums.phpfreaks.com/topic/62107-syntax-error/#findComment-309248 Share on other sites More sharing options...
Fadion Posted July 27, 2007 Share Posted July 27, 2007 $queryc="UPDATE productid SET productid=$productid WHERE invoicenum=$invoicetracker[$num]"; must be: $queryc="UPDATE productid SET productid='$productid' WHERE invoicenum='$invoicetracker[$num]'"; Just add single quotes and see if it fixes the error. Link to comment https://forums.phpfreaks.com/topic/62107-syntax-error/#findComment-309251 Share on other sites More sharing options...
DeepakJ Posted July 27, 2007 Author Share Posted July 27, 2007 I tried it it doesn't fix the error Link to comment https://forums.phpfreaks.com/topic/62107-syntax-error/#findComment-309252 Share on other sites More sharing options...
DeepakJ Posted July 27, 2007 Author Share Posted July 27, 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\InputMaintainance\linput.php on line 44 This is my new error Link to comment https://forums.phpfreaks.com/topic/62107-syntax-error/#findComment-309253 Share on other sites More sharing options...
Fadion Posted July 27, 2007 Share Posted July 27, 2007 try this: $invoiceTrackerSQL = $invoicetracker[$num]; $queryc="UPDATE productid SET productid='$productid' WHERE invoicenum='$invoiceTrackerSQL'"; $results = mysql_query($queryc) or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/62107-syntax-error/#findComment-309258 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.