Jump to content

mysql_fetch_array() expects parameter 1 to be resource, PLEASE HELP....


Recommended Posts

THIS IS MY CODE:

"<?php

mysql_select_db("service", $db_handle);

 

$result = mysql_query("SELECT tp_id, email, Rating FROM tp_info WHERE tp_id.tp_info=user_skills.tp_info HAVING user_skills.sub_id=job_info.sub_id");

 

echo "<table border='1'>

<tr>

<th>Tradesperson Username</th>

<th>Tradesperson Email</th>

<th>Rating</th>

</tr>";

 

while($row = mysql_fetch_array($result))//ERROR LINE HERE

  {

  echo "<tr>";

  echo "<td>" . $row['tp_id'] . "</td>";

  echo "<td>" . $row['email'] . "</td>";

  echo "<td>" . $row['Rating'] . "</td>";

 

  echo "</tr>";

  }

echo "</table>";

 

?>

 

 

 

WHA SHOULD I DO TO SORT THIS OUT???

Have you tested your query in MySQL?

If not you could try:

SELECT tp_id, email, Rating FROM tp_info INNER JOIN user_skills ON (tp_id.tp_info=user_skills.tp_info) WHERE user_skills.sub_id = job_info.sub_id

Your use of HAVING is a bit off, it should only be used to limit a GROUP BY, not to refine an existing WHERE clause. Let us know how you get on.

The Table Structure is something like this:

Table Name        Field Name1          Field Name2        Field Name3      Field Name4

==============================================================

tp_info                tp_id                      Rating                email                  field4

user_skills          tp_id                      sub_id

job_info              sub_id

===============================================

I want to print tp_id,Rating,email from table-tp_info for only those tp_id that match tp_id from table-user_skills. Provided sub_id from table-user-skills match sub_info from table-job_info

 

What should my query be like????

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.