954,597 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource

Hi, I've tried several of the fixes for this that I've found on here, but I haven't been able to find a work around.

Here is the code that I'm having the trouble with:

mysql_select_db($db_name,$db);
$result = mysql_query("SELECT * FROM pages WHERE pagenumber LIKE $pagenumber ",$db) ;
while ($myrow = mysql_fetch_array($result)) {


This is the error message I get on my site:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /mnt/Target01/327952/328384/www.liquidskin.com/web/content/xcart/templates_c/customer^main^welcome.tpl on line 25

dsustaita
Newbie Poster
3 posts since Aug 2007
Reputation Points: 10
Solved Threads: 0
 

Sorry, here is the rest of my code:

//Defining Variables
$pagenumber = $myrow["pagenumber"];
$pagename = $myrow["pagename"];
$html_head = $myrow["html_head"];
$html_body = $myrow["html_body"];
$html_foot = $myrow["html_foot"];
$media_link1 = $myrow["media_link1"];
$media_link2 = $myrow["media_link2"];
$media_link3 = $myrow["media_link3"];
$media_link4 = $myrow["media_link4"];
$media_link5 = $myrow["media_link5"];
$media_link6 = $myrow["media_link6"];
$media_link7 = $myrow["media_link7"];
$html_title = $myrow["html_title"];
$bg_color = $myrow["bg_color"];
$bg_image = $myrow["bg_image"];
$style = $myrow["style"];
$text1 = $myrow["text1"];
$text2 = $myrow["text2"];
$text3 = $myrow["text3"];
$text4 = $myrow["text4"];
$text1 = stripslashes($text1);
}
echo $html_head;
echo $text1;
}
 ?>

<p>
<?php if ($this->_tpl_vars['active_modules']['Bestsellers'] != "" && $this->_tpl_vars['config']['Modules']['bestsellers_menu'] != 'Y'): ?>
<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include("modules/Bestsellers/bestsellers.tpl", array());
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>
<?php endif; ?>
dsustaita
Newbie Poster
3 posts since Aug 2007
Reputation Points: 10
Solved Threads: 0
 

Hello.

Pay attention to the quotes :

$result = mysql_query("SELECT * FROM pages WHERE pagenumber LIKE '$pagenumber' ",$db) ;


Hint : You don't have to use LIKE if you don't want to use it with pattern. Instead of LIKE here you can use this :

$result = mysql_query("SELECT * FROM pages WHERE pagenumber='$pagenumber' ",$db) ;

-Mitko Kostov

MitkOK
Junior Poster
142 posts since Jul 2007
Reputation Points: 59
Solved Threads: 12
 

Thanks for th suggestion

dsustaita
Newbie Poster
3 posts since Aug 2007
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You