0

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

Edited by happygeek: fixed formatting

2
Contributors
1
Reply
2
Views
11 Years
Discussion Span
Last Post by calcop
0

You forgot to terminate the line that contains

mysql_select_db("musiclist", $conn)

it should be:

mysql_select_db("musiclist", $conn);

-matt

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.