Insert problems in to a MySQL database.

From: Date: Thu, 05 Oct 2000 15:26:08 +0000
Subject: Insert problems in to a MySQL database.
Groups: php.general 
Request: Send a blank email to php-general+get-18738@lists.php.net to get a copy of this message
I have some problems. I have a database for news for our intranet. I have got the presentation to work but now I am trying to create an inputpage for it with a form. I get a invalid query when i run it via the webpage, but if I enter the query via the MySQLAdmin it works perfectly.Ofcourse I have put in real data In the query instead of variables. The database is set up as follows: CREATE TABLE news ( id tinyint(4) DEFAULT '0' NOT NULL AUTO_INCREMENT, date varchar(10) NOT NULL,time varchar(8)NOT NULL, head varchar(20), content blob, PRIMARY KEY (id), UNIQUE id (id)); The form I use: <form method="POST" action="newsin.php" <table width="606" border="1"> <table> <tr> <td>Rubrik:<br> <input type="text" name="head" size="42"></td> </tr> <tr> <td>Innehåll:<br> <textarea rows="9" name="content" cols="62"></textarea><br> <p><input type="submit"><input type="reset" value="Reset" name="B2"></td> </tr> </table> </form> DB Updatescript: <?php $db = mysql_connect("localhost","root"); mysql_select_db("news",$db); mysql_query("insert into news values(NULL,curdate(),curtime(),%s,%s",$head,$content) or die("Invalid Query"); ?> I have tried the following querys: mysql_query("insert into news.news values(NULL,curdate(),curtime(),'$rubrik','$content';") or die("Invalid Query"); mysql_query("insert into news.news values(NULL,curdate(),curtime(),%s,%s",$rubrik,$content") or die("Invalid Query"); With and without the ' signs and the ; signs in different places. Any ideas? ;-) /Jari

« previous php.general (#18738) next »