Jump to content

[SOLVED] Withdraw help


php?

Recommended Posts

The code below should take all usernames in the database and put them on a page... problem is it won't work and it comes up with these errors:

 

Parse error: syntax error, unexpected T_ECHO, expecting ',' or ';' in C:\xampp\htdocs\tests\index.php on line 15

 

<?php
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("login", $con);

$result = mysql_query("SELECT * FROM users");

while($row = mysql_fetch_array($result))
  {
  echo $row['username']
  echo "<br />";
  }

mysql_close($con);
?>

Link to comment
Share on other sites

Okay that worked.. and now

 

 

MySQL Error: No database selected

 

isn't this selecting the database?

 

mysql_select_db("username", $con);

 

That is indeed a db selection statement, but which one are we going to use? Here you say "username", above you used "login". What's the db name?

 

PhREEEk

Link to comment
Share on other sites

You can test for data being present, then dumping the data (for testing) if any records do exist:

 

<?php
if ( !$result = mysql_query("SELECT * FROM users") ) {
   die('MySQL Error: ' . mysql_error());
}
if ( mysql_num_rows($result) > 0 ) {
   while ( $row = mysql_fetch_assoc($result) ) {
       echo "<pre>";
       print_r($row);
       echo"</pre><br>";
   }
} else {
   echo "No results from query!";
}

 

PhREEEk

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.