Jump to content

Problem with query


Perad

Recommended Posts

I have 2 columns, descriptions and page. I want to find the images where page = $page and descriptions = header. However my query doesn't appear to be checking anything after the AND statement and thus is bringing back everything whether the discription is header or not.

 

What am i doing wrong?

 

$sql = "SELECT * FROM images WHERE page='$page' AND descriptions='header'";

Link to comment
https://forums.phpfreaks.com/topic/52338-problem-with-query/
Share on other sites

echo $sql = SELECT * FROM images WHERE page='portfolio' AND descriptions='header'

echo $result = Resource id #7

 

edit: complete statement is as follows.

$sql = "SELECT * FROM images WHERE page='$page' AND descriptions='header'";
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc ($result)) {
$imageurl[] = $row['imagename'] . '.' . $row['type'];
}

Link to comment
https://forums.phpfreaks.com/topic/52338-problem-with-query/#findComment-258254
Share on other sites

try this

 

<?php
$sql = "SELECT * FROM images WHERE page='$page' AND descriptions='header'";
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc ($result)) {
$imageurl[] = $row['imagename'] . '.' . $row['type'];
if($row['descriptions']!="header"){die("ERROR");}
}
?>

 

what happens

Link to comment
https://forums.phpfreaks.com/topic/52338-problem-with-query/#findComment-258274
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.