Jump to content

mysql_fetch_array();


steelmanronald06

Recommended Posts

[b]Warning:[/b]

[quote]
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\cms\includes\functions.php on line 41
[/quote]

[b]functions.php LINES: 30-43[/b]

[code]
<?php
30:  //*** Function: query, PUrpose: Execute a database query ***
31:  function $dbquery($query) {
32:
33:  $this->theQuery = $query;
34:  return mysql_query($query, $this->link) or die(mysql_error());
35:
36:  }
37: 
38:  //** Function: fetchArray, Purpose: Get array of query results ***
39:  function mysqlfetchArray($result) {
40: 
41:  return mysql_fetch_array($result) or die(mysql_error());
42:
43:  }
?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/22017-mysql_fetch_array/
Share on other sites

The error's telling you the problem is with the [url=http://uk.php.net/manual/en/function.mysql-query.php]mysql_query()[/url] command.

Look a little closer at the error:
[quote]
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\cms\includes\functions.php on line 41
[/quote]

What this means is that where you have [code=php:0]mysql_fetch_array($result)[/code], $result is not a valid resource.  Implying that this didn't work properly:

[code=php:0]
return mysql_query($query, $this->link) or die(mysql_error());
[/code]

Or that it did work correctly, but the line that's calling it is not [code=php:0]$result = dbquery($query);[/code]


and last but by no means least, and possibly the cause of the problem :) you have [code=php:0]function $dbquery($query){[/code] this should probably just be [code=php:0]function dbquery($query){[/code] without the [b]$[/b] at the beginning of the function name.

Regards
Huggie
Link to comment
https://forums.phpfreaks.com/topic/22017-mysql_fetch_array/#findComment-98473
Share on other sites

[quote author=HuggieBear link=topic=109453.msg441226#msg441226 date=1159212813]
The error's telling you the problem is with the [url=http://uk.php.net/manual/en/function.mysql-query.php]mysql_query()[/url] command.

Look a little closer at the error:
[quote]
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\cms\includes\functions.php on line 41
[/quote]

What this means is that where you have [code=php:0]mysql_fetch_array($result)[/code], $result is not a valid resource.  Implying that this didn't work properly:

[code=php:0]
return mysql_query($query, $this->link) or die(mysql_error());
[/code]

Or that it did work correctly, but the line that's calling it is not [code=php:0]$result = dbquery($query);[/code]


and last but by no means least, and possibly the cause of the problem :) you have [code=php:0]function $dbquery($query){[/code] this should probably just be [code=php:0]function dbquery($query){[/code] without the [b]$[/b] at the beginning of the function name.

Regards
Huggie
[/quote]

It's worth a try, however if that was the case,
your first error would be "Unknown function" bla bla...

However i think it could be:
function "MYSQLFETCHARRAY($query)"
Link to comment
https://forums.phpfreaks.com/topic/22017-mysql_fetch_array/#findComment-98479
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.