Jump to content

Archived

This topic is now archived and is closed to further replies.

Meza44

PHP error

Recommended Posts

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

Share this post


Link to post
Share on other sites
You had double quote (maked in red) in your query. Which was breaking the string. And thus you got the error.
[quote]$query="INSERT INTO roster VALUES([color=red][b]"[/b][/color],'$first','$last','$number','$position','$height','$weight','$shoots','$dob')";[/quote]

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

Share this post


Link to post
Share on other sites

×

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.