Jump to content

Strange MySQL/PHP Error


pathachiever11

Recommended Posts

Hi. I recently had to implement a database search to my client’s website. I am new to MySQL and PHP, because I’ve usually dealt with ASP.Net.

 

I am getting the following error:

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/*****/public_html/***/mysql.php on line 69

 

To connect, I am using the following code and it seems to work fine, no error.

$dbhost = 'localhost:3306';
$dbuser = 'DBUSER';
$dbpass = 'DBPASS';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die (mysql_error());
if (!$conn)
  {
  die('Could not connect: ' . mysql_error());
  }
  $conId = $conn;
$dbname = 'tulipus1_products';
mysql_select_db($dbname) or die (mysql_error());

 

 

To search I am using the following code (on mysql_query, the error occurs):

$query = ‘SOME SEARCH QUERY’;
$this->result=mysql_query("SELECT * FROM products where Description LIKE '%$query%'",$this->conId) or die(mysql_error());
return new Result($this,$this->result) or die(mysql_error());

 

This is not the full code, but the summary of all the code that has been used so far.

 

I have done a lot of research on the error and tried many things, but it doesn’t make sense to me.  I have tried the same query on phpMyAdmin and it worked fine.

 

Please Help.

Thanks in advance!

 

Link to comment
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.