dpiearcy Posted December 15, 2012 Share Posted December 15, 2012 I'm still learning mysqli (obviously). Can someone give me the proper format for the following? $query = mysqli_query($myConnection, "INSERT INTO table WHERE id='$pid' LIMIT 1(how, date) VALUES('$var', now()) ") or die (mysqli_error($myConnection)); Just wanting to update here and not write a new row hence why I need to match the id. Quote Link to comment https://forums.phpfreaks.com/topic/272037-proper-format/ Share on other sites More sharing options...
Barand Posted December 15, 2012 Share Posted December 15, 2012 You need an UPDATE, not an INSERT UPDATE tablename SET how = '$var', date=NOW() WHERE id=$pid LIMIT 1 If the is unique you don't need the LIMIT 1. Quote Link to comment https://forums.phpfreaks.com/topic/272037-proper-format/#findComment-1399583 Share on other sites More sharing options...
dpiearcy Posted December 15, 2012 Author Share Posted December 15, 2012 You need an UPDATE, not an INSERT UPDATE tablename SET how = '$var', date=NOW() WHERE id=$pid LIMIT 1 If the is unique you don't need the LIMIT 1. WHAT button do I push to insert code like you did? I've tried a few of them and haven't figured that out on here yet either :-) I want to do things correctly after all. I know this was off topic but thought I'd ask. I'm going to try that and see if it works. Thanks for the reply. Quote Link to comment https://forums.phpfreaks.com/topic/272037-proper-format/#findComment-1399584 Share on other sites More sharing options...
Christian F. Posted December 15, 2012 Share Posted December 15, 2012 (edited) It's the <> button, or you could just write the [code][/code] tags out by hand. Edited December 15, 2012 by Christian F. Quote Link to comment https://forums.phpfreaks.com/topic/272037-proper-format/#findComment-1399585 Share on other sites More sharing options...
dpiearcy Posted December 15, 2012 Author Share Posted December 15, 2012 Thanks for that Christian F. Ok... not even going to bother changing table names and var names this time. This still does not work. I'm no longer getting an error but from php myadmin I see nothing has changed in the database. Here is what I used as per Barand. $query = mysqli_query($myConnection, "UPDATE prayer SET how = '$praise', date=NOW() WHERE id=$pid") or die (mysqli_error($myConnection)); Tried single quotes around the var pid to no effect as well just to check. Quote Link to comment https://forums.phpfreaks.com/topic/272037-proper-format/#findComment-1399589 Share on other sites More sharing options...
dpiearcy Posted December 15, 2012 Author Share Posted December 15, 2012 I should say (not sure if it matters) but the row ''how" has nothing in it until this point. The other rows are filled out except for how and then I want the current date. From the former insert I have the date of original insert. I want the date now so I can have both so I have two different rows for that. Short and simple, this is a prayer request board for a church I'm helping. Have their request board working but I want them to hit a button when prayer is answered. That's the how part coming from a form that says how it all happened. Then I show on a different board answered prayer with the original request, the how, the original posted date and then the answered date. I know none of that matters just saying neither of those rows will have anything in them. (well....date will have the default 00-00-0000 I guess). Quote Link to comment https://forums.phpfreaks.com/topic/272037-proper-format/#findComment-1399591 Share on other sites More sharing options...
dpiearcy Posted December 15, 2012 Author Share Posted December 15, 2012 I THINK I have found at least the source of part of the problem. For SOME reason my sessions suddenly stopped working. I had my parse.php just echo my variables and I was getting the ID from a session stored. It was working earlier and now has stopped. So I'm not sending the ID to the database to change hence no change. Back to figuring out why that suddenly stopped working since I haven't edited that at all. Quote Link to comment https://forums.phpfreaks.com/topic/272037-proper-format/#findComment-1399596 Share on other sites More sharing options...
PFMaBiSmAd Posted December 16, 2012 Share Posted December 16, 2012 It's more likely that you introduced a literal character or the BOM (Byte Order Mark) at the start of your file and that's what is causing your session variables to no longer work, and in the case where they started working again, that character/BOM got removed or didn't transfer when you copied file(s) to a server. Do you have php's error_reporting set to E_ALL and display_errors set to ON so that php will help you by reporting and displaying all the errors it detects? You are likely getting php errors that would point to why your session variables are not working. Also, echoing a $_SESSION variable on the page where it is set, doesn't mean that variable is part of a session if the session_start() statement on that page has failed. In this case, the $_SESSION variables are only local to the page they are set on. Quote Link to comment https://forums.phpfreaks.com/topic/272037-proper-format/#findComment-1399675 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.