View Full Version : PHP Help
Well I am making something so that visitors can enter the habbo name or dj name and it will display the results (Like the Rare search on Habbox).
But when there isnt any thing been searched I want it to display "", which is working fine, but when I search something I keep getting this error:
Fatal error: Cannot break/continue 1 level in /home/*****/public_html/folder/page.php on line 18
My code is
<?php
include("../connector.php");
$search = ($_GET["search"]);
if($search == "") {
echo ("Please enter a DJ or Habbo Name.");
} else {
echo ("<table style=\"border-width: 0px\" width=\"450\" align=\"center\">");
$sql = mysql_query(" SELECT * FROM `users` WHERE `username` REGEXP CONVERT( _utf8 '$search' USING latin1 ) COLLATE latin1_swedish_ci OR `habboname` REGEXP CONVERT( _utf8 '$search' USING latin1 ) COLLATE latin1_swedish_ci");
while($rows = mysql_fetch_array($sql))
if(!$a) print ("<tr>");
$a++;
print ("<td style=\"border-style: none\" align=\"center\"><img src=\"http://www.habbo.com/habbo-imaging/avatarimage?user=$rows[habboname]&action=0&direction=3&head_direction=3&img_format=gif&gesture=0&size=l\"><br><b>$rows[habboname]</b><br><i>DJ $rows[username]</i></td>");
if($a!=4) continue;
print ("</tr>");
unset($a);
}
echo ("</tr></table>");
?>
Line 18 is:
if($a!=4) continue;
Navicat
08-03-2008, 03:28 PM
Try this:
<?php
include ("../connector.php");
$search = ($_GET ["search"]);
if ($search == "") {
echo "Please enter a DJ or Habbo Name.";
} else {
echo "<table style=\"border-width: 0px\" width=\"450\" align=\"center\">";
$sql = mysql_query ( " SELECT * FROM `users` WHERE `username` LIKE '%$search%' OR `habboname` LIKE '%$search%'" );
$num = mysql_num_rows($sql);
if($num == "0") {
// Display nothing
} else {
while ($rows = mysql_fetch_array($sql)) {
echo "<tr>";
echo "<td style=\"border-style: none\" align=\"center\"><img src=\"http://www.habbo.com/habbo-imaging/avatarimage?user=$rows[habboname]&action=0&direction=3&head_direction=3&img_format=gif&gesture=0&size=l\"><br><b>$rows[habboname]</b><br><i>DJ $rows[username]</i></td>";
echo "</tr>";
}
}
echo "</tr></table>"
?>
Try this:
<?php
include ("../connector.php");
$search = ($_GET ["search"]);
if ($search == "") {
echo "Please enter a DJ or Habbo Name.";
} else {
echo "<table style=\"border-width: 0px\" width=\"450\" align=\"center\">";
$sql = mysql_query ( " SELECT * FROM `users` WHERE `username` LIKE '%$search%' OR `habboname` LIKE '%$search%'" );
$num = mysql_num_rows($sql);
if($num == "0") {
// Display nothing
} else {
while ($rows = mysql_fetch_array($sql)) {
echo "<tr>";
echo "<td style=\"border-style: none\" align=\"center\"><img src=\"http://www.habbo.com/habbo-imaging/avatarimage?user=$rows[habboname]&action=0&direction=3&head_direction=3&img_format=gif&gesture=0&size=l\"><br><b>$rows[habboname]</b><br><i>DJ $rows[username]</i></td>";
echo "</tr>";
}
}
echo "</tr></table>"
?>
unexpected $end
Also that one wont display it in columns :(
Thanks though :)
Navicat
08-03-2008, 03:53 PM
<?php
include ("../connector.php");
$search = ($_GET ["search"]);
if ($search == "") {
echo "Please enter a DJ or Habbo Name.";
} else {
echo "<table style=\"border-width: 0px\" width=\"450\" align=\"center\">";
$sql = mysql_query ( " SELECT * FROM `users` WHERE `username` LIKE '%$search%' OR `habboname` LIKE '%$search%'" );
$num = mysql_num_rows ( $sql );
if ($num == "0") {
// Display nothing
} else {
while ( $rows = mysql_fetch_array ( $sql ) ) {
echo "<tr>";
echo "<td style=\"border-style: none\" align=\"center\"><img src=\"http://www.habbo.com/habbo-imaging/avatarimage?user=$rows[habboname]&action=0&direction=3&head_direction=3&img_format=gif&gesture=0&size=l\"><br><b>$rows[habboname]</b><br><i>DJ $rows[username]</i></td>";
echo "</tr>";
}
}
echo "</tr></table>"
}
?>
Yeah it will..
<?php
include ("../connector.php");
$search = ($_GET ["search"]);
if ($search == "") {
echo "Please enter a DJ or Habbo Name.";
} else {
echo "<table style=\"border-width: 0px\" width=\"450\" align=\"center\">";
$sql = mysql_query ( " SELECT * FROM `users` WHERE `username` LIKE '%$search%' OR `habboname` LIKE '%$search%'" );
$num = mysql_num_rows ( $sql );
if ($num == "0") {
// Display nothing
} else {
while ( $rows = mysql_fetch_array ( $sql ) ) {
echo "<tr>";
echo "<td style=\"border-style: none\" align=\"center\"><img src=\"http://www.habbo.com/habbo-imaging/avatarimage?user=$rows[habboname]&action=0&direction=3&head_direction=3&img_format=gif&gesture=0&size=l\"><br><b>$rows[habboname]</b><br><i>DJ $rows[username]</i></td>";
echo "</tr>";
}
}
echo "</tr></table>"
}
?> Yeah it will..
unexpected '}', expecting ',' or ';' on line 20
<?php
include ("../connector.php");
$search = ($_GET ["search"]);
if ($search == "") {
echo "Please enter a DJ or Habbo Name.";
} else {
echo "<table style=\"border-width: 0px\" width=\"450\" align=\"center\">";
$sql = mysql_query ( " SELECT * FROM `users` WHERE `username` LIKE '%$search%' OR `habboname` LIKE '%$search%'" );
$num = mysql_num_rows ( $sql );
if ($num == "0") {
// Display nothing
} else {
while ( $rows = mysql_fetch_array ( $sql ) ) {
echo "<tr>";
echo "<td style=\"border-style: none\" align=\"center\"><img src=\"http://www.habbo.com/habbo-imaging/avatarimage?user=$rows[habboname]&action=0&direction=3&head_direction=3&img_format=gif&gesture=0&size=l\"><br><b>$rows[habboname]</b><br><i>DJ $rows[username]</i></td>";
echo "</tr>";
}
}
echo "</tr></table>";
}
?>
Navicat
08-03-2008, 05:20 PM
****, I forgot a ;
Should be simple enough to fix without posting it? :P
I have already fixed this, but thanks to every one who helped :)
+ Rep to you all
Navicat
08-03-2008, 06:13 PM
No problem! :)
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.