kr3m3r Posted August 21, 2007 Share Posted August 21, 2007 Here is the code for my interface: <?php session_start(); ?> <html> <head> <title>Multimedia Library - New Item Entry</title> </head> <body> <h1>Multimedia Library - New Item Entry</h1> <?php //create short variable names $UPC=$_POST['UPC']; $title=$_POST['Title']; $MajorAttribute=$_POST['MajorAttribute']; $SecondaryAttribute=$_POST['SecondaryAttribute']; $itemtype = $_SESSION['itemtype']; if(!$UPC || !$title || !$MajorAttribute || !$SecondaryAttribute || !$itemtype) { echo 'You have not entered all the required details. <br />' .'Please go back and try again.'; exit; } $UPC=addslashes($UPC); $title=addslashes($title); $MajorAttribute=addslashes($MajorAttribute); $SecondaryAttribute=addslashes($SecondaryAttribute); $itemtype=addslashes($itemtype); @ $db = mysql_pconnect('school', 'library', 'alpha321'); if(!$db) { echo 'Error: Could not connect to database. Please try later.'; exit; } mysql_select_db('cisse'); $query = "insert into Library_Asset values ('".$UPC."','".$title."','".$MajorAttribute."','".$SecondaryAttribute."','".$itemtype."')"; echo '<br />'; echo $query; echo '<br />'; $result = mysql_query($query); if($result) { echo mysql_affected_rows().' item(s) inserted into database.<br /><br />'; echo 'You entered: <br />'; echo $UPC; echo '<br />'; echo $title; echo '<br />'; echo $MajorAttribute; echo '<br />'; echo $SecondaryAttribute; echo '<br />into the Library'; echo '<br /><br />'; } ?> <INPUT TYPE = BUTTON Value = "Add Another Item" onClick="window.location.href='http://www.kr3m3r.com/newitem.html'"> </body> </html> and here is the query which set up the database: SQL query: CREATE TABLE `Library_Asset` ( `UPC` INT( 13 ) UNSIGNED NOT NULL , `Title` CHAR( 100 ) NOT NULL , `MajorAttribute` CHAR( 100 ) NOT NULL , `SecondaryAttribute` CHAR( 100 ) NOT NULL , PRIMARY KEY ( `UPC` ) ) ; I can add a number of items with UPC values of 123 or 234 or 001234 but for some reason when I attempted to enter a few items to test the database, it will only add the first item I add. Two of the test cases were: 0024543151906 iRobot Alex Proyas Will Smith and 0042284347921 Live at the Apollo 1962 James Brown PolyGram Records which ever one I entered first would be added to the table with no problem (I looked at it through the command line interface) but when I'd go to add the other item, it would fail. (I tried deleting each item from the database, and then starting with the other, and only the first one entered would be added to the table, the second one would not be added to the table). Any help in reasolving this issue would be greatly appreciated. -Robb Quote Link to comment https://forums.phpfreaks.com/topic/66028-solved-database-wont-accept-more-than-one-item/ Share on other sites More sharing options...
kr3m3r Posted August 21, 2007 Author Share Posted August 21, 2007 UPC and ItemType in the SQL needed to be char Quote Link to comment https://forums.phpfreaks.com/topic/66028-solved-database-wont-accept-more-than-one-item/#findComment-330267 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.