|
Posted by Carl on 11/07/06 23:11
Jerim79 wrote:
> I am no PHP programmer. At my current job I made it known that I was no
> PHP programmer during the interview. Still they have given me a script
> to write with the understanding that it will take me a while (This
> information is just for general knowledge as I don't want anyone
> thinking I am trying to be dishonest with my intentions. Also, I do not
> portray myself as something I am not. I am a beginner.)
>
> Anyway, what the script needs to do is to take variables passed from an
> HTML form and do two things. One is read it into a database. The other
> is to send me an email with all of the customer's information.
>
> //Name of the script is test.php
> <?php
> //I am using this echo command to make sure that the variables where
> passed correctly.
> echo $_Post['FName']; //Never displays
> //Here is where the script for the database connections starts
> $username='username';
> $password='password';
> $hostname='localhost';
> $databasename='database';
> //Here is where the database connection is actually made
> $conection = mysql_connect($hostname, $username, $password);
> mysql_select_db($databasename) or die ("Cannot connect to
> database");
> //With the database connection open, I start to insert the data from
> the HTML form.
> $result = mysql_query("INSERT INTO table() VALUES($FName,
> $LName, $Company, $Title, $Address, $Apt, $City, $State, $Zip, $Phone,
> $Fax, $Email, $Var1, $Var2, $Var3, $Var4, $Var5)");
> //After reading the information into the table, we close the database
> connection
> mysql_close();
>8 Message Cut >8
Hi Jerim,
A couple of things;
- $_Post is not the same as $_POST.
- When a function returns a value (as is the case with mysql_query()),
It is usually wise to check the value returned and make sure it is what
you expected.
- The mysql_error() function (http://php.net/mysql_error) is quite
useful when debugging these sorts of problems.
Hope that helps,
Carl.
Navigation:
[Reply to this message]
|