Jump to content


PHP Error


6 replies to this topic

#1 Deathskin

    Young Padawan

  • Members
  • Pip
  • 70 posts
  • Gender:Male

Posted 25 January 2007 - 07:19 PM

the error i get is this : Parse error: parse error, unexpected T_IF in C:\wamp\www\add.php on line 27.

Any help would be great :D thanks line 27 is bold. by the way.

HERES THE CODE:

<html>
<title></title>
<head>


</head>
<body>
<?php
//connect to mysql database
require ($_SERVER["DOCUMENT_ROOT"]."/Config/music.php");
$connection = mysql_connect($db_host, $db_user, $db_pw) or die(mysql_error());
mysql_select_db($db_name, $connection);
?>

<!-- Add Song Form -->
<form action="<?php $_SERVER[PHP_SELF] ?>" method=post>
<input type="text" name="artist" maxlength="75" value="artist">
<input type="text" name="song" maxlength="75" value="song">
<input type="text" name="rating" maxlength="3" size="1">
<input type="text" name="albumID" maxlength="4" size="1" value="ID">
<input type="submit" name="submit" value="send">
</form><br>
<!-- end of form -->
<?php

$sql = "INSERT INTO songs values('','$_POST[artist]','$_POST[song]', $_POST[rating], $_POST[albumID])"
if (MYSQL_QUERY($sql, $connection)){ echo "Record Added!";}
?>



</body>
</html>

#2 cheerio

    Young Padawan

  • Members
  • Pip
  • 246 posts
  • Gender:Male

Posted 25 January 2007 - 07:21 PM

You forgot a semicolon.
$sql = "INSERT INTO songs values('','$_POST[artist]','$_POST[song]', $_POST[rating], $_POST[albumID])"
should be
$sql = "INSERT INTO songs values('','$_POST[artist]','$_POST[song]', $_POST[rating], $_POST[albumID])";


#3 Deathskin

    Young Padawan

  • Members
  • Pip
  • 70 posts
  • Gender:Male

Posted 25 January 2007 - 07:44 PM

View Postcheerio, on Jan 26 2007, 12:21 AM, said:

You forgot a semicolon.
$sql = "INSERT INTO songs values('','$_POST[artist]','$_POST[song]', $_POST[rating], $_POST[albumID])"
should be
$sql = "INSERT INTO songs values('','$_POST[artist]','$_POST[song]', $_POST[rating], $_POST[albumID])";


ahhhhh YES thank you, should the semicolon always be after the quotes?

#4 bay

    Young Padawan

  • Members
  • Pip
  • 105 posts
  • Gender:Male
  • Location:Chicago, IL USA

Posted 25 January 2007 - 07:55 PM

It should be at the end of a any line of code. It tells the PHP Engine that "This is where this line of code ends. Now you can evaluate it. Otherwise, the engine gets confused :P

#5 Deathskin

    Young Padawan

  • Members
  • Pip
  • 70 posts
  • Gender:Male

Posted 29 January 2007 - 12:17 PM

thanks ;)

#6 smart-coder

    Young Padawan

  • Members
  • Pip
  • 16 posts

Posted 29 January 2007 - 06:37 PM

Yeah, its the semi colon, does your script work now?

#7 blacky

    Young Padawan

  • Members
  • Pip
  • 34 posts
  • Gender:Male

Posted 30 January 2007 - 11:17 PM

View Postsmart-coder, on Jan 29 2007, 03:37 PM, said:

Yeah, its the semi colon, does your script work now?


teehehehehe, i would assume it does by the "thanks" reply





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users