How do I insert info from a textbox to a text file on my MySql database?
I know how to connect to my database using PHP, so all I need now is to be able to add data to it, then retrieve it on the following page.
Here's what I'm trying to do:
A page where user's can put their name and message, and it pops out on the other page. Basically like a comments page.
How do I insert info from a textbox to a text file on my MySql database?
To a text file on your MySQL database???
Perhaps you mean just into the database? Use mysql_query function (see php.net).
Yes, sorry I just meant into the database :)
Just check out the mysql_query function on php.net and you may also want to read that (http://dev.mysql.com/doc/refman/4.1/en/sql-syntax.html).
Err... I don't know what to look for. Could you help me?
Look at the samples: http://php.net/mysql_query
<?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, that's how you GET the data OUT of the database. !!!
$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);
*/
?>
To access a database you need to understand SQL. Here (http://www.freewebmasterhelp.com/tutorials/phpmysql) is a good SQL tutorial.
To access a database you need to understand SQL. Here (http://www.freewebmasterhelp.com/tutorials/phpmysql) is a good SQL tutorial.
Link doesn't works:
http://www.freewebmasterhelp.com/tutorials/phpmysql
Oh crap... That page must have been taken down recently. I had used that link and found it quite handy. I have to look for another one I guess.