bovis88 Posted July 18, 2010 Share Posted July 18, 2010 // set date variables date_default_timezone_set("America/New_York"); $date=date("l F d, Y, h:i:s"); $datedb=date("m.d.y"); // passkey from email link $confirm_code=$_GET['confirm_code']; // access temporary table $tbl_name1="temp_member"; // Retrieve data from table where row that match this passkey $sql1="SELECT * FROM $tbl_name1 WHERE confirm_code='$confirm_code'"; $result1=mysql_query($sql1); // If successfully queried if($result1){ // Count the row number of the passkey $count=mysql_num_rows($result1); // if the confirm_code is found in the database, retrieve data from table "temp_member" if($count==1){ $rows=mysql_fetch_array($result1); $confirm_code=$rows['confirm_code']; $email=$rows['email']; $output0=$rows['output0']; $output1=$rows['output1']; $output2=$rows['output2']; $output3=$rows['output3']; $output4=$rows['output4']; $output5=$rows['output5']; $output6=$rows['output6']; $output7=$rows['output7']; $output8=$rows['output8']; $output9=$rows['output9']; $output10=$rows['output10']; $output11=$rows['output11']; $output12=$rows['output12']; $output13=$rows['output13']; $output14=$rows['output14']; $output15=$rows['output15']; $output16=$rows['output16']; $output17=$rows['output17']; $output18=$rows['output18']; $output19=$rows['output19']; $output20=$rows['output20']; $output21=$rows['output21']; $output22=$rows['output22']; $output23=$rows['output23']; $output24=$rows['output24']; $output25=$rows['output25']; $output26=$rows['output26']; $output27=$rows['output27']; // access permanant table $tbl_name2="register_member"; // Insert data that retrieves from "temp_member" into table "register_member" $sql2="INSERT INTO $tbl_name2('confirm_code', 'date', 'email', 'output0', 'output1', 'output2', 'output3', 'output4', 'output5', 'output6', 'output7', 'output8', 'output9', 'output10', 'output11', 'output12', 'output13', 'output14', 'output15', 'output16', 'output17', 'output18', 'output19', 'output20', 'output21', 'output22', 'output23', 'output24', 'output25', 'output26', 'output27') VALUES ('$confirm_code', '$datedb', '$email', '$output0', '$output1', '$output2', '$output3', '$output4', '$output5', '$output6', '$output7', '$output8', '$output9', '$output10', '$output11', '$output12', '$output13', '$output14', '$output15', '$output16', '$output17', '$output18', '$output19', '$output20', '$output21', '$output22', '$output23', '$output24', '$output25', '$output26', '$output27')"; $result2=mysql_query($sql2); Quote Link to comment https://forums.phpfreaks.com/topic/208124-cant-insert-data-into-table/ Share on other sites More sharing options...
bovis88 Posted July 18, 2010 Author Share Posted July 18, 2010 Sorry... forgot to say: I am having a problem inserting data into a table. I'm carrying it over from a temp table and placing it in a permanent one. I think I am getting the data out of the temp table just fine, but can't seem to get it placed into the second table. Later on in the script when I check if($result2) I always get to the else because it didn't process. I am sure the variables are not just blank because when they are sent in an email I receive the values just fine. Any help at all would be excellent. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/208124-cant-insert-data-into-table/#findComment-1087912 Share on other sites More sharing options...
Pikachu2000 Posted July 18, 2010 Share Posted July 18, 2010 How do you know the query is executing? Add the or die() statements to both of your queries like the example below and see if you get any errors. $result2=mysql_query($sql2) or die( 'This query cratered: ' . $sql2 . '<br />And produced this error: ' . mysql_error() ); Quote Link to comment https://forums.phpfreaks.com/topic/208124-cant-insert-data-into-table/#findComment-1087917 Share on other sites More sharing options...
PFMaBiSmAd Posted July 18, 2010 Share Posted July 18, 2010 Your column names are enclosed in single-quotes, thereby making them strings instead of column names. Remove the single-quotes from around the column names. Quote Link to comment https://forums.phpfreaks.com/topic/208124-cant-insert-data-into-table/#findComment-1087921 Share on other sites More sharing options...
bovis88 Posted July 19, 2010 Author Share Posted July 19, 2010 Thank you very much Pikachu2000 and PFMaBiSmAd. Removing the quotes was a necessary step, and that error message from mysql_error() let me know that I was trying to access a column that I had forgotten to create. Quote Link to comment https://forums.phpfreaks.com/topic/208124-cant-insert-data-into-table/#findComment-1087970 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.