You are here: simple adding of data to a table « PHP Programming Language « IT news, forums, messages
simple adding of data to a table

Posted by tomhughes_86 on 02/07/07 17:54

Hi,
I'm basically creating a system which add records to a pre made SQL
database built in SQLyog.
So far i'va had no problems actually connecting to the database and
displaying resulst but I just cannot make it add records. I know its
connected to the database as a I made a mistake with connection
details on purpose to see if it recognised it.
I just add data into a text field, click submit and the page goes to
a
new, blank page with no changes to the table when I check in SQLyog.
Any help would be much appreciated, as I am very new to PHP.
Thanks Tom.

Here is the code I have tried (simple add before I code the proper
system):


HTML page
<form action="script.php" method="post">
Test: <input type="text" name="test2"><br>
<input type="Submit">
</form>


and the PHP script to add data:
<?
$host="localhost"
$username="root";
$database="test";


$test2=$_POST['test2'];


mysql_pconnect($host,$username);
@mysql_select_db($database) or die( "Unable to select database");


$query = "INSERT INTO test2 VALUES ('','$test2')";
mysql_query($query);


mysql_close();
?>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация