PHP5 - MySQL Parse error:

Reply

Join Date: Apr 2005
Posts: 26
Reputation: Walyer is an unknown quantity at this point 
Solved Threads: 1
Walyer's Avatar
Walyer Walyer is offline Offline
Light Poster

PHP5 - MySQL Parse error:

 
0
  #1
Jan 16th, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 27
Reputation: calcop is an unknown quantity at this point 
Solved Threads: 0
calcop calcop is offline Offline
Light Poster

Re: PHP5 - MySQL Parse error:

 
0
  #2
Jan 22nd, 2006
You forgot to terminate the line that contains

  1. mysql_select_db("musiclist", $conn)

it should be:

  1. mysql_select_db("musiclist", $conn);

-matt
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC