Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Could someone help fix this script :)

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi, I was wondering if someone could help fix the script below, it's being real annoying, i'm sure the mistake is obvious i used a previous script i made and edited it alot and now it doesn't work. I think it's got something todo with the values not being picked up for the $data variable.

If someone could help I'd be very greatful. Thanx

<?
if (!isset($debut)) $debut = 0;
$db = mysql_connect($host,$login,$pass);
mysql_select_db($base,$db);

$sql2 = &quot;SELECT * FROM bands_tbl WHERE cat = '$cat' ORDER BY name ASC &quot;;
$req2 = mysql_query($sql2) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
$nb = mysql_num_rows($req2);

$sql = &quot;SELECT * FROM bands_tbl WHERE cat = '$cat' ORDER BY name ASC LIMIT $debut,$limit &quot;;
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());


if ($nb<1) {
echo '<center><font face=&quot;Verdana&quot; size=&quot;2&quot;><b>No bands in this category</b></font></center>';
} else {

while($data = mysql_fetch_array($req))
echo '<p align=&quot;left&quot; style=&quot;margin-bottom: 5&quot;><font face=&quot;Verdana&quot; size=&quot;2&quot;><img border=&quot;0&quot; src=&quot;../images/lnav_5.gif&quot; width=&quot;12&quot; height=&quot;8&quot;><a href=&quot;band_info.php?id='.$data['id'].'&quot;>
<b>'.$data['name'].'</b></a></font><b><font face=&quot;Verdana&quot; size=&quot;1&quot;>&nbsp;&nbsp;[</font></b>';

$sql3 = &quot;SELECT * FROM tabs_tbl WHERE band_id = '.$data['id'].'&quot;;
$req3 = mysql_query($sql3) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
$nb3 = mysql_num_rows($req3);

if ($nb3<1) {
echo '';
} else {
echo '<font face=&quot;Verdana&quot; size=&quot;1&quot;>Tabs - <a href=&quot;tabs_songs.php?id='.$data['id'].'&name='.$data['name'].'&filetype='.bass_tabs.'&filetype_name='.Bass_Tabs.'&quot;>Bass</a> | <a href=&quot;tabs_songs.php?id='.$data['id'].'&filetype='.drum_tabs.'&filetype_name='.Drum_Tabs.'&quot;>Drum</a> | <a href=&quot;tabs_songs.php?id='.$data['id'].'&filetype='.guitar_tabs.'&filetype_name='.Guitar_Tabs.'&quot;>Guitar</a>] - </font>';
}

$sql4 = &quot;SELECT * FROM tabs_tbl WHERE band_id = '.$data['id'].' & filetype = 'lyrics'&quot;;
$req4 = mysql_query($sql4) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
$nb4 = mysql_num_rows($req4);

if ($nb4<1) {
echo '';
} else {
echo '<font face=&quot;Verdana&quot; size=&quot;1&quot;>[<a href=&quot;tabs_songs.php?id='.$data['id'].'&filetype='.lyrics.'&filetype_name='.Lyrics.'&quot;>Lyrics</a>] - </font>';
}

echo '[<a href=&quot;bandreviews.php?band_id='.$data['id'].'&quot;>Reviews</a>]</font></p>
<div align=&quot;center&quot;>
<table border=&quot;0&quot; width=&quot;90%&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;>
<tr>
<td width=&quot;100%&quot;><font face=&quot;Verdana&quot; size=&quot;1&quot; color=&quot;#D0CCD0&quot;>'.$data['description'].' </font></td>
</tr>
</table>
</div>
<p align=&quot;right&quot; style=&quot;margin-top: 5&quot;><font face=&quot;Verdana&quot; size=&quot;1&quot; color=&quot;#000000&quot;>[ Rating:
'.$data['vote_avg'].'
Votes: '.$data['nbr_votes'].' ] </font><font face=&quot;Verdana&quot; size=&quot;1&quot;><a href=&quot;javascript:Rate_Band(\'rateband.php?id='.$data['id'].'\')&quot;><u>Rate
Band</u></a></font></p>
<p align=&quot;right&quot;>';

$nombre=ceil($nb/$limit);

echo &quot;<center>&quot;; if($debut>0)
{
echo &quot;<font face=\&quot;Verdana\&quot; size=\&quot;1\&quot;><a href=bands.php?cat=$cat&debut=&quot;.($debut-$limit). &quot;><<</a> </font> &quot;;
}

if ($nombre>1)
{ for($i=1; $i<=$nombre; $i++)
{
echo &quot;<font face=\&quot;Verdana\&quot; size=\&quot;1\&quot;><a href=bands.php?cat=$cat&debut=&quot;.(($i-1)*$limit). &quot;>&quot;.$i. &quot;</a> </font> &quot;;
}
}
if(($debut+$limit)<$nb)
{
echo &quot;<font face=\&quot;Verdana\&quot; size=\&quot;1\&quot;><a href=bands.php?cat=$cat&debut=&quot;.($debut+$limit). &quot;>>></a></font>&quot;;
}

echo &quot;</CENTER>&quot;;

} mysql_close($db);
?>
 
First, I'd change
Code:
$sql2 = &quot;SELECT * FROM bands_tbl WHERE cat = '$cat' ORDER BY name ASC &quot;;
$req2 = mysql_query($sql2) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
$nb = mysql_num_rows($req2);
to
Code:
$sql2 = &quot;SELECT count(*) FROM bands_tbl WHERE cat = '$cat' ORDER BY name ASC&quot;;
$req2 = mysql_query($sql2) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
$nb = (mysql_fetch_row($req))[0];
Also, you have to tell us what isn't working, what errors are you getting, etc. //Daniel
 
Actually, a typo in my previous post.
Code:
$nb = (mysql_fetch_row($req))[0];
should've been
Code:
list($nb) = mysql_fetch_row($req);
I'm not sure the first works, but I know the second one is. //Daniel
 
Cheers for your help already here's the error I get.

Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /home/virtual/newfound/home/httpd/html/banddatabase2/bands.php on line 96

Because the above code is just a clip from my original code here is the line numbers.

96: $sql3 = &quot;SELECT * FROM tabs_tbl WHERE band_id = '.$data['id'].'&quot;;

97: $req3 = mysql_query($sql3) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());

98: $nb3 = mysql_num_rows($req3);
 
96: $sql3 = &quot;SELECT * FROM tabs_tbl WHERE band_id = '$data[id]'&quot;;
______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
cheers it wasn't the exact answer because i put a typo but i found out that i need to put { } after the while statement and after the last echo statement. Cheers anywayz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top