syclonefx Posted August 31, 2007 Share Posted August 31, 2007 I need help I am getting this error. Unknown column 'popwarner' in 'where clause' Here is my Query: <?php $VidCat = ($row_rsCategory['CategoryTitle']); $query1 = sprintf("SELECT * FROM videos WHERE Active = 1 AND Category = %s",mysql_real_escape_string($VidCat)); $result = mysql_query($query1) or die(mysql_error()); while ($row = mysql_fetch_assoc($result)) { echo '<span class=""><a href="video_pl.php?video_ID=' . $row['video_ID'] . '" class="" title="' .$row['VideoTitle']. '">' .$row['VideoTitle']. '</a></span><br />'; } ?> If I change my query to this: <?php $VidCat = ($row_rsCategory['CategoryTitle']); $query1 = sprintf("SELECT * FROM videos WHERE Category = 'popwarner'"); $result = mysql_query($query1) or die(mysql_error()); while ($row = mysql_fetch_assoc($result)) { echo '<span class=""><a href="video_pl.php?video_ID=' . $row['video_ID'] . '" class="" title="' .$row['VideoTitle']. '">' .$row['VideoTitle']. '</a></span><br />'; } ?> Everything works fine. Link to comment https://forums.phpfreaks.com/topic/67498-solved-query-problem/ Share on other sites More sharing options...
Ken2k7 Posted August 31, 2007 Share Posted August 31, 2007 Okay so what's the help that you need now? Link to comment https://forums.phpfreaks.com/topic/67498-solved-query-problem/#findComment-338894 Share on other sites More sharing options...
phpSensei Posted August 31, 2007 Share Posted August 31, 2007 What does valued does $vidcat contain? Link to comment https://forums.phpfreaks.com/topic/67498-solved-query-problem/#findComment-338897 Share on other sites More sharing options...
matthewhaworth Posted August 31, 2007 Share Posted August 31, 2007 It's always best to print out your query as a form of debugging add. <?php echo $query1; ?> Before the query is executed and the problem may become obvious to you . Link to comment https://forums.phpfreaks.com/topic/67498-solved-query-problem/#findComment-338899 Share on other sites More sharing options...
syclonefx Posted August 31, 2007 Author Share Posted August 31, 2007 It's always best to print out your query as a form of debugging add. <?php echo $query1; ?> Before the query is executed and the problem may become obvious to you . Thanks matthewhaworth I got it.. %s should have been '%s' <?php $VidCat = ($row_rsCategory['CategoryTitle']); $query1 = sprintf("SELECT * FROM videos WHERE Active = 1 AND Category = '%s'",mysql_real_escape_string($VidCat)); //echo ($query1). '<br>'; $result = mysql_query($query1) or die(mysql_error()); while ($row = mysql_fetch_assoc($result)) { echo '<span class=""><a href="video_pl.php?video_ID=' . $row['video_ID'] . '" class="" title="' .$row['VideoTitle']. '">' .$row['VideoTitle']. '</a></span><br />'; } ?> Link to comment https://forums.phpfreaks.com/topic/67498-solved-query-problem/#findComment-338918 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.