Jump to content


Photo

mysql_fetch_array();


  • Please log in to reply
5 replies to this topic

#1 steelmanronald06

steelmanronald06
  • Staff Alumni
  • Advanced Member
  • 2,004 posts
  • LocationOk

Posted 25 September 2006 - 06:37 PM

Warning:

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


functions.php LINES: 30-43

<?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:  }
?>


#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 25 September 2006 - 06:53 PM

I'm not sure how I can help here....
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 steelmanronald06

steelmanronald06
  • Staff Alumni
  • Advanced Member
  • 2,004 posts
  • LocationOk

Posted 25 September 2006 - 06:56 PM

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.

#4 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 25 September 2006 - 06:59 PM

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

#5 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 25 September 2006 - 07:33 PM

The error's telling you the problem is with the mysql_query() command.

Look a little closer at the error:

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


What this means is that where you have
mysql_fetch_array($result)
, $result is not a valid resource.  Implying that this didn't work properly:

return mysql_query($query, $this->link) or die(mysql_error());

Or that it did work correctly, but the line that's calling it is not
$result = dbquery($query);


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

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#6 xyn

xyn
  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 25 September 2006 - 07:40 PM

The error's telling you the problem is with the mysql_query() command.

Look a little closer at the error:

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


What this means is that where you have
mysql_fetch_array($result)
, $result is not a valid resource.  Implying that this didn't work properly:

return mysql_query($query, $this->link) or die(mysql_error());

Or that it did work correctly, but the line that's calling it is not
$result = dbquery($query);


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

Regards
Huggie


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)"




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users