elindithas Posted August 3, 2009 Share Posted August 3, 2009 hiya again, I have a form set to upload info to my database, all laid out working well etc, I know basically how to do an upsert but im getting lost on actually where to punch in the code, also this script is giving me an error on submit, even tho its updating my info what i want is if the name is the same to update the stock value +whatever they add for stock, instead of making a new entry to just update the row <?php $Name = $_POST['Name']; $Color = $_POST['Color']; $Type = $_POST['Type']; $Rarity = $_POST['Rarity']; $Price = $_POST['Price']; $Stock = $_POST['Stock']; $Added = $_POST['Added']; $Added = $_POST['Foil']; $Added = $_POST['Buy']; $Added = $_POST['Buyprice']; $submit = $_POST['submit']; mysql_connect ("localhost", "jmartens", "jason23") or die ('Error: ' . mysql_error()); mysql_select_db ("mtgshack"); $query="INSERT INTO m10 (ID, Name, Color, Type, Rarity, Price, Stock, Added, Foil, Buy, Buyprice)VALUES ('NULL', '".$Name."', '".$Color."', '".$Type."', '".$Rarity."', '".$Price."', '".$Stock."', '".$Added."', '".$Foil."', '".$Buy."', '".$Buyprice."')"; mysql_query($query) or die ('Error updating database'); echo "Database Updated With " .$Name. " " .$Color. " " .$Type. " " .$Rarity. " " .$Price. " " .$Stock. " " .$Added. " " .$Foil. " " .$Buy. " " .$Buyprice ; ?> the error im getting is Notice: Undefined index: submit in C:\wamp\www\website\update.php on line 13 Notice: Undefined variable: Foil in C:\wamp\www\website\update.php on line 19 Notice: Undefined variable: Buy in C:\wamp\www\website\update.php on line 19 Notice: Undefined variable: Buyprice in C:\wamp\www\website\update.php on line 19 Notice: Undefined variable: Foil in C:\wamp\www\website\update.php on line 24 Notice: Undefined variable: Buy in C:\wamp\www\website\update.php on line 24 Notice: Undefined variable: Buyprice in C:\wamp\www\website\update.php on line 24 is it my php setup? or am i missing something? Quote Link to comment https://forums.phpfreaks.com/topic/168643-upserts/ Share on other sites More sharing options...
Maq Posted August 3, 2009 Share Posted August 3, 2009 You're assigning the same variable to 4 different $_POSTs. $Added = $_POST['Added']; $Added = $_POST['Foil']; $Added = $_POST['Buy']; $Added = $_POST['Buyprice']; Should be: $Added = $_POST['Added']; $Foil = $_POST['Foil']; $Buy = $_POST['Buy']; $Buyprice = $_POST['Buyprice']; Quote Link to comment https://forums.phpfreaks.com/topic/168643-upserts/#findComment-889646 Share on other sites More sharing options...
elindithas Posted August 3, 2009 Author Share Posted August 3, 2009 oops, that was a stupid mistake the one ive been getting all along is Notice: Undefined index: submit in C:\wamp\www\website\update.php on line 13 nm, fixed that too, was a capital S somwhere just need to work out this update thing now actually i need it to check the name and the foil status, and if its the same to update the stock for the difference Quote Link to comment https://forums.phpfreaks.com/topic/168643-upserts/#findComment-889672 Share on other sites More sharing options...
Maq Posted August 3, 2009 Share Posted August 3, 2009 I don't understand why you are assigning something to 'submit'. Take that line out, you aren't using it, nor should you be. Quote Link to comment https://forums.phpfreaks.com/topic/168643-upserts/#findComment-889674 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.