rasta Posted January 11, 2003 Share Posted January 11, 2003 Hi, I\'m new to mysql and php but I\'m trying to create a music database for my site. I pass the variable \'id\' through the url. Basically I just want to display the songs and times that have the same id as the variable i pass from the previous page. I\'m not sure exactly what\'s wrong but I get a Parse error: parse error, unexpected T_STRING, expecting \',\' or \';\' error message. <?php $location = "xxx"; $username = "xxx"; $password = "xxx"; $database = "xxx"; $conn = mysql_connect("$location","$username","$password"); if (!$conn) die ("Could not connect MySQL"); mysql_select_db($database,$conn) or die ("Could not open database"); echo "<table width=200 border=0 cellpadding=4 cellspacing=0> <tr> <td width=100><p><b>Song</b></p></td> <td><p><b>Length</b></p></td> </tr>; $sql_events = mysql_query("SELECT * FROM `r-setlist` WHERE id = $id "); while ($row = mysql_fetch_array($sql_events)) { $song = $row["song"]; $length = $row["length"]; echo "<tr> <td width=100 nowrap><p>$song</p></td> <td nowrap><td nowrap><p>$length</p></td> </tr>"; $row_count++; } echo "</table>"; ?> Thanks Quote Link to comment Share on other sites More sharing options...
ToniVR Posted January 22, 2003 Share Posted January 22, 2003 Hi, I\'m new to mysql and php but I\'m trying to create a music database for my site. I pass the variable \'id\' through the url. Basically I just want to display the songs and times that have the same id as the variable i pass from the previous page. I\'m not sure exactly what\'s wrong but I get a Parse error: parse error, unexpected T_STRING, expecting \',\' or \';\' error message. What line number is given by the error? <?php $location = "xxx"; $username = "xxx"; $password = "xxx"; $database = "xxx"; $conn = mysql_connect("$location","$username","$password"); if (!$conn) die ("Could not connect MySQL"); mysql_select_db($database,$conn) or die ("Could not open database"); echo "<table width=200 border=0 cellpadding=4 cellspacing=0> <tr> <td width=100><p><b>Song</b></p></td> <td><p><b>Length</b></p></td> </tr>; $sql_events = mysql_query("SELECT * FROM `r-setlist` WHERE id = $id "); Are you using back-tics here? I would use: $sql_events = mysql_query("SELECT FROM r-setlist WHERE id=".$id); Works for me. while ($row = mysql_fetch_array($sql_events)) { $song = $row["song"]; $length = $row["length"]; echo "<tr> <td width=100 nowrap><p>$song</p></td> <td nowrap><td nowrap><p>$length</p></td> </tr>"; $row_count++; } echo "</table>"; ?> Thanks Hope this helps a little bit. Grtz, Toni. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.