dbsheajr Posted November 11, 2009 Share Posted November 11, 2009 Hello, My band just purchased Web hosting from Netfirms that is running phpMyAdmin 2.4.0 and MySQL 5.0.77. I have another Web site from Netfirms that runs the same services, but I cannot get my PHP/MySQL code to work on my band’s site. Every time I use the mysql_query statement, I get the following error: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /mnt/w0701/d49/s37/b0312b06/www/knucklesdeepband.com/wip/test.php on line 32 Unable to complete query: [] As you will see in my code, I have created a custom error statement, but on this particular error I receive neither the error number nor the error statement code. The following code is a test file that has no real purpose as a Web page, I just created this file because I know the error is in the mysql_query line and I to get rid of everything else. Thanks, Dennis Shea dennis@knucklesdeepband.com <?php //determine if they need to see the form or not if (!$_POST) { //they need to see the form, so create form block $display_block = " <form name=\"testing_form\" method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\"> <p> <input type=\"submit\" name=\"submit\" value=\"Run Test Query\" /> </p> </form>"; } else { //set up a couple of functions function doDB() { global $link; //connect to server $hostname = "myhost"; $username = "myusername"; $password = "mypassword"; $link = mysql_connect($hostname, $username, $password) or die("Unable to connect to server: [".mysql_errno()."] ".mysql_error()); //connect to database $dbid = "mydatabase"; mysql_select_db($dbid) or die ("Unable to connect to database: [".mysql_errno()."] ".mysql_error()); } //sample query to check syntax, etc. $test_sql = "INSERT INTO `forum_topics` (`topic_title`, `topic_create_time`, `topic_owner`) VALUES ('PHP/MySQL syntax check', now(), 'dennis@knucklesdeepband.com')"; $test_res = mysql_query($test_sql, $link) or die("Unable to complete query: [".mysql_errno()."] ".mysql_error()); //close connection to MySQL mysql_close($link); } ?> <?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Test</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <?php echo "$display_block"; ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/181180-solved-trouble-with-mysql_query/ Share on other sites More sharing options...
mattal999 Posted November 11, 2009 Share Posted November 11, 2009 You don't call the doDB() function. You only define it. Quote Link to comment https://forums.phpfreaks.com/topic/181180-solved-trouble-with-mysql_query/#findComment-955856 Share on other sites More sharing options...
Maq Posted November 11, 2009 Share Posted November 11, 2009 dbsheajr, when posting code please surround your code with tags. Quote Link to comment https://forums.phpfreaks.com/topic/181180-solved-trouble-with-mysql_query/#findComment-955858 Share on other sites More sharing options...
dbsheajr Posted November 11, 2009 Author Share Posted November 11, 2009 Thanks, I have when I miss a mundate detail like that. Thanks for your help & quick reply. DS Quote Link to comment https://forums.phpfreaks.com/topic/181180-solved-trouble-with-mysql_query/#findComment-955862 Share on other sites More sharing options...
Maq Posted November 11, 2009 Share Posted November 11, 2009 Hi dbsheajr, If your topic is solved please mark as so by clicking the bottom left tab [sOLVED]. I know you're new to the forums, so welcome . Quote Link to comment https://forums.phpfreaks.com/topic/181180-solved-trouble-with-mysql_query/#findComment-955864 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.