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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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