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
https://forums.phpfreaks.com/topic/223041-data-not-showing-up-in-tables/
Share on other sites

Array

(

    [ctlSell$txtFirstName] => name

    [ctlSell$txtLastName] => name

    [ctlSell$txtPhone] => 1234567890

    [ctlSell$txtEmail] => [email protected]

    [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 :(

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. 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.