Jump to content

Small Problem


rasta

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

Link to comment
Share on other sites

  • 2 weeks later...
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.