GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 27-Jan-2005, 15:39
phpnewbie phpnewbie is offline
New Member
 
Join Date: Jan 2005
Posts: 10
phpnewbie is on a distinguished road

Not a Valid MySQL result


I am now getting the error:

mysql_fetch_row(): supplied argument is not a valid MySQL result resource on line 11

Warning: Cannot add header information - headers already sent by (output started at ....php:11) on line 40

I have researched many options i.e. mysql_fetch_array, etc. but I am against a wall. This same code is running on a different server, without fail, and they are exactly alike (at least on the surface, because one works and the other.... The permissions/properties for mysql are the same on both systems, but .... Here is the code for lines 9 thru 20 any suggestions? Remember I am very new, and I have ordered several manuals on this subject. Thank You.

PHP Code:

$result=mysql("$DBName","SELECT CartItemsID,Date FROM CartItems");
//line 11 is the next line
while ($row=mysql_fetch_row ($result))
{
$CII=$row[0];
$CDa=$row[1];
$pieces=explode(":",$CDa);
$DCHK=$pieces[1];
if ($DCHK < $old) {
mysql("$DBName","DELETE FROM CartItems WHERE CartItemsID = '$CII'");
    }
} 


  #2  
Old 27-Jan-2005, 16:50
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
Now I am glad I didn't post a reply in that other thread. It's the same question isn't it?

Anyway, you're right in starting a new thread, this has nothing to do with your problem earlier.

I can't tell what's wrong with your code because it seems like your SQL statement is the one that's causing the error. Either the table "CartItems" or (column names) don't exist or the names are mis-spelled.

Since you are using what seems to be a custom function for your db queries i.e. mysql(), you'd have to find a way to make it show you the errors, if any.
  #3  
Old 28-Jan-2005, 03:05
besttoolbars
 
Posts: n/a
It seems like your query is not working properly. A code of your mysql() function could be a help
  #4  
Old 28-Jan-2005, 14:56
phpnewbie phpnewbie is offline
New Member
 
Join Date: Jan 2005
Posts: 10
phpnewbie is on a distinguished road
It is the same question, but I thought a new thread was needed as well. I appreciate you assistance, I am looking at the database, And it seems the Table & column names are present and spelled correct i.e. correct case etc... so now I am looking at possible version conflicts... ??: I postedd the version conflict in a different thread.


Quote:
Originally Posted by JdS
Now I am glad I didn't post a reply in that other thread. It's the same question isn't it?

Anyway, you're right in starting a new thread, this has nothing to do with your problem earlier.

I can't tell what's wrong with your code because it seems like your SQL statement is the one that's causing the error. Either the table "CartItems" or (column names) don't exist or the names are mis-spelled.

Since you are using what seems to be a custom function for your db queries i.e. mysql(), you'd have to find a way to make it show you the errors, if any.
  #5  
Old 28-Jan-2005, 15:17
firebird's Avatar
firebird firebird is offline
New Member
 
Join Date: Jan 2005
Posts: 11
firebird is on a distinguished road
I don't believe a php 'version conflict' could result in this behaviour.
Does $DBName contain the value of a database that 1) exists and 2) your script is connected to? And it does seem the error is in your SQL query. Since you moved servers, is it possible that the database is not configured correctled, even though you just checked?
Try running the "SELECT CartItemsID,Date FROM CartItems" query in PhpMyAdmin, or whatever 3dParty you're using (if any).
  #6  
Old 28-Jan-2005, 16:29
CB2k3 CB2k3 is offline
New Member
 
Join Date: Jan 2005
Posts: 1
CB2k3 is on a distinguished road
i guess in your mysql(...)-function you call the mysql_query(...)-function.

if the table is empty the query-function doesn't return a valid mysql-resource. it returns false;

therefore $result contains false, but mysql_fetch_row(...) expects a valid resource, otherwise it generates an error.

and that's it. you have to check $result. if it contains a valid mysql-resource you can call mysql_fetch_row(...), but if the variable contains false you couldn't call this function^^.
  #7  
Old 03-Feb-2005, 13:58
phpnewbie phpnewbie is offline
New Member
 
Join Date: Jan 2005
Posts: 10
phpnewbie is on a distinguished road
Quote:
Originally Posted by Dave
I don't believe a php 'version conflict' could result in this behaviour.
Does $DBName contain the value of a database that 1) exists and 2) your script is connected to? And it does seem the error is in your SQL query. Since you moved servers, is it possible that the database is not configured correctled, even though you just checked?
Try running the "SELECT CartItemsID,Date FROM CartItems" query in PhpMyAdmin, or whatever 3dParty you're using (if any).


I was able to run "SELECT CartItemsID,Date FROM CartItems" query in PhpMyAdmin with no problem. The DBname is correct as are the col. names (no mis-spells) however when I run the file, I am still getting:

"Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /var/www/html/Cart/index.php on line 11"

and I just don't see it... Line 11 has not changed, it must be something very simple.
  #8  
Old 18-Feb-2005, 12:04
phpnewbie phpnewbie is offline
New Member
 
Join Date: Jan 2005
Posts: 10
phpnewbie is on a distinguished road

More error information


I have tried several different things and finally put the following in my code, just above the line that give the error:
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in

<php>
if ($row = mysql_fetch_row($res)) {
return $row;
} else {
print (mysql_error());
}
break;;
</php>

and I think a more descriptive error displayed:

access denied for user:'@localhost" to database 'classes'

which is the database I want to access. I understand, I think that this is a permissions error, but an error whom?? (remember I'm very new to this.) I have also noticed this php script requires a different page, the one that has all of the database information, the host, the username, password, and database name.
  #9  
Old 19-Feb-2005, 07:45
firebird's Avatar
firebird firebird is offline
New Member
 
Join Date: Jan 2005
Posts: 11
firebird is on a distinguished road
I've never had to add '@localhost' to any of my users.

PHP Code:

$db = mysql_connect ("localhost", "firebird", "12345") or die(mysql_error());
mysql_select_db ("sitedb", $db); 



The 'database' format differs per host. For example, in my scripts I use 'mydomain_dbname'.
But that's something different, I reckon. Try the user without the @localhost add-on.
  #10  
Old 22-Feb-2005, 21:23
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
Quote:
Originally Posted by phpnewbie
... access denied for user:'@localhost" to database 'classes'

which is the database I want to access. I understand, I think that this is a permissions error, but an error whom?? (remember I'm very new to this.) I have also noticed this php script requires a different page, the one that has all of the database information, the host, the username, password, and database name.

Sorry I am late with my reply phpnewbie.

When it reports an error like access denied for user:'@localhost", it simply means that the username was not set when connecting to the database server.

Your hunch is right, it might simply be an issue with the "include page" not being included after all.
 
 

Recent GIDBlogToyota - 2008 July Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
fltk-2.0 cvs Plumb FLTK Forum 20 13-Nov-2004 07:10
Starting Mysql server problem pjacks MySQL / PHP Forum 23 08-Sep-2004 17:23
PHP, MySQL, WML skyloon MySQL / PHP Forum 0 05-Mar-2004 07:53
Windows: From only £20p/y,Linux: from $10p/m. ASP, ASP.NET, PHP, Free MySQL, +More EyotaHosts Web Hosting Advertisements & Offers 0 28-Jun-2003 13:54
MySQL Adds Subselects, Upgrades Performance and Security JdS MySQL / PHP Forum 4 22-Jan-2003 17:42

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 01:56.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.