pathachiever11 Posted October 10, 2010 Share Posted October 10, 2010 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! Quote Link to comment https://forums.phpfreaks.com/topic/215537-strange-mysqlphp-error/ Share on other sites More sharing options...
fenway Posted October 10, 2010 Share Posted October 10, 2010 Then you're not getting your die() properly -- drop all that OO stuff until you can get an error to be thrown. Quote Link to comment https://forums.phpfreaks.com/topic/215537-strange-mysqlphp-error/#findComment-1120800 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.