Jump to content

Recommended Posts

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>

 

Link to comment
https://forums.phpfreaks.com/topic/181180-solved-trouble-with-mysql_query/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.