Jump to content

Archived

This topic is now archived and is closed to further replies.

rasta

Small Problem

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.