dolcezza Posted December 31, 2007 Share Posted December 31, 2007 <?php include_once("connect.php"); $authorlast=$_POST['authorlast']; $date=$_POST['date']; $venue=$_POST['venue']; var_dump("$authorlast"); var_dump("$date"); var_dump("$venue"); $authorquery = ("SELECT * FROM `authors` WHERE `authorlast`='{$_POST['authorlast']}'"); $authorresult=mysql_query($authorquery); $info = mysql_fetch_assoc($authorresult); $authorid = $info['authorid']; var_dump("$authorid"); $venuequery = ("SELECT * FROM 'venues' WHERE 'venue'='{$_POST['venue']}"); $venueresult=mysql_query($venuequery); $info = mysql_fetch_assoc($venueresult); $venueid = $info['venueid']; var_dump("$venueid"); $query = "INSERT INTO events (date,venueid,authorid) VALUES ('$date','$venueid','$authorid')"; $my_result=mysql_query($query); if(!$my_result){echo mysql_error();} else { include('events.php'); // get code from database // mail code to venue } ?> This is what I get: string(0) "" string(9) "1/28/2006" string(16) "White Oak School" string(0) "" string(0) "" event has been added. The database has an event added, but none of the values. Any help for a beginner is greatly appreciated!!! Quote Link to comment https://forums.phpfreaks.com/topic/83811-getting-id-from-a-table-and-putting-it-into-another/ Share on other sites More sharing options...
Barand Posted December 31, 2007 Share Posted December 31, 2007 Looking at the var_dump results: authorlast has no value, so consequently no rec found and authorid is therefore empty The venue query has syntax errors so you won't get a venueid either Insert dates into tables in 2007-01-28 format. I suggest you check values of query result and, if false, display mysql_error() after each of your queries and also check if any rows are returned Quote Link to comment https://forums.phpfreaks.com/topic/83811-getting-id-from-a-table-and-putting-it-into-another/#findComment-426624 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.