Whenever I am having problems with SQL queries I always display the query on the page with all the replaced variables so I can make sure that the query makes sense. If it passes the MySQL parser in my brain and still doesn't work, I will copy the displayed query into the command line mysql monitor (or phpmyadmin) and try the command manually to see what happens.
I also found it easier to solve my SQL problems by not using "or die " and just displaying some information about the problem query. This way I know something is wrong if the third line of the echo is not at least 1. $query="INSERT INTO test (test1, test2) VALUES ('$_POST['test1']','$_POST['test2']')"; $result = mysql_query($query); echo(mysql_error()."<BR>$query<BR>".mysql_affected_rows($result)); James On Sunday 15 June 2003 09:39 am, Frank Keessen wrote: > Dear all, > > Refering to my first e-mail with the same subject; I've reworked the code > to this: > > But the only problem is; Nothing is written into the mysql database! And > there are no error displayed.. > > Can someone have a look at my code? > > <? > $_REQUEST["submit"]=isset($_REQUEST["submit"])?$_REQUEST["submit"]:""; > if($_REQUEST['submit']!="") > { > for($i=0;$i<count($_POST['test1[]']);$i++) { > $query="INSERT INTO test (test1, test2) VALUES > ('$_POST['test1']','$_POST['test2']')"; $result = mysql_query($query) or > die ("Error in query: $query. " . mysql_error()); } > } > ?> > <form name="form1" method=post id=form1 enctype=multipart/form-data > action="<? $_SERVER['PHP_SELF']?>"> <? > for ($i=1; $i<=2; $i++) > { > echo "# $i<input type=\"text\" name=\"test1[]\"><br>"; > echo "# $i<input type=\"text\" name=\"test2[]\"><br>"; > > } > > ?> > <input type=submit name=submit value=submit> > </form> > > Thanks very much, > > Frank -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php