| Author |
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in
|
|
|
| Warning: mysql_query(): supplied argument is not a valid MySQL-Link
resource in/home/macca/public_html/somethingartistic/index.php on line
42
I am getting this message when i try to run my code on my hosts server
(using php 4) but it works fine on my own sysem (running php 5)
Example snippet:
<?php
include ("admin/config.php");
$query = "SELECT * FROM artists WHERE
category = 'Photography'";
$result = mysql_query($query, $connection);
$count = mysql_num_rows($result);
echo '<i>('.$count.' galleries)</i>';?>
Do you thisk it is the version that is causing the error or some error
of my own?
Cheers!
| |
|
| macca wrote:
> Warning: mysql_query(): supplied argument is not a valid MySQL-Link
> resource in/home/macca/public_html/somethingartistic/index.php on line
> 42
>
> I am getting this message when i try to run my code on my hosts server
> (using php 4) but it works fine on my own sysem (running php 5)
1. Is the database-connection established?
2. Does the table/field/category-value exist?
BTW: this is faster for this particular snippet:
$count = reset(mysql_query("SELECT COUNT(*) FROM artists WHERE category =
'Photography'"));
> Do you thisk it is the version that is causing the error or some error
> of my own?
In the posted snippet is nothing that would suggest a version problem. So
probably one of your own :-)
Grtz,
--
Rik Wasmus
| |
|
| Line 42 in this function is:
$result = mysql_query($query, $connection);
Surely
"not a valid MySQL-Link resource"
wouldnt mean:
cannot connect to the database would it? wouldnt it just print out
"cannot connect to database"?
all my config file has is:
<?php
$dbh=mysql_connect ("localhost", "<user>",
"<mypassword>") or die ('I cannot connect to the database because: ' .
mysql_error());
mysql_select_db ("<mydatabasename>");
return;
?>
I just noticed that the variable is $dbh and not $connection;
I changed the variable to $dbh due to the string my hosting provider
asked me to use for a database connection.
If a changed the connection variable to $dbh instead of $connection do
you think this might work?
| |
|
|
OH WHAT A STUPID MISTAKE FOR ME TO MAKE !!!!!
Somethimes you can't see the forest through the trees!
I changed the connection var and all seems well !
:-)
|
|
|
|