Advertisement
hadesvine

php simple select from table and print result.

Jan 16th, 2012
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.51 KB | None | 0 0
  1. <?php
  2.   $con = mysql_connect("example.testdb.com:666","root","PASSWORD");
  3.   if(!$con){
  4.     die('Could not connect:'.mysql_error());
  5.   }else{
  6.     $test_sql = "SELECT foo from bar LIMIT 10";
  7.     $result = mysql_query($test_sql);
  8.     if(!result){
  9.        $message = 'Invalid Query'. mysql_error() . "\n";
  10.     $message = ' ' . mysql_error();
  11.     echo $message;
  12.        die($message);
  13.     }else{
  14.        while($row = mysql_fetch_array($result)){
  15.          echo $row['id'];
  16.          echo'</br>';
  17.        }
  18.     }
  19.   }
  20. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement