hi!!
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.

hi
just try inserting for storing

<html>
<head></head>
<body>
<?php
$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);	?>
</form>
</body>
</html>
<?php
// 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
mysql_free_result($result);

// Closing connection
mysql_close($link);
?>

There's no need to use

mysql_free_result($result);

mysql_close($link);

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);

Regards,
Alex

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.