Hi. A quick hack to figure out your problem is to change: IF (mysql_query($query)){ print "Row added to table"; } else { print "error adding row"; }
To: if (!$result = mysql_query($query)) { print 'Query Error: ' . mysql_error(); exit; } else { print 'Success! Row added.'; } In short, mysql_error() is your friend. Regards, Philip Olson On Tue, 2 Apr 2002, menezesd wrote: > Hello Friends. > > I know I am asking for too much. But somehow, I am stuck > with three books I am refering and still not being able to > solve my problem, which I would greatly appreciate if any > of you gurus can assist. The problem is as follows : > > I have three sections in this mail : > 1. My table structure > 2. My test.html file whose ACTION is testphp1.php file > 3. My testphp1.php file. > > The problem is that I keep getting the error "error adding > rows" as the rows are not adding in the database. > > My table structure : > ==================== > Table name : news > Fields : > newsid INT(11) > title carchar(100) > author varchar(40) > posted INT(11) > body MEDIUMTEXT > > > My test.htm file : > ================== > <html> > <head> > <title>Untitled Document</title> > <meta http-equiv="Content-Type" content="text/html; > charset=iso-8859-1"> > > </head> > > <body bgcolor="#FFFFFF" text="#000000"> > <form name="form1" method="post" action="testphp1.php"> > <p> > <input type="text" name="newsid"> > </p> > <p> > <input type="text" name="title"> > </p> > <p> > <input type="text" name="author"> > </p> > <p> > <input type="text" name="body"> > </p> > <p> > <input type="submit" name="Submit" value="Submit"> > </p> > </form> > </body> > > > > </html> > > > My testphp1.php file : > ====================== > > <html> > <head> > <title>Untitled Document</title> > <meta http-equiv="Content-Type" content="text/html; > charset=iso-8859-1"> > > </head> > > <body bgcolor="#FFFFFF" text="#000000"> > <? > $link=mysql_connect("localhost","menezesd","FX3PYTys"); > if ($link){ > print "link id is $link"; > } else { > print "error connecting to database"; > } > $posted=time(); > > $query="INSERT INTO 'news' > ('newsid','title','author', 'posted', 'body') > VALUES($newsid,'$title','$author',$posted,'$body' )"; > print ($query); > > IF (mysql_query($query)){ > print "Row added to table"; > } else { > print "error adding row"; > } > mysql_close($link); > ?> > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php