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
https://forums.phpfreaks.com/topic/83944-solved-withdraw-help/
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
https://forums.phpfreaks.com/topic/83944-solved-withdraw-help/#findComment-427186
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
https://forums.phpfreaks.com/topic/83944-solved-withdraw-help/#findComment-427193
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.