mysql_query() expects parameter 2 to be resource, object given in...
Warning: mysql_query() expects parameter 2 to be resource, object given in C:\xampp\htdocs\search.php on line 15
I get this error message whenever I try to
This is my code
$db = 'htdocs\as4.mdb';
$conn = new COM('ADODB.Connection');
$search = $_POST['search'];
$sql = "SELECT * FROM vendor WHERE vendorName like '%search%' OR
address like '%search%' or
city like '%search%' or
provState like '%search%' or
country like '%search%'";
$result = mysql_query($sql, $db) or die (mysql_error());
$number = mysql_num_rows($result);
// <h3>$number of results found search for "$search"</h3>
while($row = mysql_fetch_array($result))
$vendorName = $row['vendorName'];
$address = $row['address'];
$city = $row['city'];
$provState = $row['provState'];
$country = $row['country'];
It maybe something small, but at the moment I can't seem to figure out what it is. Any help?
You start out the script using COM to make an ADODB connection, but then try to use MySQL functions to do a database query. If it's a MySQL database, then you would use mysql_connect() to connect to it. If you want/need to use a COM object, then you would use COM functions to query it, but mixing the two is probably not ever going to work.
Ok I see. I'm trying to search the query, but I want to use it with the COMM function what can I do to make that happen? The example I have was one of the many ways I saw online except for the COMM part which I added in to connect the database.
I've never used the COM stuff, so don't really know my way around it. Example #2 on this page shows some possibly useful stuff.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)