Ducky1 Posted June 14, 2009 Share Posted June 14, 2009 Hi Guys, Trying to do a really simple script. Not sure, but i think the error is getting the user / $table variable into the query. Thanks in advance. <?php $table = $_GET['user']; $conn = mysql_connect("**", "***", "***"); if (!$conn ) { echo "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 "Invalid database name."; } $data = mysql_query("SELECT * FROM rank WHERE name = '$table'"); Print "<table border cellpadding=3>"; $info = mysql_fetch_array($data); while($info = mysql_fetch_array($data)) { echo "test"; Print "<tr>"; Print "<th>Name:</th> <td>".$info['name'] . "</td> "; Print "<th>Rank:</th> <td>".$info['rank'] . " </td>"; Print "<th>Title:</th> <td>".$info['title'] . "</td> "; } Print "</table>"; echo("End"); ?> Quote Link to comment Share on other sites More sharing options...
joel24 Posted June 14, 2009 Share Posted June 14, 2009 whats the error you are getting? was going to tell you to edit out the user/pass for your database but you've already done so, Quote Link to comment Share on other sites More sharing options...
Ducky1 Posted June 14, 2009 Author Share Posted June 14, 2009 Just realised that after posting, but changed the password for it already just in case Its just that the $data = mysql_query("SELECT * FROM rank WHERE name = '$table'"); - getting the $table into the query, and where it says echo "test", it never appears, so it must be failing somewhere Quote Link to comment Share on other sites More sharing options...
joel24 Posted June 14, 2009 Share Posted June 14, 2009 also check that your $table variable is being set... up the top put in $table = $_GET['user']; echo $table; exit(); and see what it echos. Quote Link to comment Share on other sites More sharing options...
joel24 Posted June 14, 2009 Share Posted June 14, 2009 woops sorry, didnt have a good enough look at your code you have mysql_fetch_array twice. change get rid of the $info = mysql_fetch_array($data); line so its only Print "<table border cellpadding=3>"; while($info = mysql_fetch_array($data)) Quote Link to comment 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.