6 messages in com.mysql.lists.win32RE: can't insert in mysql db using php| From | Sent On | Attachments |
|---|---|---|
| GORE...@aol.com | 24 Dec 2001 17:55 | |
| Stephano Mariani | 25 Dec 2001 06:29 | |
| Gerald R. Jensen | 25 Dec 2001 09:14 | |
| Rob Raisch | 25 Dec 2001 10:01 | |
| gabi | 27 Dec 2001 08:15 | |
| Land, Christopher | 27 Dec 2001 12:40 |
| Subject: | RE: can't insert in mysql db using php![]() |
|---|---|
| From: | Land, Christopher (C2.L...@247realmedia.com) |
| Date: | 12/27/2001 12:40:08 PM |
| List: | com.mysql.lists.win32 |
Try this:
$query = "INSERT INTO articole VALUES ('$titlu', '$bodytext', '$autor')";
Xi2
-----Original Message----- From: gabi [mailto:gabi...@fx.ro] Sent: Thursday, December 27, 2001 8:16 AM To: win...@lists.mysql.com; PHPL...@yahoogroups.com; php-...@yahoogroups.com Subject: can't insert in mysql db using php
I have a database:
Database revista - table articole
Field Type Null Extra artid int(11) No auto_increment titlu varchar(80) Yes bodytext text No autor varchar(100) Yes
and 2 pages:
index.php
<html> <head><title>Web Database Sample Index</title> </head> <body bgcolor=#ffffff> <h1>Data from mytable</h1> <? mysql_connect("localhost", "", ""); $query = "SELECT titlu, autor FROM articole"; $result = mysql_db_query("example", $query); if ($result) { echo "Found these entries in the database:<ul>"; while ($r = mysql_fetch_array($result)) { $titlu = $r["titlu"]; $autor = $r["autor"]; echo "<li>$titlu, $autor"; } echo "</ul>"; } else { echo "No data."; } //mysql_free_result($result); ?> <p><a href="add.php">Add new entry</a> </body> </html>
add.php
<html> <head><title>Web Database Sample Inserting</title> </head> <body bgcolor=#ffffff> <? mysql_connect("localhost", "", ""); if (isset($titlu) && isset($autor)) { $query = "INSERT INTO articole VALUES ('$titlu', '$autor')"; $result = mysql_db_query("example", $query); if ($result) { echo "<p>$name was added to the database</p>"; } } ?> <h1>Add an entry</h1> <form> Titlu: <input type=text name='titlu'><br> Autor: <input type=text name='autor'><br> <input type=submit> </form> <p><a href="index.php">Back to index</a> </body> </html>
I can't insert text in db. I don't know why. I can connect to database.
Any tip/clue appreciate!
Thank you!
gabi
--------------------------------------------------------------------- Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before posting. To request this thread, e-mail win3...@lists.mysql.com
To unsubscribe, send a message to the address shown in the List-Unsubscribe header of this message. If you cannot see it, e-mail win3...@lists.mysql.com instead.




