Ducky1 Posted August 6, 2009 Share Posted August 6, 2009 Hey Guys. Thanks for looking. I cant figure what on earth is wrong with the code below . It takes a user ID and password, if it's right, it sets a variable to true. This i have confirmed works fine. I also know that the "by" part of my sql table is there. Thanks. <?php $pass = $_POST['passwd']; $user = $_POST['login']; $auth = "FALSE"; $conn = mysql_connect("...", "...", "..."); if (!$conn ) { echo "ERROR: Could not connect to the database."; } $did_we_find_a_db_to_use = mysql_select_db("rovstr_peter"); if (!$did_we_find_a_db_to_use) { echo "ERROR: Invalid database name."; } echo "<b> Working... Please Wait... </b>"; $data = mysql_query("SELECT * FROM users WHERE name = '$user'"); while($info = mysql_fetch_array($data)) { if($info['pass'] == $pass) { $auth = "TRUE"; } } if($auth == "TRUE") { Echo ("Prescription table for: $user"); $data = mysql_query("SELECT * FROM medicine WHERE by = '$user'"); Print "<table border cellpadding=3>"; while($info = mysql_fetch_array($data)) { Print "<tr>"; Print "<th>Name:</th> <td>".$info['name'] . "</td> "; Print "<th>Dosage:</th> <td>".$info['dosage'] . " </td>"; Print "<th>Description:</th> <td>".$info['descr'] . "</td> "; Print "<th>When:</th> <td>".$info['time'] . "</td>"; Print "<th>Set by:</th> <td>".$info['by'] . "</td></tr>"; } Print "</table>"; } else { echo "Username/password incorrect"; } ?> Link to comment https://forums.phpfreaks.com/topic/169072-php-mysql-simple-problem/ Share on other sites More sharing options...
lynxus Posted August 6, 2009 Share Posted August 6, 2009 What error do you get? Check your webserver log files.. ie: if its linux, check in /var/log/httpd/error_log the code appears ok from a quick lookover. Link to comment https://forums.phpfreaks.com/topic/169072-php-mysql-simple-problem/#findComment-892037 Share on other sites More sharing options...
Ducky1 Posted August 6, 2009 Author Share Posted August 6, 2009 I dont get an error, i get a blank reply, even though i know the data is in the table.. i suspect the sql query? Link to comment https://forums.phpfreaks.com/topic/169072-php-mysql-simple-problem/#findComment-892066 Share on other sites More sharing options...
watsmyname Posted August 6, 2009 Share Posted August 6, 2009 I dont get an error, i get a blank reply, even though i know the data is in the table.. i suspect the sql query? execute this query in your phpmyadmin and see if mysql throws any error SELECT * FROM medicine WHERE by = '$user' //make sure to replace $user with the name Link to comment https://forums.phpfreaks.com/topic/169072-php-mysql-simple-problem/#findComment-892068 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.