у меня здесь все правильно? PHP: <? $found=false; $row=mysql_fetch_row(mysql_query("SELECT name FROM ticket where id=0"));$order=$row[0]; $res=mysql_query("SELECT * FROM ticket where id<>0 order by $order"); if(mysql_num_rows($res)>0){ $found=true; print " <tr bgcolor=#e4e4e4> <td align=center colspan=3 style='font-size:12px;color:#41559D' style='border:solid 1px silver'><b>Автомты с выдачей билетов</b></td> </tr> "; while($row=mysql_fetch_row($res)){ if($row[3]!=""){ $r1=preg_replace("/\"/","''",$row[1]); $r2=preg_replace("/\"/","''",$row[2]); $alt="$r1\n$r2\nЦена: $row[5] $row[6]";$alt=del_tags($alt); $img="<img src=img.php?src=foto/$row[3]&width=50 width=50 alt=\"$alt\" style='border:solid 1px black'>"; } else{$img="<img src=img/none_small.gif width=50 style='border:solid 1px black'>";} print " <tr bgcolor=ECF0FC> <td width=10% align=center style='border:solid 1px silver'>$img</td> <td style='border:solid 1px silver'><a href=\"JavaScript:detail($row[0],1);\" class=syn><b>$row[1]</b></a><br>$row[2]</td> <td width=10% align=center class=price style='border:solid 1px silver'><nobr><b>$row[5] $row[6]</b></nobr></td> </tr> "; } } $row=mysql_fetch_row(mysql_query("SELECT name FROM imitator where id=0"));$order=$row[0]; $res=mysql_query("SELECT * FROM imitator where id<>0 order by $order"); if(mysql_num_rows($res)>0){ $found=true; print " <tr bgcolor=#e4e4e4> <td align=center colspan=3 style='font-size:12px;color:#41559D' style='border:solid 1px silver'><b>Автоматы-имитаторы</b></td> </tr> "; while($row=mysql_fetch_row($res)){ if($row[3]!=""){ $r1=preg_replace("/\"/","''",$row[1]); $r2=preg_replace("/\"/","''",$row[2]); $alt="$r1\n$r2\nЦена: $row[5] $row[6]";$alt=del_tags($alt); $img="<img src=img.php?src=foto/$row[3]&width=50 width=50 alt=\"$alt\" style='border:solid 1px black'>"; } else{$img="<img src=img/none_small.gif width=50 style='border:solid 1px black'>";} print " <tr bgcolor=ECF0FC> <td width=10% align=center style='border:solid 1px silver'>$img</td> <td style='border:solid 1px silver'><a href=\"JavaScript:detail($row[0],2);\" class=syn><b>$row[1]</b></a><br>$row[2]</td> <td width=10% align=center class=price style='border:solid 1px silver'><nobr><b>$row[5] $row[6]</b></nobr></td> </tr> "; } } $row=mysql_fetch_row(mysql_query("SELECT name FROM attraction where id=0"));$order=$row[0]; $res=mysql_query("SELECT * FROM attraction where id<>0 order by $order"); if(mysql_num_rows($res)>0){ $found=true; print " <tr bgcolor=#e4e4e4> <td align=center colspan=3 style='font-size:12px;color:#41559D' style='border:solid 1px silver'><b>Уличные аттракционы</b></td> </tr> "; while($row=mysql_fetch_row($res)){ if($row[3]!=""){ $r1=preg_replace("/\"/","''",$row[1]); $r2=preg_replace("/\"/","''",$row[2]); $alt="$r1\n$r2\nЦена: $row[5] $row[6]";$alt=del_tags($alt); $img="<img src=img.php?src=foto/$row[3]&width=50 width=50 alt=\"$alt\" style='border:solid 1px black'>"; } else{$img="<img src=img/none_small.gif width=50 style='border:solid 1px black'>";} print " <tr bgcolor=ECF0FC> <td width=10% align=center style='border:solid 1px silver'>$img</td> <td style='border:solid 1px silver'><a href=\"JavaScript:detail($row[0],3);\" class=syn><b>$row[1]</b></a><br>$row[2]</td> <td width=10% align=center class=price style='border:solid 1px silver'><nobr><b>$row[5] $row[6]</b></nobr></td> </tr> "; } } $row=mysql_fetch_row(mysql_query("SELECT name FROM laser where id=0"));$order=$row[0]; $res=mysql_query("SELECT * FROM laser where id<>0 order by $order"); if(mysql_num_rows($res)>0){ $found=true; print " <tr bgcolor=#e4e4e4> <td align=center colspan=3 style='font-size:12px;color:#41559D' style='border:solid 1px silver'><b>Тир лазерный</b></td> </tr> "; while($row=mysql_fetch_row($res)){ if($row[3]!=""){ $r1=preg_replace("/\"/","''",$row[1]); $r2=preg_replace("/\"/","''",$row[2]); $alt="$r1\n$r2\nЦена: $row[5] $row[6]";$alt=del_tags($alt); $img="<img src=img.php?src=foto/$row[3]&width=50 width=50 alt=\"$alt\" style='border:solid 1px black'>"; } else{$img="<img src=img/none_small.gif width=50 style='border:solid 1px black'>";} print " <tr bgcolor=ECF0FC> <td width=10% align=center style='border:solid 1px silver'>$img</td> <td style='border:solid 1px silver'><a href=\"JavaScript:detail($row[0],4);\" class=syn><b>$row[1]</b></a><br>$row[2]</td> <td width=10% align=center class=price style='border:solid 1px silver'><nobr><b>$row[5] $row[6]</b></nobr></td> </tr> "; } } if(!$found){ print " <tr bgcolor=white> <td align=center colspan=3 style='font-size:12px;color:#41559D'><b>Описания пока не готовы...</b></td> </tr> "; } ?>
pnata ну я бы сделал так: PHP: <? $found=false; $sql = "SELECT name FROM ticket where id=0"; $res = mysql_query($sql); ################################################ if(!$res) { print("Ошибка: [$sql] - ".mysql_error()); exit(); } ################################################ $row=mysql_fetch_row($res); $order=$row[0]; $sql = "SELECT * FROM ticket where id<>0 order by $order"; $res=mysql_query($sql); ################################################ if(!$res) { print("Ошибка: [$sql] - ".mysql_error()); exit(); } ################################################ if(mysql_num_rows($res)>0) { $found=true; print " <tr bgcolor=#e4e4e4> <td align=center colspan=3 style='font-size:12px;color:#41559D' style='border:solid 1px silver'><b>Автомты с выдачей билетов</b></td> </tr> "; while($row=mysql_fetch_row($res)) { if($row[3]!="") { $r1=str_replace('"','',$row[1]); $r2=preg_replace('"','',$row[2]); $alt="$r1\n$r2\nЦена: $row[5] $row[6]"; $alt=del_tags($alt); $img="<img src=img.php?src=foto/$row[3]&width=50 width=50 alt=\"$alt\" style='border:solid 1px black'>"; } else { $img="<img src=img/none_small.gif width=50 style='border:solid 1px black'>";} print " <tr bgcolor=ECF0FC> <td width=10% align=center style='border:solid 1px silver'>$img</td> <td style='border:solid 1px silver'><a href=\"JavaScript:detail($row[0],1);\" class=syn><b>$row[1]</b></a><br>$row[2]</td> <td width=10% align=center class=price style='border:solid 1px silver'><nobr><b>$row[5] $row[6]</b></nobr></td> </tr> "; } } } ### дальше сама ... ?>
$sql = "SELECT name FROM ticket where id=0"; $res = mysql_query($sql); ################################################ if(!$res) { print("Ошибка: [$sql] - ".mysql_error()); exit(); } прям тут же выдает ошибку! значит в базе что то не так?
Notice: Undefined variable: res in /pub/home/sevik99/htdocs/catalog.php on line 127 Notice: Undefined variable: sql in /pub/home/sevik99/htdocs/catalog.php on line 128
<? include "config.php"; include "func.php"; ?> <!-- Content --> <? error_reporting(E_ALL); $found=false; $row=mysql_fetch_row(mysql_query("SELECT name FROM ticket where id=0"));$order=$row[0]; if(!$res) { print("Ошибка: [$sql] - ".mysql_error()); exit(); } $res=mysql_query("SELECT * FROM ticket where id<>0 order by $order"); if(mysql_num_rows($res)>0){ $found=true; print " <tr bgcolor=#e4e4e4> <td align=center colspan=3 style='font-size:12px;color:#41559D' style='border:solid 1px silver'><b>Автомты с выдачей билетов</b></td> </tr> "; while($row=mysql_fetch_row($res)){ if($row[3]!=""){ $r1=preg_replace("/\"/","''",$row[1]); $r2=preg_replace("/\"/","''",$row[2]); $alt="$r1\n$r2\nЦена: $row[5] $row[6]";$alt=del_tags($alt); $img="<img src=img.php?src=foto/$row[3]&width=50 width=50 alt=\"$alt\" style='border:solid 1px black'>"; } else{$img="<img src=img/none_small.gif width=50 style='border:solid 1px black'>";} print " <tr bgcolor=ECF0FC> <td width=10% align=center style='border:solid 1px silver'>$img</td> <td style='border:solid 1px silver'><a href=\"JavaScript:detail($row[0],1);\" class=syn><b>$row[1]</b></a><br>$row[2]</td> <td width=10% align=center class=price style='border:solid 1px silver'><nobr><b>$row[5] $row[6]</b></nobr></td> </tr> "; } } $row=mysql_fetch_row(mysql_query("SELECT name FROM imitator where id=0"));$order=$row[0]; $res=mysql_query("SELECT * FROM imitator where id<>0 order by $order"); if(mysql_num_rows($res)>0){ $found=true; print " <tr bgcolor=#e4e4e4> <td align=center colspan=3 style='font-size:12px;color:#41559D' style='border:solid 1px silver'><b>Автоматы-имитаторы</b></td> </tr> "; while($row=mysql_fetch_row($res)){ if($row[3]!=""){ $r1=preg_replace("/\"/","''",$row[1]); $r2=preg_replace("/\"/","''",$row[2]); $alt="$r1\n$r2\nЦена: $row[5] $row[6]";$alt=del_tags($alt); $img="<img src=img.php?src=foto/$row[3]&width=50 width=50 alt=\"$alt\" style='border:solid 1px black'>"; } else{$img="<img src=img/none_small.gif width=50 style='border:solid 1px black'>";} print " <tr bgcolor=ECF0FC> <td width=10% align=center style='border:solid 1px silver'>$img</td> <td style='border:solid 1px silver'><a href=\"JavaScript:detail($row[0],2);\" class=syn><b>$row[1]</b></a><br>$row[2]</td> <td width=10% align=center class=price style='border:solid 1px silver'><nobr><b>$row[5] $row[6]</b></nobr></td> </tr> "; } } $row=mysql_fetch_row(mysql_query("SELECT name FROM attraction where id=0"));$order=$row[0]; $res=mysql_query("SELECT * FROM attraction where id<>0 order by $order"); if(mysql_num_rows($res)>0){ $found=true; print " <tr bgcolor=#e4e4e4> <td align=center colspan=3 style='font-size:12px;color:#41559D' style='border:solid 1px silver'><b>Уличные аттракционы</b></td> </tr> "; while($row=mysql_fetch_row($res)){ if($row[3]!=""){ $r1=preg_replace("/\"/","''",$row[1]); $r2=preg_replace("/\"/","''",$row[2]); $alt="$r1\n$r2\nЦена: $row[5] $row[6]";$alt=del_tags($alt); $img="<img src=img.php?src=foto/$row[3]&width=50 width=50 alt=\"$alt\" style='border:solid 1px black'>"; } else{$img="<img src=img/none_small.gif width=50 style='border:solid 1px black'>";} print " <tr bgcolor=ECF0FC> <td width=10% align=center style='border:solid 1px silver'>$img</td> <td style='border:solid 1px silver'><a href=\"JavaScript:detail($row[0],3);\" class=syn><b>$row[1]</b></a><br>$row[2]</td> <td width=10% align=center class=price style='border:solid 1px silver'><nobr><b>$row[5] $row[6]</b></nobr></td> </tr> "; } } $row=mysql_fetch_row(mysql_query("SELECT name FROM laser where id=0"));$order=$row[0]; $res=mysql_query("SELECT * FROM laser where id<>0 order by $order"); if(mysql_num_rows($res)>0){ $found=true; print " <tr bgcolor=#e4e4e4> <td align=center colspan=3 style='font-size:12px;color:#41559D' style='border:solid 1px silver'><b>Тир лазерный</b></td> </tr> "; while($row=mysql_fetch_row($res)){ if($row[3]!=""){ $r1=preg_replace("/\"/","''",$row[1]); $r2=preg_replace("/\"/","''",$row[2]); $alt="$r1\n$r2\nЦена: $row[5] $row[6]";$alt=del_tags($alt); $img="<img src=img.php?src=foto/$row[3]&width=50 width=50 alt=\"$alt\" style='border:solid 1px black'>"; } else{$img="<img src=img/none_small.gif width=50 style='border:solid 1px black'>";} print " <tr bgcolor=ECF0FC> <td width=10% align=center style='border:solid 1px silver'>$img</td> <td style='border:solid 1px silver'><a href=\"JavaScript:detail($row[0],4);\" class=syn><b>$row[1]</b></a><br>$row[2]</td> <td width=10% align=center class=price style='border:solid 1px silver'><nobr><b>$row[5] $row[6]</b></nobr></td> </tr> "; } } if(!$found){ print " <tr bgcolor=white> <td align=center colspan=3 style='font-size:12px;color:#41559D'><b>Описания пока не готовы...</b></td> </tr> "; } ?> <!-- End Content -->
pnata error_reporting(E_ALL); $found=false; $row=mysql_fetch_row(mysql_query("SELECT name FROM ticket where id=0"));$order=$row[0]; if(!$res) { print("Ошибка: [$sql] - ".mysql_error()); exit(); } ты не сделала как я написал! PHP: <? $sql = "SELECT name FROM ticket where id=0"; $res = mysql_query($sql); ################################################ if(!$res) { print("Ошибка: [$sql] - ".mysql_error()); exit(); } ################################################?>