User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 403,367 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,336 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1422 | Replies: 7
Reply
Join Date: Feb 2008
Posts: 2
Reputation: SofiaMaria is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
SofiaMaria SofiaMaria is offline Offline
Newbie Poster

Help Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home

  #1  
Feb 29th, 2008
Hi there,

I am new to Php and MySql.

However, i have been learning for some time now.

I get the above error and my line 77 has the following statement:
$result=mysql_query($query,$conn);

Any ideas? If you need more of the code please let me know.

Thanks a lot,

Sofia
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 239
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home

  #2  
Feb 29th, 2008
You have an error in your query. It isn't returning a valid resource. Print out $query, execute it in phpmyadmin/mysql. Then you ll know what's the error. You can also give die(mysql_error());
ie., $result=mysql_query($query,$conn) or die(mysql_error());
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Feb 2008
Posts: 2
Reputation: SofiaMaria is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
SofiaMaria SofiaMaria is offline Offline
Newbie Poster

Re: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /

  #3  
Feb 29th, 2008
Originally Posted by nav33n View Post
You have an error in your query. It isn't returning a valid resource. Print out $query, execute it in phpmyadmin/mysql. Then you ll know what's the error. You can also give die(mysql_error());
ie., $result=mysql_query($query,$conn) or die(mysql_error());

Hi, I have found that error now. i called the $conn in the included file $connection.

I feel rather daft now, but at least i have a different error to play with now :o)

Thanks for the rapid response
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 239
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home

  #4  
Feb 29th, 2008
You are welcome!
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Mar 2008
Posts: 2
Reputation: regreta is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
regreta regreta is offline Offline
Newbie Poster

Re: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /

  #5  
Mar 28th, 2008
Hi nav33n,

coul you please help me.. im trying to display quiz questions from database but i get an the same error as desribed above . please see my code

the error points to line 3 and 7.

1 <?php

2 include("contentdb.php");

3 $display = mysql_query("SELECT * FROM $table ORDER BY id",$db);

4 if (!$submit) {


echo "<form method=post action=$PHP_SELF>";
echo "<table border=0>";

7 while ($row = mysql_fetch_array($display)) {


Please please please... i desperately need your help.

Thank in advance
Last edited by regreta : Mar 28th, 2008 at 5:26 am.
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 239
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home

  #6  
Mar 28th, 2008
3 $display = mysql_query("SELECT * FROM $table ORDER BY id",$db);
Select * from $table ? What does $table have ? It must be empty.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Mar 2008
Posts: 2
Reputation: regreta is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
regreta regreta is offline Offline
Newbie Poster

Re: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home

  #7  
Mar 28th, 2008
my table is defined in config. file

<?
$database = "quiz";
$hostname = "localhost";
$table = "quiz";
?>
as you see table is called quiz and it has data in it.

Shall I recall
$display = mysql_query("SELECT * FROM $table ORDER BY id",$db);

to

$display = mysql_query("SELECT * FROM $quiz ORDER BY id",$db); ???

thanks
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 239
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home

  #8  
Mar 28th, 2008
Nope. Just print out the query. ie., instead of
$display = mysql_query("SELECT * FROM $table ORDER BY id",$db);
do,
  1. $query="SELECT * FROM $table ORDER BY id";
  2. echo $query;
  3. $display = mysql_query($query,$db);
Execute your query in phpmyadmin/mysql console and see what's the problem. Or, you can also try putting die statement after mysql_query to see the error.
  1. $display = mysql_query($query,$db) or die(mysql_error());
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 9:02 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC