me i have a problem in PHP/MYSL database i dont know how send/store a data and receiving that data from the database by use codes ,i tried to do it so many times but i didnt get it.

just try inserting for storing

$name=$_REQUEST['name'];//get from the form
$hostname = "localhost";
$username = "";
$password = "";
$dbid = "";//database name
$link=mysql_connect($hostname, $username, $password);
mysql_select_db($dbid) or die("unable to connect");
mysql_query("INSERT INTO tablename(name)values('$name');
mysql_close($link);	?>
// Connecting, selecting database
$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')
    or die('Could not connect: ' . mysql_error());
echo 'Connected successfully';
mysql_select_db('my_database') or die('Could not select database');

// Performing SQL query
$query = 'SELECT * FROM my_table';
$result = mysql_query($query) or die('Query failed: ' . mysql_error());

// Printing results in HTML
echo "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
    echo "\t<tr>\n";
    foreach ($line as $col_value) {
        echo "\t\t<td>$col_value</td>\n";
    echo "\t</tr>\n";
echo "</table>\n";

// Free resultset

// Closing connection

There's no need to use



unless you want to close a persistent connection. The script above does not use persistent connections so PHP automatically closes the link to MySQL.

If you did want to use persistent links then you would connect to MySQL using

mysql_pconnect('host', 'user', 'pass);


This article has been dead for over six months. Start a new discussion instead.