You are here: Re: Problem adding records « All PHP « IT news, forums, messages
Re: Problem adding records

Posted by KB on 02/02/08 01:13

I think I just figured it out. Somehow it worked when I put single quotation
marks around it. It doesn't make much sense to me, because one would think
that then it became a literal string instead of a variable. Kind of puzzled,
but it worked that way???

Kees


"KB" <nospam@nospam.com> wrote in message
news:n2Ooj.23932$E01.11905@newsfe22.lga...
> Hi, I'm trying to use a PHP script to add a record. It's a very simple
> table with three fields: Last Name, First Name and Email Address.
>
> I ran this script and for some reason, the record doesn't get added, but
> all the fields do come accross fine. That's why I have the thing at the
> end where I displayed the fields. When I look at the table, the fields
> aren't there. I don't get an error either.
>
> The connect information has been changed for obvious security reasons. The
> connect information does work fine with other programs, where it reads the
> database. I think the problem likes in my SQL string.
>
> The variable $result returns a blank.
>
> Here is the code:
>
> <?php
>
> $phpform_lastname = $_POST['form_lastname'];
> $phpform_firstname = $_POST['form_firstname'];
> $phpform_email = $_POST['form_email'];
>
> //Connect To Database
> $hostname="hw329d32s7.securecomputer.com";
> $username="joeuser";
> $password="Deleb56";
> $dbname="joeuser";
> $usertable="addresses";
>
> mysql_connect($hostname,$username, $password) OR DIE ("Unable to load the
> Test Database! Please try again later.");
> mysql_select_db($dbname);
>
> //Make and execute SQL String
>
> $query = "INSERT INTO `addresses` (`last_name`, `first_name`,
> `emailaddress`) VALUES ($phpform_lastname, $phpform_firstname,
> $phpform_email)";
> $result = mysql_query($query);
>
> ?>
>
> <html>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
> </head>
>
> <?php
>
> echo "The Result is: ".$result;
>
> echo "<BR>I just added the record with the following parameters.<BR>";
> echo "<BR>";
> echo "The Last name is: ".$phpform_lastname."<BR>";
> echo "The First name is: ".$phpform_firstname."<BR>";
> echo "The Email is: ".$phpform_email."<BR>";
>
> ?>
>
> </body>
> </html>
>
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация