Forum Moderators: coopster
I get the following warning after $sql data is printed as shown
SELECT * FROM reflections WHERE `trusted` = 1 AND `catid` = 1 ORDER BY `id` ASC LIMIT 8, 1
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mysite/public_html/addons/class.upload/pages.php on line 66
$sql = "SELECT * FROM reflections WHERE `trusted` = 1 AND `catid` = 1 ORDER BY `id` ASC LIMIT $from, $max_results";mysql_query($sql);
echo $sql;
while($row = mysql_fetch_array($sql))
{
if(strlen(isset($_GET['tcheck']))>0 && $_GET['tcheck']==$safeurl->make_safe_url($row['title'])){
$tcheck=trim(mysql_real_escape_string($_GET['tcheck']));
}else{
echo "invalid query";
exit;}
echo "<!--start-->";
echo "<font size=3><b>";
echo $row['title']."</b><br /></font>";
echo "<font size=2>";
echo "Added On ";
echo date("jS F Y H:i:s", $row['date'])."<p>";
echo '<img src="/addons/class.upload/test/'.$name.'" border="0" height="50%" width="50%" alt="' . $row['title'] .'" />';
echo "<!--end-->";
}
$sql = "SELECT * FROM reflections WHERE `trusted` = 1 AND `catid` = 1 ORDER BY `id` ASC LIMIT $from, $max_results";$result = mysql_query($sql) or die('select died: ' . mysql_error());
echo $sql;
echo $result;
while($row = mysql_fetch_array($sql))
{
... some data
}
To this it gives me $sql,$result followed by the warning as shown
SELECT * FROM reflections WHERE `trusted` = 1 AND `catid` = 1 ORDER BY `id` ASC LIMIT 8, 1
Resource id #6
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mysite/public_html/addons/class.upload/pages.php on line 67
$sql = "SELECT * FROM reflections WHERE `trusted` = 1 AND `catid` = 1 ORDER BY `id` ASC LIMIT $from, $max_results";$result = mysql_query($sql) or die('select died: ' . mysql_error());
echo $sql;
echo $result;
while($row = mysql_fetch_array($result)){
echo "inside while loop";
}
SELECT * FROM reflections WHERE `trusted` = 1 AND `catid` = 1 ORDER BY `id` ASC LIMIT 8, 1
Resource id #6
No warnings but still it does not go into the while loop and print "inside while loop"... what could be the reason now? Any problem with the query
adding the or die after your query call as I did will show you the actual error from mysql if there is one. If the query works then it will not be displayed. It makes echoing the resource redundant plus gives you information you can use to fix it.
I am using the code below to display the image
echo '<img src="/addons/class.upload/test/'.$name.'" border="0" height="50%" width="50%" alt="' . $row['title'] .'" />'; it doesn't display the image and on clicking on image properties it gives http://example.com/addons/class.upload/test/
instead of http://example.com/addons/class.upload/test/confidence_1.jpg
which is the actual image , i asked this question in the morning also and then someone gave me the above code but now it doesn't display the image
secondly
I solved image thing, by writing
$name = $row['name'];
echo '<img src="/addons/class.upload/test/'.$name.'" border="0" height="50%" width="50%" alt="' . $row['title'] .'" />'; i was missing the first statement
ALL OK NOW Thanks to you all :)