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
https://forums.phpfreaks.com/topic/215537-strange-mysqlphp-error/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.