mikey1090
07-30-2006, 07:24 AM
my friend has recently moved server. His new server is pretty much the same. He connects to the mysql fine, and gets the message "connection OK" from his database file.
The problem is, none of his mysql queries ork any more......
Can anyone help??
mysql_query($query) or die(mysql_error());
then google the error
mikey1090
07-30-2006, 09:42 AM
mysql_query(): supplied argument is not a valid MySQL-Link resource in path/to/file.php
that is the error......
horizon
07-30-2006, 09:57 AM
It would be best if you would post your peace of codes in order to assist you in a better way. ;)
globaltap
07-30-2006, 10:03 AM
Try to connect using this basic example. This will tell you if the mysql link is created or not:
<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>
horizon
07-30-2006, 10:16 AM
Looks more like you're trying to accomplish this:
<?php
$link = @mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
} else {
echo 'Connected successfully';
$get_database = @mysql_select_db('mysql_database_name_here', $link);
if ($get_database) {
echo 'Database gathered successfully.';
} else {
die ('Failed to gather database name');
}
}
@mysql_close($link);
?>
mikey1090
07-30-2006, 01:48 PM
ok, it did not gather the database name, "Connected successfullyFailed to gather database name" was the message i got.....what now?
globaltap
07-30-2006, 01:51 PM
I would use phpMyAdmin or mysql client from the console to verify the existence of the database you are trying to access. Make sure that the database exists and that you do not have any spelling errors. I would also check to make sure that the user you are connecting with has select permissions on the database you want to access.
berol
07-30-2006, 02:03 PM
hi i am mikeys friend and basicly it now displays the message "Connected successfully
Database gathered successfully." so it is connected well but i am still getting these errors can someone please help me?
lutan
07-30-2006, 02:34 PM
Did you mysql_close(..) anywhere before trying mysql_query(..)? I mean if you have accidentally closed mysql connection.
berol
07-30-2006, 02:35 PM
no i took the mysql_close part out
horizon
07-30-2006, 03:16 PM
Leave everything as is, from my posted above, for this tryout. Simply go to your cPanel's mySQL database page and check the name of the created database it shows.
Then, put that name under the @mysql_select_db line (as a replacement of the first apposition). This should connect just nicely.
From there, once the connection is successful + gathers the database name correctly, you can proceed further to execute more queries within these functions. ;)