Sorry to be a nuisance again, but I cannot understand why my code is not
functioning correctly.
I have tested the separate elements of the code and they work fine. But
when I put it all together something goes off the rails. I am using
sessions and cookies.
After verifying that the required fields are entered, the script
continues as below:
$sql1 = "INSERT INTO book ( title, sub_title, descr,
comment, bk_cover, copyright, ISBN, language, sellers )
VALUES ('$titleIN', '$sub_titleIN', '$descrIN', '$commentIN',
'$bk_coverIN', '$copyrightIN', '$ISBNIN', '$languageIN',
'$sellersIN')";
$result1 = mysql_query($sql1, $db);
$autoid = mysql_insert_id($result1);
}/* <--- IF THIS LIKE IS DELETED, THE PAGE DOES NOT DISPLAY
So, if I select insert on the page, only the first query is executed
since the rest is commented out. Thus, I get onle the book table
inserted but not other tables, like author, book_author, or publishers,
book_publisher or categories, book_categories...
Is there something wrong with what follows immediately...
like, do I have the brackets right? I've tried about every
combination possible with no change.
//Check if Author is entered & exists
if( (strlen($_POST["first_nameIN"]) > 0)
&& (strlen($_POST["last_nameIN"]) > 0) ) {
$sql2 = "SELECT (first_name, last_name)
FROM author WHERE (first_name LIKE '$first_nameIN'
&& last_name LIKE '$last_nameIN)'";
$result2 = mysql_query($sql2);
if (mysql_num_rows($result2) > 0) {
$sql2a = "INSERT INTO book_author (authID, bookID, ordinal)
VALUES (author.id WHERE (first_name LIKE '$first_nameIN'
&& last_name LIKE '$last_nameIN'),
book.ID WHERE book.title LIKE '$titleIN'), '1'";
$result2a = mysql_query($sql2a, $db);
}
elseif (mysql_num_rows($result2) = 0) {
$sql2b = "INSERT INTO author (first_name, last_name)
VALUES ('$first_nameIN', '$last_nameIN')";
$result2b = mysql_query($sql2b, $db);
$sql2c = "INSERT INTO book_author (authID, bookID, ordinal)
VALUES (author.id WHERE (first_name LIKE '$first_nameIN'
&& last_name LIKE '$last_nameIN'), book.ID
WHERE book.title LIKE '$titleIN'), '1'";
$result2c = mysql_query($sql2c, $db);
}
}
I have tried to format the code for display on this page, but as e-mail
pages tend to be unreliable because of character encoding and page
widths, I hope it is understandable.
I could post an URL to view the code and the output page from the web.
There is something in the code that escapes me totally.
--
unheralded genius: "A clean desk is the sign of a dull mind. "
-------------------------------------------------------------
Phil Jourdan --- [email protected]
http://www.ptahhotep.com
http://www.chiccantine.com/andypantry.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php