Jump to content

query expects paramater to be string?


turpentyne

Recommended Posts

Stumped on this. I copied the syntax of this from another site I'd done (where it works) Then I changed the query, of course.

But I'm getting an error, that I'm not sure I understand:

The page prints: 451made it to here

Warning: mysql_query() expects parameter 1 to be string, resource given in /home/workshop/public_html/register5b.php on line 20

Resource id #4

Warning: mysql_num_rows() expects parameter 1 to be resource, null given in /home/workshop/public_html/register5b.php on line 23

Query failed:

 

And the code is:

 

<?php

if ((isset($_POST['rid'])) && (is_numeric($_POST['rid']))) {
$rid = $_POST['rid'];   

   print_r($rid);
   echo "made it to here";
   // connect to database
include("x.php"); 
    
$query = mysql_query("SELECT tbl_registration.*, tbl_workshops.* 
FROM tbl_registration_workshop  
LEFT JOIN tbl_registration ON tbl_registration_workshop.workshop_id = tbl_registration.reg_id
LEFT JOIN tbl_workshops ON tbl_registration_workshop.workshop_id = tbl_workshops.workshop_id
WHERE tbl_registration_workshop.registration_id = $rid");

$result = mysql_query($query);
   echo $query;
   
    if (mysql_num_rows($result) == 1){

 while ($row = mysql_fetch_array($result)) {
   $workshop = $row['workshop_id'];  
    
?> <!-- from here on, I just print out fields from the data I pull. -->


<?php
     }
    } 


}die("Query failed: " . mysql_error());
?>

Link to comment
https://forums.phpfreaks.com/topic/257538-query-expects-paramater-to-be-string/
Share on other sites

You're executing mysql_query using the resource returned by the previous call to mysql_query instead of a query string. Remove the call to mysql_query from around your query string.

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.