WeExClan Posted May 24, 2010 Share Posted May 24, 2010 How can i see tables and stuff directly on my website, i want to make like a members list and when they register i want to see user name and the name table.. From THE MYSQL caps Quote Link to comment Share on other sites More sharing options...
F1Fan Posted May 24, 2010 Share Posted May 24, 2010 Like phpMySQLAdmin? http://www.phpmyadmin.net/home_page/index.php Quote Link to comment Share on other sites More sharing options...
WeExClan Posted May 24, 2010 Author Share Posted May 24, 2010 No, i mean like. I have a "Members" list on my website. And when they register i want their names to be in a list automaticly on my website. Their name and their playstation network name... Quote Link to comment Share on other sites More sharing options...
F1Fan Posted May 24, 2010 Share Posted May 24, 2010 So you just want a PHP page that gets a list from a table in MySQL and displays it for you? If so, you've posted in the wrong place, as that would be PHP and MySQL, not just HTML. Start with a simple PHP/MySQL tutorial like this one: http://www.w3schools.com/php/php_mysql_select.asp Quote Link to comment Share on other sites More sharing options...
WeExClan Posted May 24, 2010 Author Share Posted May 24, 2010 I try that and i get a error about this: while($row = mysql_fetch_array($result)) Quote Link to comment Share on other sites More sharing options...
F1Fan Posted May 24, 2010 Share Posted May 24, 2010 When you try what? What error? Please post the rest of your code. There probably isn't a problem with that line, it's just that's the first time that PHP sees a problem. Quote Link to comment Share on other sites More sharing options...
WeExClan Posted May 24, 2010 Author Share Posted May 24, 2010 Here is the error in the browser: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /~/www/****.tk/members/index.php on line 18 **** = I'm hiding whats really there... Here is the script: <?php $con = mysql_connect("***","***","****"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_db", $con); $result = mysql_query("SELECT * FROM Members"); echo "<table border='1'> <tr> <th>PSN Navn</th> <th>Navn</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['login'] . "</td>"; echo "<td>" . $row['FirstName'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> Quote Link to comment Share on other sites More sharing options...
F1Fan Posted May 24, 2010 Share Posted May 24, 2010 Possibly the DB select. Try this (also, please post code in the code tags, as it makes it far easier to read): $db_con = mysql_select_db("my_db", $con); if (!$db_con) { die('Could not connect to "my_db": ' . mysql_error()); } Quote Link to comment Share on other sites More sharing options...
WeExClan Posted May 24, 2010 Author Share Posted May 24, 2010 Ok, when i added your thingy it said some could not connect thing but i fixed it and now its the same as it was... This is the code now: <?php $con = mysql_connect("****","****","****"); if (!$con) { die('Could not connect: ' . mysql_error()); } $db_con = mysql_select_db("****", $con); if (!$db_con) { die('Could not connect to "****": ' . mysql_error()); } $result = mysql_query("SELECT * FROM Members"); echo "<table border='1'> <tr> <th>PSN Navn</th> <th>Navn</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['login'] . "</td>"; echo "<td>" . $row['FirstName'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> The error is still: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /~/www/****.tk/members/index.php on line 22 Quote Link to comment Share on other sites More sharing options...
F1Fan Posted May 24, 2010 Share Posted May 24, 2010 Hmm. Try adding the connection object to the select: $result = mysql_query("SELECT * FROM Members", $con); Quote Link to comment Share on other sites More sharing options...
WeExClan Posted May 24, 2010 Author Share Posted May 24, 2010 Its still the same error... :-\ Quote Link to comment Share on other sites More sharing options...
F1Fan Posted May 24, 2010 Share Posted May 24, 2010 I assume that there is a "Members" table in the database that you're connecting to? Have you tried running that query manually using phpMySQLAdmin, or any other SQL tool, using the same connection parameters that you're using on this page? Quote Link to comment Share on other sites More sharing options...
WeExClan Posted May 24, 2010 Author Share Posted May 24, 2010 Sorry, i didnt understand that but i can connect to it with the same info on the registration/login form... And yes, i'm using phpmyadmin Quote Link to comment Share on other sites More sharing options...
WeExClan Posted May 24, 2010 Author Share Posted May 24, 2010 OH, sorry. I had to take away caps, Members to members and FirstName to firstname. Thanks for the help.. Quote Link to comment Share on other sites More sharing options...
xcoderx Posted May 24, 2010 Share Posted May 24, 2010 this isnt php or sql help section. staff should move this topic. ask this in php help section it will be solved :-) 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.