Jump to content

Data not showing up in tables??


casino1234

Recommended Posts

<?php
$con = mysql_connect("localhost","user","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("contact", $con);

$sql="INSERT INTO contact_info (FirstName, LastName, Phone, Email, ContactMethod, City, State, zip, TimeFrame, Agent, AgentInfo)
VALUES
('$_POST[firstname]','$_POST[lastname]','$_POST[phone]','$_POST[email]','$_POST[contactmethod]','$_POST[city]','$_POST[state]','$_POST[zip]','$_POST[timeframe]','$_POST[agent]','$_POST[agentinfo]')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "1 record added";

mysql_close($con)
?>

 

That's my code everything seem's to be working fine script runs and says 1 record added however when I go to view the entry phpMyAdmin the entry show's up without the data?

Link to comment
Share on other sites

Array

(

    [ctlSell$txtFirstName] => name

    [ctlSell$txtLastName] => name

    [ctlSell$txtPhone] => 1234567890

    [ctlSell$txtEmail] => email@email.com

    [ctlSell$cboPreferredMethod] => Phone

    [ctlSell$txtCity] => City

    [ctlSell$txtState] => NY

    [ZipCode] => 12345

    [ctlSell$cboTimeFrame] => 15

    [ctlSell$rdoWorkingWithAgent] => 0

    [ctlSell$txtAgentInformation] =>

    [ctlSell$btnSubmit] => Submit

)

 

thats the output so it say's data's going into the table but when I look at it... still nothing :(

Link to comment
Share on other sites

maybe put ' ' around the $_POST elements

$_POST['phone'] instead of $_POST[phone]  et cetera

 

That doesn't matter.  Putting '' around them would help PHP parse the code faster, and it also ensures that you aren't accidentally using a constant instead of array element (php would try to parse it as a constant first, then an array element...if there happens to be a constant by the same name, it would attempt to find the array element of the constant's value).  IOW it's good practice, but not strictly necessary. 

 

His problem that his form is not using the same element names as his array elements he's using in his db query.  If you compare the $_POST dump to his variables in his db query, you can see that they aren't the same. 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.