turpentyne Posted February 22, 2012 Share Posted February 22, 2012 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()); ?> Quote Link to comment https://forums.phpfreaks.com/topic/257538-query-expects-paramater-to-be-string/ Share on other sites More sharing options...
scootstah Posted February 22, 2012 Share Posted February 22, 2012 You are calling mysql_query() twice. Quote Link to comment https://forums.phpfreaks.com/topic/257538-query-expects-paramater-to-be-string/#findComment-1320037 Share on other sites More sharing options...
Pikachu2000 Posted February 22, 2012 Share Posted February 22, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/257538-query-expects-paramater-to-be-string/#findComment-1320038 Share on other sites More sharing options...
turpentyne Posted February 22, 2012 Author Share Posted February 22, 2012 Yep... Just now realized that's what I was doing... Problem solved. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/257538-query-expects-paramater-to-be-string/#findComment-1320043 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.