Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

unexpected T_STRING error

Status
Not open for further replies.

DKailen

Technical User
Mar 6, 2010
13
0
0
US
Hi everyone,

This one has me pulling my hair out. I am getting an error
Parse error: syntax error, unexpected T_STRING in /home/public_html/test/edit.php on line 30

I guess I have been looking too long because I cannot see it. Any suggestions will be greatly appreciated.

Jim

Code:
<?php

$id = $_GET['id'];

header('Content-type: text/html; charset=utf-8');

$username="waynesbo_WHFZen";
$password="whfshop22980";
$database="waynesbo_WHFZen";

$con = mysql_connect(localhost,$username,$password);

if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

$selected = mysql_select_db($database, $con)  
  or die("Could not select $database");

 $SQL = "SELECT FROM products WHERE ID =\"" . $id . "\";";
$result = mysql_query($SQL);

while ($item = mysql_fetch_assoc($result)) {
print $item['ID'] . "<BR>";
print $item['Item_Name'] . "<BR>";
print $item['Item_Desc'] . "<BR>";
print $item['Item_Price'] . "<BR>";
print $item['Item_Shipping'] . "<BR>";
print $item['Item_Image'] . "<BR>";
print $item['Item_Cat'] . "<BR>";
  
mysql_close($con);

}

print "<form method=POST action=add.php>";

print "<input type=hidden name=action value=add>";

print "<table border=3 width=500>";

print "  <tr>";
print "     <td colspan=2><p><font size=\"5\" color=\"#000000\"><b>Edit An Item in the Database</b></font></p></td>";
print "  </tr>";
print "  <tr>";
print "     <td>Item Name</td>";
print "     <td><input type=text value=$Item_Name name=Item_Name id=txtItem_name size=50 id=\"Item_Name\" onchange=\"checkUniq(this.name, this.value)\"></td>";
print "  </tr>";
print "  <tr>";
print "     <td>Item Description</td>";
print "     <td><input type=text name=Item_Desc size=50></td>";
print "  </tr>";
print "  <tr>";
print "     <td>Item Price</td>";
print "     <td><input type=text name=Item_Price size=50></td>";
print "  </tr>";
print "  <tr>";
print "     <td colspan=2>Please use the format 'X.XX' with no \$ included for the price.</td>";
print "  </tr>";
print "  <tr>";
print "     <td>Item Shipping</td>";
print "     <td><input type=text name=Item_Shipping size=50></td>";
print "  </tr>";
print "  <tr>";
print "     <td>Item Image</td>";
print "     <td><input type=text name=Item_Image size=50 value=None></td>";
print "  </tr>";
print "  <tr>";
print "     <td>Item Category</td>";
print "     <td><input type=text name=Item_Cat size=50></td>";
print "  </tr>";
print "  <tr>";
print "     <td><input type=submit name=submit value=Submit form></td>";
print "     <td><input type=reset></td>";
print "  </tr>";
print "</table>";

print "</form>";

?>
 
putting mysql_close within a while loop seems a bit odd. if you want only one result then dont use a while loop

you are using a user contributed variable in a query without any cleansing. read up on sql injection attacks.

i do not see any parser errors when i run this script, however.
 
same here clear syntax on windows using 5.2.13
Can you try running from the command prompt and also at the command prompt try:
php -l file.php
This just does a syntax check
 
Really, I get several errors.

One due to a malformed query. Namely missing an "*" before "FROM" and some non defined variables further down.

For that error I get an error with the mysql_fetch_assoc function because the query can't run,and so the handle is not valid for mysql_fetch_assoc.

There's also the issue with "localhost" in the mysql_connect statement. Unless there's a constant with that name defined elsewhere, that would produce a warning. It should be surrounded by quotes.

I don't however get the parser error message. Perhaps ading error checking to the mysql function calls may help.

Code:
$result = mysql_query($SQL)[red]or die(mysql_error())[/red];


That might be due to some code we are not seeing.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
like you, Phil, I get loads of errors, but no parser errors which was what the OP was asking about, I thought.
 
True, very true. Sorry.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Thanks for the replies everyone. Sorry about being MIA for the past few days, I had some things come up. But yes, the only error I was concerned about was the parse. That code was from very early in a rewrite and I finally got everything working.

Thanks again!
Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top