943,713 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 5716
  • PHP RSS
Jan 16th, 2006
0

PHP5 - MySQL Parse error:

Expand Post »
hey,

i'm trying to insert data into my database with PHP5

i've created this code,

<?
//open the connection
$conn = mysql_connect("localhost", "user", "pass");
//pick the database to use
mysql_select_db("musiclist", $conn)
//create SQL statement
$sql = "INSERT INTO musiclist (artist, title)";
$sql.= "VALUES (";
$sql.= "'John Denver', 'Thank God I'm A Country Boy')";
//execute the SQL statement
if(mysql_query($sql, $conn))
{echo "record added!";}
else
{echo "something went worng!";}
?>

and to my eyes it looks good, but i keep getting this error

Parse error: syntax error, unexpected T_VARIABLE in C:\www\leewalsh\php\musiclist.php on line 17

this is line 17

$sql = "INSERT INTO musiclist (artist, title)";

i don't really understand it fully yet so any help woul be great

--Walyer

Walyer's Playpen
Reputation Points: 10
Solved Threads: 1
Light Poster
Walyer is offline Offline
26 posts
since Apr 2005
Jan 22nd, 2006
0

Re: PHP5 - MySQL Parse error:

You forgot to terminate the line that contains

PHP Syntax (Toggle Plain Text)
  1. mysql_select_db("musiclist", $conn)

it should be:

PHP Syntax (Toggle Plain Text)
  1. mysql_select_db("musiclist", $conn);

-matt
Reputation Points: 10
Solved Threads: 0
Light Poster
calcop is offline Offline
27 posts
since Oct 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Please help me!!!
Next Thread in PHP Forum Timeline: help please i am a php dummy :eek:





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC