Jump to content

PHP error


Meza44

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
Link to comment
https://forums.phpfreaks.com/topic/22234-php-error/
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]
Link to comment
https://forums.phpfreaks.com/topic/22234-php-error/#findComment-99528
Share on other sites

Archived

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

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