Guest User

Untitled

a guest
Oct 18th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.09 KB | None | 0 0
  1. <?php
  2.    
  3.     session_start();
  4.     error_reporting(-1);ini_set('display_errors', 1);
  5.     $myServer = "mysql8.000webhost.com";
  6.     $myUser = "a1761169_chat";
  7.     $myPass = "site123";
  8.     $myDB = "a1761169_chat";
  9.     //Connection to the database
  10.     $dbhandle = mysql_connect($myServer, $myUser, $myPass)
  11.     or die("Couldn't connect to SQL Server on $myServer");
  12.     //Select a database to work with
  13.     $selected = mysql_select_db($myDB, $dbhandle)
  14.     or die("Couldn't open database $myDB");
  15.     //Declare the SQL statement that will query the database
  16.     $query = "SELECT * FROM `topics`";
  17.     //Execute the SQL query and return records
  18.     $result = mysql_query($query)
  19.     or die('A error occured: ' . mysql_error());
  20.     //Show result
  21.     while ( $record = mysql_fetch_array($result) )
  22.     {
  23.         echo '<div align="center" id="content">$record["topic_name"] . " " . $record["topic_username"]."<br><br></div>';
  24.     }
  25.     //Free result set memory
  26.     mysql_free_result($result);
  27.     //Close the connection
  28.     mysql_close($dbhandle);
  29. ?>
  30. <html>
  31.     <head>
  32.     </head>
  33.  
  34.     <body>
  35.     </body>
  36. </html>
Add Comment
Please, Sign In to add comment