mysql_select_db('yumbox_table', $con) or die('Cannot make a connection'); session_start(); ini_set('session.bug_compat_warn', 0); ini_set('session.bug_compat_42', 0);
$data = mysql_query("SELECT * from users where user_name = '$user_name' AND password = '$password'") or die(mysql_error()); $row = mysql_fetch_assoc($data);
if ($row['user_type']=="Support Staff") { echo "Welcome Support Staff"; echo "</br>"; echo $row['first_name']. " "; echo $row['last_name']; echo "</br>"; echo "Here are a list of open tickets: ";
$query = mysql_query("SELECT users.id, users.email, users.first_name, users.last_name, users.user_type, users.user_name, users.password, users.problem_id, yumbox_customer_inquiry.problem_id, yumbox_customer_inquiry.customer_last_name, yumbox_customer_inquiry.customer_first_name, yumbox_customer_inquiry.customer_email, yumbox_customer_inquiry.problem_body, yumbox_customer_inquiry.category_id, yumbox_customer_inquiry.problem_status, yumbox_customer_inquiry.problem_solution from yumbox_customer_inquiry, users where users.problem_id = yumbox_customer_inquiry.category_id AND yumbox_customer_inquiry.problem_solution = ' '") or die (mysql_error()); $result = mysql_fetch_assoc($query); $support_pull = mysql_fetch_array($query) or die(mysql_error()); $_SESSION['tabledata'] = $result;
} else { echo ("I am sorry but this login is incorrect. Please try again"); }
mysql_close($con); ?>
The portions in bold are the issue. After retrieving the results from the tables listed in $query, there is suppose to be a loop (again, listed in bold) that retrieves all the relevant results and display them onscreen. However, I receive nothing. Now I know that it's not because there is nothing in the mysql table being referenced. So if anyone out there has an idea as to what is wrong, I would greatly appreciate it.
Thanks!
Last edited by Inigoesdr; 05-13-2011 at 10:46 PM..
do you receive either a PHP error or mysql error (or perhaps just a white screen), or is it just that no records are iterated? If its the latter, than you simply have no results matching that criteria. If its the former, post the error if its available, and if its a white screen use
at the top of the page to have it show you the errors (or check the error log).
Now, two things I can say: you don't need to die mysql_fetch_*. In fact I wouldn't ever do this, as its typically used for a control within a while loop, and will continue until it hits false. If you add an or die() to it, it will cause it to fail when it shouldn't.
Second, you are aware you are starting on the third (if it exists) record of the resultset correct?
You have a call to fetch_assoc which will iterate to the second record, and the a call to fetch_array which will iterate past the second to the third record. Now the fetch_array within the while loop begins on the third record, or fails to evaluate if it has no third record.
It does not display error messages, it displays no results. It should though, because the MY_SQL query statement in question lists parameters in it that should match certain data within the two tables listed.
It does not display error messages, it displays no results. It should though, because the MY_SQL query statement in question lists parameters in it that should match certain data within the two tables listed.
Then there is no problem here. The problem is your query data, not a problem with PHP. Just because a table has columns you are requesting does not mean that it matches your definition of a where clause.
Also mentioned, you are starting on the third record, but you did not touch base on that in your last reply.
Copy the created query by printing it out before processing it and pasting it into querybrowser or cli mysql connection. I'm betting you have less than 3 record (which may or may not be zero).