Incredinot Posted March 15, 2010 Share Posted March 15, 2010 Hi.. Alright, i have some problems... I have this code where some parts of it works, and some dont... Before i submit the whole code here, i would start out by just inserting what accually dont work.. Part one: (The thing that dont work here is that sometimes it works - sometimes it dont? o.O) <?php /* Notice: The variables that is underneeth in this insert into is further up in the code, but they should be just fine. */ // Step 1. // Create a new node. $success = mysql_query("INSERT INTO node ( type, title, uid, status, language, created, changed) VALUES('profil', 'TITEL', '$id', '1', 'da', '$datonu', '$datonu')") or die(mysql_error()); // The above table have a row called "nid" which is primary and auto increment. $result = mysql_query("SELECT * FROM node WHERE uid='$id'") or die(mysql_error()); $row4 = mysql_fetch_array($result); $nodevid = $row4['nid']; // Step 2 // Update the node, and make the vid the same as the nid. $success = mysql_query("UPDATE node SET vid='$nodevid' WHERE uid='$id'") or die(mysql_error()); ?> Part two: (In this part nothing is insertet to the table at ALL) <?php $success = mysql_query("INSERT INTO betalinger ( ordreid, beskrivelse, betalingsmetode, betalingdato, pris, status, uid) VALUES('$dato', '$medlemskabstype', '$betalingstype', '$dato', '$pris', '1', '$id')") or die(mysql_error()); $sql = "DELETE * FROM a_temp_user WHERE dato=$ordrenr"; $result = mysql_query($sql); ?> Let me know if it looks alright and you need all code to figure it out.. Anyway, i hope someone can help me out... Quote Link to comment https://forums.phpfreaks.com/topic/195308-need-help-with-some-insert-into-that-bugs/ Share on other sites More sharing options...
aeroswat Posted March 15, 2010 Share Posted March 15, 2010 The only thing that I can think of is you have a field that is required to be filled out and is not getting a value or it is getting a value that is not correct to what is specified. I'm guessing it probably has to do with your dates but that's just a guess. What errors are you getting? Quote Link to comment https://forums.phpfreaks.com/topic/195308-need-help-with-some-insert-into-that-bugs/#findComment-1026341 Share on other sites More sharing options...
Incredinot Posted March 15, 2010 Author Share Posted March 15, 2010 Accually, i have just tested: <?php mysql_connect("xxxxx", "xxxxx", "xxxxx") or die(mysql_error()); mysql_select_db("xxxxx") or die(mysql_error()); $success = mysql_query("INSERT INTO betalinger ( ordreid, beskrivelse, betalingsmetode, betalingdato, pris, status, uid) VALUES('1166417089', '1', '1', '1166417089', '199500', '1', '111111111')") or die(mysql_error()); ?> And it works just fine.. So it seems like it is a bug in the script somewhere.. Accually my head is gettin' cracked by to many things atm - so anyone wanna do some "freelance"? What you need to help me with is fixin those 2 bugs ofcource - and make the script "failsafe" after a user have sumbittet... So it runs the entire operations without breaking like it does now... (And maybe you can help me with some other stuff aswell) I am quite sure that if you are a good programmer, it wont take you much more than an hour or so to fix.. Maybe less... Anyway, if anyone is up to it - please send me a pm asap and lets work something out. Quote Link to comment https://forums.phpfreaks.com/topic/195308-need-help-with-some-insert-into-that-bugs/#findComment-1026357 Share on other sites More sharing options...
KevinM1 Posted March 15, 2010 Share Posted March 15, 2010 You need to do some basic debugging: 1. In your first example, are there any differences in the data between the values that are being inserted, and those that aren't? 2. Are you certain that the variables you pass into your queries have values? Your test worked because you manually wrote the values directly in the query. This leads me to believe your problem is that your variables aren't actually containing any values when you attempt to insert them, and the insert is failing because you have one or more columns that cannot contain a null value. Quote Link to comment https://forums.phpfreaks.com/topic/195308-need-help-with-some-insert-into-that-bugs/#findComment-1026363 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.