Re: Ploblems inserting into a table, and I dont know why.
| From: | Brian T. Allen | Date: | Mon, 09 Oct 2000 19:11:36 +0000 |
| Subject: | Re: Ploblems inserting into a table, and I dont know why. | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-19229@lists.php.net to get a copy of this message | ||
To check for MySQL errors do:
if(mysql_error()){
mail(...);
}
Add the appropriate mail() command elements to mail yourself the current
page, query, date, and error message and your set.
Brian
> 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
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net