Archaic Binary

 
  • Decrease font size
  • Default font size
  • Increase font size
  • default color
  • blue color
  • green color
Home arrow Forums
Welcome, Guest
Please remember that if you wish to join in the conversations, you must register an account or login.
Re: Connect to MySQL Database from PHP (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: Re: Connect to MySQL Database from PHP
#1
zharvek (Admin)
Server Admin, Webmaster, Programming, Eh More...
Admin
Posts: 69
graph
User Online Now Click here to see the profile of this user
Gender: Male Archaic Binary Zharvek Location: Orlando, FL Birthdate: 1984-11-28
Connect to MySQL Database from PHP 8 Months, 2 Weeks ago Karma: 4  
Code:

Standard PHP Connect to MySQL <?php // Connect to database server $hd = mysql_connect("myhost", "username", "password") or die ("Unable to connect"); // Select database mysql_select_db ("database", $hd) or die ("Unable to select database"); // Execute sample query $res = mysql_query("SELECT * FROM customer", $hd) or die ("Unable to run query"); // Query number of rows in rowset $nrows = mysql_num_rows($res); // Output echo "The query returned $nrows row(s):\n\n"; // Iteration loop, for each row in rowset while ($row = mysql_fetch_assoc($res)) { // Assigning variables from cell values $data1 = $row["title"]; $data2 = $row["fname"]; $data3 = $row["lname"]; $data4 = $row["phone"]; // Outputting data to browser echo "ROW# $nr : $data1 $data2 $data3 $data4\n"; } // Close the MySQL connection mysql_close($hd); ?>
 
Report to moderator   Logged Logged  
 
I once knew a Jewish girl who kept a diary. It ended badly... Ah! You thought I was making a Nazi joke... SHAME ON YOU! -Clouse (American Dad)
  The administrator has disabled public write access.
#8
teverz (User)
Fresh Boarder
Posts: 3
graphgraph
User Offline Click here to see the profile of this user
Re: Connect to MySQL Database from PHP 8 Months, 2 Weeks ago Karma: 0  
Nice to see someone helping others with coding. Good Job!!
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
Go to top Post Reply
get the latest posts directly to your desktop