Jump to content


Photo

PHP error


  • Please log in to reply
2 replies to this topic

#1 Meza44

Meza44
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 27 September 2006 - 11:21 AM

I am new to PHP and Mysql  I am getting an error from a piece of code that I copied from a tutorial and don't know how to fix it.

Here is the error

Parse error: parse error, unexpected ',' in /home/content/i/b/e/ibezamn/html/insert.php on line 21


Here is my code

<html>
<head><title>Insert.PHP</title></head>

<body>

<?
include("/php/capsroster.inc.php");

$first=$_POST['first'];
$last=$_POST['last'];
$number=$_POST['number'];
$position=$_POST['position'];
$height=$_POST['height'];
$weight=$_POST['weight'];
$shoots=$_POST['shoots'];
$dob=$_POST['dob'];

mysql_connect(mysql213.secureserver.net,$username,$password);
@mysql_select_db($database) or die("Unable to select database");

$query="INSERT INTO roster VALUES(",'$first','$last','$number','$position','$height','$weight','$shoots','$dob')";
mysql_query($query);
mysql_close();
?>

<a href="websiteinputform2.html">Add another player</a>
</body>
</html>


Thank you

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 27 September 2006 - 11:27 AM

You had double quote (maked in red) in your query. Which was breaking the string. And thus you got the error.

$query="INSERT INTO roster VALUES(",'$first','$last','$number','$position','$height','$weight','$shoots','$dob')";


use this instead:
$query="INSERT INTO roster VALUES(NULL,'$first','$last','$number','$position','$height','$weight','$shoots','$dob')";


#3 Meza44

Meza44
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 27 September 2006 - 02:22 PM

thank you




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users