Jump to content


Photo

Small Problem


  • Please log in to reply
1 reply to this topic

#1 rasta

rasta
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 11 January 2003 - 05:57 AM

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

#2 ToniVR

ToniVR
  • New Members
  • Pip
  • Newbie
  • 6 posts
  • LocationBelgium

Posted 22 January 2003 - 12:32 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users