Jump to content

Syntax error


DeepakJ

Recommended Posts

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
Share on other sites

$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
Share on other sites

 

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.