View Full Version : Parse error: syntax error- HELP!!


abhishekmat
01-26-2006, 08:07 AM
This is the error:

Parse error: syntax error, unexpected ',', expecting T_PAAMAYIM_NEKUDOTAYIM in c:\Inetpub\wwwroot\edu\database.php on line 11

I have already create a table "abhi1" with all the fields.
If am typing

INSERT INTO abhi1 values('','sa','as','ss','ss','e','r','tt','tt','yy','uu','ii','i','o','p','u','t','r','e','w','q','q','q','q','q','q');

on mysql prompt it is working fine


This is the CODE:

<?php

$conn=mysql_connect("localhost", "root", "");


mysql_select_db("abhishek", $conn);

$sql = "INSERT INTO abhi1 values('','sa','as','ss','ss','e','r','tt','tt','yy','uu','ii','i','o','p','u','t','r','e','w','q','q','q','q','q','q')";


$result = mysql_query(&sql, $conn) or die(mysql_error());

echo $result;

?>

This is my forst try on PHP :)

I think all are well aware of PHP here and I will get enough advice to make it work:)

Thanks in advance

abhishekmat
01-27-2006, 05:13 AM
Hello :)

You people are smart enough, I can understand you don't have time even though hope for some advice.

Abhishek

Paz
01-28-2006, 12:06 PM
Hi,

well your post was all greek to me, sorry.

It'll take some time, but someone (eg sarahk) will come by eventually to tell you that you've used a ' instead of a "

Cheers,
Paz.

ERE Breckenridge
01-29-2006, 07:37 PM
This is a common error when data stored in the data base has the char [ ' ]. It brakes your SQL string. Simply use the addslashes function before pushing data into the database and hopefully you can get your issues resolved.

reZo
02-02-2006, 08:41 PM
Yes, I would agree. This is a very common error. However, if you want to use " in your PHP line which opens the line with a ", simple use \" instead of ". And example of this is shown as below:



<?php

echo "Hello welcome, <a href=\"#\"> example </a>";

?>



As you can see, I have used the \" in the HTML hyperlink tag.

Sam
02-03-2006, 02:06 AM
Your problem is in this line:

$result = mysql_query(&sql, $conn) or die(mysql_error());

You've got an & instead of a $. Change it to:

$result = mysql_query($sql, $conn) or die(mysql_error());

and it should work ;)

Sam