473,761 Members | 5,163 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to fix: "Warning: mysql_fetch_ass oc(): supplied argument is not a valid . . "?

wilsonh
6 New Member
Hi

I am aware that this is a common problem as I have scoured the internet endlessly looking for a solution.

The script was installed and set up for me because I am a complete beginner so unfortunately I have made little sense of some of the solutions that have been posted.

I have looked into it and now have some understanding of what the code should be doing or what it is trying to do.


The error is

"Warning: mysql_fetch_ass oc(): supplied argument is not a valid MySQL result resource in /path/to/file/index.php on line 213"

Line 213 is....

Expand|Select|Wrap|Line Numbers
  1. while($row = mysql_fetch_assoc($rs)) {
  2.  
This is strange because this script originally worked absolutely fine until I tried uploading a new design for the index page (with the original php code re-inserted).
I have even uploaded the original files (but left the db intact) and the error still occurs.

I spoke to a friend of mine and he mentioned something about the variable being returned as false and I need to perform some type of operation on the database maybe.

Do you have any suggestions on what I need to do?

This is the code that connects to the db...

Expand|Select|Wrap|Line Numbers
  1. $conn = mysql_connect($hostname,$username,$password) or die("Having problem connecting to database");
  2.     mysql_select_db($dbname,$conn);
I can also provide the full code by request.

Thanks in advance

Will
Dec 1 '10 #1
10 3114
Dormilich
8,658 Recognized Expert Moderator Expert
the problem likely arises in a mysql_query() call. die with an error message there.
Expand|Select|Wrap|Line Numbers
  1. $res = mysql_query($sql) or die("Error in $sql: " . mysql_error());
Dec 2 '10 #2
wilsonh
6 New Member
Thanks for your reply Dormilich but I am still unclear as to what I need to do
Dec 2 '10 #3
Dormilich
8,658 Recognized Expert Moderator Expert
try the following. go to line #213 in index.php, look for mysql_query() that is called before that, insert/append the code from post#2, post result here.
Dec 2 '10 #4
wilsonh
6 New Member
There is no mysql_query that I can see.
I added your code just before line 213. This has removed the original error message but it now displays....

"Error in select name,expiration ,ext from domains where 1=1: Lost connection to MySQL server during query"

Is there anyway I can show you the whole code of index.php?
There are about 250 lines of code which are too many to post here.
Dec 2 '10 #5
Dormilich
8,658 Recognized Expert Moderator Expert
you can put it in a zip file and attach it. post the zip file’s checksum too (sha1 preferred)
Dec 2 '10 #6
wilsonh
6 New Member
Thanks Dormilich, I have attached the files as requested.
There are 2 other files included in the zip (files linked to the index which may be of some help).
Attached Files
File Type: zip wilsonh.zip (5.8 KB, 94 views)
File Type: txt checksum.txt (40 Bytes, 293 views)
Dec 2 '10 #7
Dormilich
8,658 Recognized Expert Moderator Expert
the problem here is improper class design.

the method PS_Pagination->paginate() (ps_pagination. php:60) does not return a consistent result. if the query succeeds, it returns a resource, if the query fails (what is happening here) it returns false (just like mysql_query()). therefore as immediate fix you have to check the $rs variable (index.php:191) before using it (index.php:213) .

if you’re running PHP 5, I recommend a different pagination class (this code is for PHP 4). in PHP 5 there are enough mechanisms available to avoid those problems, but coding all those in the current code would be a waste of effort. IMO, this class’ code needs a complete rewrite.
Dec 2 '10 #8
wilsonh
6 New Member
Thanks for having a look, I really appreciate it!

Can you tell me how I would check the $rs variable?

Also, for a re-write is this a big job that I would need to pay somebody to do or could I find the code online?

Sorry to keep asking questions, I am a complete beginner with php and mysql
Dec 2 '10 #9
Dormilich
8,658 Recognized Expert Moderator Expert
check the variable:
Expand|Select|Wrap|Line Numbers
  1. // PHP 5
  2. if (!$rs) 
  3. {
  4.     throw new RuntimeException("The Query failed.");
  5. }
this requires your code wrapped in a try … catch block. (cf. Exceptions)

rewrite, first you should search the net for other pagination classes. chances are that you’ll find something suitable. esp. pay attention to error handling.

the only thing I could offer you is a solid database handling system for PHP 5 …
Dec 2 '10 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

6
4673
by: aa | last post by:
I use the following fragment of code to output datf from MySQL: ====================================================== $chan = mysql_connect ($db_host, $username, $password); mysql_select_db ($DB_name, $chan); $resultid = mysql_query ("select name_ru, description_ru, retail, dealer from lasershot WHERE le='1'", $chan); ........ ======================================================
4
7836
by: Ryanlawrence1 | last post by:
Heya, I get these 2 errors: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/themepar/public_html/changepass.php on line 20 You have not entered all the fields Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/themepar/public_html/changepass.php on line 34 Sorry You failed to enter the correct old password I was wondering if anyone could help me, I have...
2
16932
by: techjohnny | last post by:
Error: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/jplane/certcent/phpweb/quiz/index.php on line 20 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/jplane/certcent/phpweb/quiz/index.php on line 21 PHP CODE:
11
3605
by: Breana | last post by:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/breana/public_html/category.php on line 88 ------------------------------------------- It does this when there is no result "empty table" how can i do a quick fix to say No Results... row 88: if ($myrow = mysql_fetch_array($result)) { do { if ($rowcolor == 1) {
6
2018
by: Tinker | last post by:
hi i am having a problem i can figure out can some one please tell me how to fix this PHP Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /hermes/ i took out the names here showed my log in info /htdocs/includes/sql_layer.php on line 237
4
1734
by: simon2x1 | last post by:
how can i fix these error and what does it mean Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\test_php\log\search\result.php on line 8 <?php @mysql_connect('localhost','user2','point')or die('could not connect'); @mysql_select_db('files') or die('could not select database');
2
2199
by: perhapscwk | last post by:
When I run my site from localhost, no error, but when I move it to webhosting, it show below error, why? Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/asi50080/public_html/onlineadv/category.php on line 143 Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/asi50080/public_html/onlineadv/category.php on line 155
0
5622
Atli
by: Atli | last post by:
What to discuss: What is a "MySQL resource". What causes the error. How to fix it. Common Newbie Pitfalls This article is the second installment in a series of (hopefully) many, following Markus' first installment: 1: Headers Already Sent.
1
1934
by: kmacc | last post by:
Hi, I'm getting this error on a page after changing server host, the error did not happen on my old host. I'm thinking it is to do with a new MySQL version and more strict coding. Can anyone help? Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/xxxx/public_html/propview.php on line 78 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in...
0
10111
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9948
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8770
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6603
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5364
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3866
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3446
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2738
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.