Jump to content

[SOLVED] PHP Parse Error: syntax error Line 21 unexpected T_STRING


DeepakJ

Recommended Posts

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

<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
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\verification.php on line 19 Thats the error I get when I change the variable to ['x']

Link to comment
Share on other sites

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

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

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

<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
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.