Jump to content

[SOLVED] PHP mysql_fetch_array() not working?


EPCtech

Recommended Posts

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

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

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.