Jump to content
Sign in to follow this  
e4games

User List Error

Recommended Posts

I can't find a error with this code...can you guys help me?

<?phpmysql_connect("Host Name", "username", "pass") or die(mysql_error()); mysql_select_db("DB name") or die(mysql_error()); $query=mysql_query ("SELECT * FROM users");echo "<tr><td colspan='2' bgcolor='darkyellow'>.::. Users .::.</td><tr/><tr><td colspan='2'>";while "($row = mysql_query ($query) ) ";{echo "<tr><td> {$row['ID']}";echo "</td></tr>";echo "<tr><td> {$row['username']}";echo "</td></tr>";}echo "</table>"";?>

The code is supposed to output a users ID and name inside of a table...but a white screen just happens D:

Edited by e4games

Share this post


Link to post
Share on other sites

PHP is trying to understand this part as PHP, and it doesn't work: <tr><td colspan='2'>When you interpolate array elements inside double quotation marks, they should be wrapped in braces, like this:echo "<tr><td> {$row['ID']}";All PHP statements must end with a semicolon ( ; ). If the semicolon is inside quotation marks, it is part of the string and does not terminate the statement.This will never work:while "($row = mysql_query ($query) );"No offense, but this is pretty basic stuff. PLEASE do some homework. We are here to help you, not teach you stuff you can learn in chapter 1 of any basic tutorial or book.

Edited by Deirdre's Dad

Share this post


Link to post
Share on other sites

I changed the code at the top...and it still gets the same error D: I also tried it with the semicolons only after the lines with the curly braces it them, but it still gets the same errorAnd it says no where that you need to put curly braces around PHP with HTML with it, especially not at the beginning of anything

Edited by e4games

Share this post


Link to post
Share on other sites

Post your revised code. No one can guess what it looks like now.

it says no where that you need to put curly braces around PHP with HTML with it
That is not what I was discussing. If you don't understand, please say you don't understand. There is no need to get defensive.And what is this "nowhere" you're talking about? This site is great for HTML, but it barely scratches the surface of PHP. Use it as a starting point, but don't imagine everything you need to know about PHP can be found in the tutorials here. Edited by Deirdre's Dad

Share this post


Link to post
Share on other sites
my revised code is on the first post...I editted it..like I said in my post.
Sorry. I thought you meant something different by "at the top." It is not customary on this board to post revised code into earlier entries.Remove the quotation marks and the semicolon from this line:while "($row = mysql_query ($query) ) ";I deliberately didn't tell you everything that was wrong with it because I hoped you wanted to be part of this process and might look at it closely yourself. Edited by Deirdre's Dad

Share this post


Link to post
Share on other sites

You still have useless quotation marks around your while() condition.

Share this post


Link to post
Share on other sites

You also have too many here:echo "</table>"";If you're seeing a blank page, that means you have error messages disabled on your server. It would be a good idea to enable error messages while you're developing.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...