INSERT into mySQL over PHP (internet)
| From: | Nils Wetterich | Date: | Thu, 03 May 2001 13:43:11 +0000 |
| Subject: | INSERT into mySQL over PHP (internet) | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-9091@lists.php.net to get a copy of this message | ||
Hi NG
Now that I finally realy work with the combination mySQL & PHP on a
Windows-machine I began to just love it. There's only one problem I still
have:
How can I INSERT data from a HTML-form to the database on the server? I'd
like to have some kind of a GUI on the internet so I could administer and
manage the database from everywhere I want.
Please look at what I have yet. Maybe you can find the prob and help me. (I
have the idea that "mysql_query()" can't work with the variables ($uName &
$eMail).)
Thanx in advance,
Yours Nils.
---------------------------------------------------------
$con = @mysql_connect("host", "user", "password") or die("Oops...
no
connect.");
$qry = "SELECT name, mail FROM TUsers";
$res = mysql_db_query("database", $qry, $con);
// $ins = "INSERT INTO TUsers (name, mail)
// VALUES ($uName, $eMail)"; // ---------------> doesn't work!
$ins = "INSERT INTO TUsers (name, mail)
VALUES (\"Any Name\", "\and eMail\"); // ------> works
perfect!
mysql_query($ins) or die("Sorry. Couldn't execute INSERT.");
<form action="script.php" method="post">
Name: <input type="text" name="uName"><br>
eMail: <input type="text" name="eMail"><br>
<input type="submit">
</form>