Jump to content

coolhandluke012

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Everything posted by coolhandluke012

  1. Hi Pikachu, Thank you for getting back to me so quickly, I am very grateful for your time and advice. I ran the code with your recommendations, and found that my data is being properly read in to the array, and also that I am connecting to the database. When you added the mysql_error() call there, this is what I receive when inputting the variables to the VALUES() as $varname, $varname2, $varname3: "Query string: INSERT INTO `MAILINGLIST` (`id`,`First`, `Last`, `Email`, `How_Found`) VALUES (NULL, $firstname, $lastname, $email, $howfound); Produced error: Unknown column '$firstname' in 'field list' When I ran the query directly on myPHPAdmin, of course I couldn't use the variable names at that point so I directly substituted some values for each - this worked. It appears to me therefore that I am tripping up somewhere on the syntax involving how the VALUES() portion replaces the variable names with the actual instance data for each. There is no column of course with those names, so I'm not sure why it is looking for a column at that point, I specified the column names in the first list there. Given the data is being read in properly to the _POST[] array, and also my variables are being initialized properly (verified this by doing an echo of each variable after each initialization), any ideas why when I go to put in the VALUES() as the variables, it all goes to crap? MySQL server version is 5.0.91-log if that is of assistance. I am completely stuck here. I've now echoed out everything I can think to echo out, verified I am actually connecting to the database/table, and that all variables are getting initialized properly. Thanks a million in advance for any feedback or ideas you may have about why this is happening. CL
  2. Hi everyone, First off thank you very kindly to anyone who can provide some enlightenment to this total php/mysql newb. I am creating my first database and while I have been able to connect to the database within my php script (or so I believe), the form data does not appear to be actually getting sent. I have development experience in other languages but this is completely new to me so if I've missed something that appears painfully obvious like a parse error of some sort, I do apologize. I am creating a website using Godaddy as the hosting account, and attempting to connect to the mysql database at the following URL (maybe this is where I'm going wrong): "pnmailinglist.db.4662743.hostedresource.com" Below is my very simple code: <?php //Verify successful connection to database. $connect = mysql_connect("pnmailinglist.db.4662743.hostedresource.com", "*********", "*********"); if(!$connect) {die("Could not connect!"); } //Initialize variables with form data. $firstname = $_POST['FirstName']; $lastname = $_POST['LastName']; $email = $_POST['Email']; $howfound = $_POST['HowFound']; //Post data to database, or return error. mysql_select_db("pnmailinglist", $connect); mysql_query("INSERT INTO mailinglist (First, Last, Email, How_Found) VALUES ($firstname,$lastname,$email,$howfound)"); mysql_close($connect); echo "Thank you for joining our mailing list! We will contact you soon with the dates and times of our upcoming events."; ?> Thank you again very much for any pointers or hints as to where I'm screwing up. I get no runtime errors, no syntax errors, and the echo message does display fine at the end -- just no data when I go to check my database! Best Regards, CL
×
×
  • 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.