Jump to content

Archived

This topic is now archived and is closed to further replies.

steelmanronald06

mysql_fetch_array();

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]

Share this post


Link to post
Share on other sites
I'm not sure how I can help here....

Share this post


Link to post
Share on other sites
I can move it to PHP help, but since it is dealing with mysql I was just wondering where it should go :) ha ha ha!  I mean it is a bit of both, but since there is alot of OOP I will move it to php.

Share this post


Link to post
Share on other sites
Usually that means a problem with your sql statement. Either wrong field name or misspelled name. Echo out your statement and see what it says

Ray

Share this post


Link to post
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

Share this post


Link to post
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)"

Share this post


Link to post
Share on other sites

×

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.