EPCtech Posted July 21, 2008 Share Posted July 21, 2008 Hello PHPfreaks.com, I have a code in PHP that doesn't work for some reason. Could someone help me with it? $mainsql=MySQL_Query("SELECT * FROM mainf"); while($maininfo=MySQL_Fetch_Array($mainsql)) { $style=$maininfo['style']; $slogan=$maininfo['slogan']; $title=$maininfo['title'];$footer=$maininfo['footer']; } But, then, when I place it on a beta folder of my website, I get the following error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /****/*********/productsbeta/epmanage/index.php on line 32 (I replaced some parts with asterisks because I really don't want people to know them) If anyone could help with this, it would be greatly appreciated. Best Regards, En-Psyche Link to comment https://forums.phpfreaks.com/topic/115897-solved-php-mysql_fetch_array-not-working/ Share on other sites More sharing options...
kenrbnsn Posted July 21, 2008 Share Posted July 21, 2008 Change <?php $mainsql=MySQL_Query("SELECT * FROM mainf"); ?> to <?php $q = "SELECT * FROM mainf"; $mainsql=MySQL_Query($q) or die("Problem with the query: $q on line " . __LINE__ . '<br>' . mysql_error()); ?> You should get an error message that should tell you the problem. Ken Link to comment https://forums.phpfreaks.com/topic/115897-solved-php-mysql_fetch_array-not-working/#findComment-595882 Share on other sites More sharing options...
dezkit Posted July 21, 2008 Share Posted July 21, 2008 uh, aren't you just setting variables, you aren't even echo-ing anything Link to comment https://forums.phpfreaks.com/topic/115897-solved-php-mysql_fetch_array-not-working/#findComment-595884 Share on other sites More sharing options...
EPCtech Posted July 21, 2008 Author Share Posted July 21, 2008 dezkit: The query was the problem. Not echoing. kenrbnsn: The code told me something that I now feel stupid about. I forgot to connect to the database. Thanks for your help. This problem has been solved. Link to comment https://forums.phpfreaks.com/topic/115897-solved-php-mysql_fetch_array-not-working/#findComment-595887 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.