Link to home
Start Free TrialLog in
Avatar of Nick50000
Nick50000

asked on

SQL question....

Hi,

Why does this sample of code just produce a blank page?

<?php

$cat=test;

$conn=mysql_connect("host","user","pass");
if(!$conn){
       echo"cant connect";
       die;
}

mysql_select_db("testdb");

$qid=mysql_query("SELECT * FROM testtable WHERE cat=$cat");

while($row=mysql_fetch_array($qid)){
?>
<table>
<tr><td><?=$row[heading]?></td></tr>
<tr><td><?=$row[message]?></td></tr>
<tr><td><a href="/folder/subfolder/script.php?id=<?=$row[id]?>">LINK</a></td></tr>
</table>

<br><br>
<?}?>

I am a SQL newbie, and I think there's something wrong with the "SELECT * FROM testtable WHERE cat=$cat" part, but have been unable to fiqure it out.

Thanks,
Nick!
ASKER CERTIFIED SOLUTION
Avatar of Batalf
Batalf
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lokeshv
lokeshv

put $cat in '',

then echo ur query and check...is that alrite ?

is till doesnt work ...


put this few lines after

$qid=....

if(!$qid){

echo 'Error :'.mysql_error();
}

and check the error...


Hope this helps..

LK

Avatar of Nick50000

ASKER

O.K thanks, i'm trying that now.
Great, your advice worked first time....

Problem solved!

Thanks,
Nick!!!
Glad I could help.

Batalf