I always hesitate to make mails too long with code,
If you have someplace online to post the .php file as .txt then your can just reference the file in you email.
OK, you've got extra calls to mysql_query() and you are using the return value from mysql_query() incorrectly.
Here's part of the code, rewritten and commented, starting from:
echo "<p>$source</p>";
// define a query to select all poem ids where // the title matches the input.
$query = "SELECT spw_poems_id FROM spw_poems
WHERE spw_poems_title = '{$_POST['poem_title']}' ";// submit the query to mysql $result = mysql_query($query);
// get the result of the query
if (!$result) {
// there was a problem
echo mysql_error();
echo " SQL: $query \n";} else {
// read the results
// since there could be more than one id returned,
// we use a while loop
while ($row = mysql_fetch_row($result)) {
$spw_poems_id[] = $row[0];
}
}// print all the id's returned, there could be more than one print_r($spw_poems_id);
// setup a new query $query2 = "SELECT spw_type_id FROM spw_type WHERE spw_type_description='{$_POST['poemtype']}'";
// submit the query to mysql $result = mysql_query($query2);
// get the result of the query
if (!$result) {
// there was a problem
echo mysql_error();
echo " SQL: $query2 \n";
} else {
// read the results
// since there could be more than one id returned,
// we use a while loop
while ($row = mysql_fetch_row($result)) {
$spw_type_id[] = $row[0];
}
}// now we have an array of type ids print_r($spw_type_id);
// at this point you have two arrays of id's // get the first item in each array $title = $spw_poems_id[0]; $type = $spw_type_id[0];
// setup SQL for insert
$sql = "INSERT INTO spw_typelist (
spw_typelist_id ,
spw_poems_id,
spw_type_id) VALUES ('',
'$title',
'$type')
";// run the query
$result = mysql_query($sql);
if(!$result){
echo "Error inserting your info into mysql: ".mysql_error();
}footer(); exit();
That should do it. I assume someone else will point out any errors I've made.
Sheila
____ � The WDVL Discussion List from WDVL.COM � ____
To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] Send Your Posts To: [EMAIL PROTECTED]
To set a personal password send an email to [EMAIL PROTECTED] with the words: "set WDVLTALK pw=yourpassword" in the body of the email.
To change subscription settings to the wdvltalk digest version:
http://wdvl.internet.com/WDVL/Forum/#sub
________________ http://www.wdvl.com _______________________
You are currently subscribed to wdvltalk as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED]
To unsubscribe via postal mail, please contact us at: Jupitermedia Corp. Attn: Discussion List Management 475 Park Avenue South New York, NY 10016
Please include the email address which you have been contacted with.
