DelphiFAQ Home Search:

Getting started with php and mysql

 

comments2 comments. Current rating: 3 stars (1 votes). Leave comments and/ or rate it.

You need a basic skeleton to access a mysql database with php? Take the piece from below and add what you need.

<?php

$link = mysql_connect("localhost", "user_name", "password")
   or die("Could not connect : " . mysql_error());

mysql_select_db("database_name") or die("Could not select database");

$query = "INSERT into users (uname) VALUES ('John')";
echo "$query<br>\n";
mysql_query($query);


$query = "SELECT u_name, u_pass FROM users";
$result = mysql_query($query);

/* Printing results in HTML */
while ($row = mysql_fetch_row($result)) {
   echo "\"$row[0],$row[1]\",<br>";
}

?>

Content-type: text/html

Comments:

2013-02-09, 00:25:47
 
rating
yyinwmji <a href=' http://buyviagrate.com/ '>buy cheap viagra online</a> >:]] <a href=' http://buycialiste.com/ '>buy generic cialis online</a> 4053
2013-02-26, 21:55:06
anonymous  

 

 

NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: