Re: Ploblems inserting into a table, and I dont know why.

From: Date: Mon, 09 Oct 2000 05:52:05 +0000
Subject: Re: Ploblems inserting into a table, and I dont know why.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-19146@lists.php.net to get a copy of this message
On Mon, 09 Oct 2000, Dallas Kropka wrote: > > I have connected to mysql, > I have created the DB, > I have created the Table, > I have made the database the active database, > And I still cant freaken do it,..... here is my code. > Please pardon the sloppy code, and forgive me any infringements on the rules, this is my first > post, > Thanks in advance. > > > > > <HTML> > <body> > > <? > require("connect.phtml"); > > $debug=1; > > if ($debug) > { > > echo (" > Name = $applicant <BR> > Email = $email<BR> > email var = $email_var<BR> > <BR> > Company = $company_name<BR> > address = $address<BR> > city = $city<BR> > > "); > > //does the email match? > > if ($email == $email_var) > echo"the email addresses match"; > else > echo"the email addresses do not match"; > > } > > //$res = mysql_select_db("mail_list"); > if(!mysql_select_db(mail_list)) > {echo"<BR>database not selected<BR>"; > exit(); > } > else > { echo "<BR>database selected<BR>"; > } > > > $add = "INSERT into list VALUES ($applicant, $email, $company_name, $address, > $city)"; If these are char type fields then they should be delimited by single quotes $add = "INSERT into list VALUES ('$applicant', '$email', '$company_name', '$address', '$city')"; > > > > if(!mysql_query($add)) > { echo" unable to insert into DB"; > } > else > { echo"insert complete"; > } > > > > ?> > </body> > </HTML> A general debugging tip for mysql problems is to use mysql_error() after your database call to see if any errors are being returned by mysql. It will save a lot of frustration and emails to this list :-) -- David Robley | WEBMASTER & Mail List Admin RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/ AusEinet | http://auseinet.flinders.edu.au/ Flinders University, ADELAIDE, SOUTH AUSTRALIA

« previous php.general (#19146) next »