
dpiearcy
Members-
Posts
83 -
Joined
-
Last visited
Everything posted by dpiearcy
-
actually I moved it up and this: include_once "Scripts/connect_to_mysql.php"; $name = $_POST['name']; $praise = $_POST['praise']; $pid = $_POST['pid']; $praise = mysqli_real_escape_string($praise); $query = mysqli_query($myConnection, "UPDATE prayer SET how = '$praise', answerdate = NOW() WHERE id = '$pid'") or die (mysqli_error($myConnection)); header("location:praise_wall.php"); exit(); does not write to database. (dang it. Just realized I haven't been removing that URL earlier :-) oops. Nor does it work if I move the require connection just below my post variable settings and just above the escape string.
-
Ok. Changed it back Jessica. Now this $name = $_POST['name']; $praise = $_POST['praise']; $pid = $_POST['pid']; $praise = mysqli_real_escape_string($praise); include_once "Scripts/connect_to_mysql.php"; $request = mysqli_real_escape_string($myConnection, $request); $query = mysqli_query($myConnection, "UPDATE prayer SET how = '$praise', answerdate = NOW() WHERE id = '$pid'") or die (mysqli_error($myConnection)); header("location: praise_wall.php"); exit(); Will not write to the database at all. THIS: $name = $_POST['name']; $praise = $_POST['praise']; $pid = $_POST['pid']; include_once "Scripts/connect_to_mysql.php"; $query = mysqli_query($myConnection, "UPDATE prayer SET how = '$praise', answerdate = NOW() WHERE id = '$pid'") or die (mysqli_error($myConnection)); header("location:praise_wall.php"); exit(); Will update. but will of course give me this error if I use a word like don't. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'T', answerdate = NOW() WHERE id = '12'' at line1 And finally, This: $name = $_POST['name']; $praise = $_POST['praise']; $pid = $_POST['pid']; $praise = mysqli_real_escape_string($praise);[/size][/font][/color] [color=#000000][font=Times][size=1]include_once "Scripts/connect_to_mysql.php"; $query = mysqli_query($myConnection, "UPDATE prayer SET how = '$praise', answerdate = NOW() WHERE id = '$pid'") or die (mysqli_error($myConnection)); header("location: praise_wall.php"); exit(); Will not write regardless of '
-
I haven't been echoing it out. I just look over in php myadmin and see nothing was written. Same effect. Except that annoying logging me out after 1800 seconds :-)
-
Oh. Yeah I see that. I was actually using the same string for update as insert and it didn't work that's when I switched to var specific. Then had it twice so I removed the other string that was identical to the insert. I'll change it back to that way and give it another go.
-
Actually Jessica after reading your link am I right in assuming if I add , E_USER_ERROR) to my code I'm using already $query = mysqli_query($myConnection, "UPDATE prayer SET how = '$praise', answerdate = NOW() WHERE id = '$pid'") or die (mysqli_error($myConnection)); and stick it behind (mwsqli_error($myConnection)) it will give me a more detailed error report???
-
Ok. Here's the actual code (after a bunch of if and else if statements occur) but here's the part that writes to the database and this works fine. I can use a word like don't and it's ok with the '. include_once "Scripts/connect_to_mysql.php"; $request = mysqli_real_escape_string($myConnection, $request); $query = mysqli_query($myConnection, "INSERT INTO prayer (name, email, phone, share, request, sendmail, date) VALUES('$name', '$email', '$phone', '$share', '$request', '$sendmail', now())") or die (mysqli_error($myConnection)); header("location: prayer_wall.php"); exit();} BUT... the same does not work for update. Here's that code: $name = $_POST['name']; $praise = $_POST['praise']; $pid = $_POST['pid']; $praise = mysqli_real_escape_string($praise); include_once "Scripts/connect_to_mysql.php"; $query = mysqli_query($myConnection, "UPDATE prayer SET how = '$praise', answerdate = NOW() WHERE id = '$pid'") or die (mysqli_error($myConnection)); echo 'Operation Completed Successfully! <br /><br />'; header("location: praise_wall.php"); exit(); Yes... I know there are two escape strings. Just using the single one wasn't working so I added the var specific one too. I just read the link in Jessica's footer about error reporting and will amend so I can give you the actual report. This will follow but maybe this will get you started thinking.
-
My first time posting in the javascript forum! I'm usually over looking for help with php. Anyway, I decided to make a really cool menu using some jquery I have used for other applications. Just a slide down box. Here's the code: <script language="javascript" type="text/javascript"> function toggleSlideBox(x) { if ($('#'+x).is(":hidden")) { $(".editBox").slideUp(200); $('#'+x).slideDown(300); } else { $('#'+x).slideUp(300); } } </script> Obviously the div class editBox when clicked (it's a # link) will slide the box down and in that box is just another div so I can put anything I want in there. Currently the only way to close that box is to click the link again. Is there a way to edit this so that is will slideUp on mouse leave? No more hover no more slide down.
-
No worries with log in credentials anyway. That's all done with a require script anyway so isn't located in my query string other than the call for the other script. I'll change the code back and post ASAP.
-
I'll read your links. Thanks. And I don't interpret your facts that way. I said I like them :-) And I'm sure I'm older than you. Not sure what difference that makes other than I'm OLD for a computer geek :-)
-
Yeah, that was the thing I mentioned I didn't know how to do. From what I've read I add this code? ini_set('display_errors',1); error_reporting(E_ALL); Does this go in my query string? If so can you post me an example? I'll post the full code without me changing variable names. But for now $var was actually $praise. I'll get rid of the strip slashes and then copy and paste the code here. Sorry for making changes to the actual code. I can see how that can become confusing.
-
Oh... and as I said at the bottom there... if I add that last bit of script it will go ahead and not throw an error but nothing gets written to the database. Without that code it doesn't give me a specific error (need to learn that command for it to tell me the error. I'll put that on my to do list) just says there's something wrong near ' (the word with the ' in it) and check my manual.
-
Well no...it's not actually called table. Not sure why that was the only thing I changed in there :-) That is the actual code except the table is called prayer. You want the whole code? I figured that was the important part. Oh. And thanks for being nice Jessica. I've seen some of your replies to others. But I have to admit, I love your sense of humor. I can't remember which one or what you said the other day that made me laugh out loud but I was thinking the same thing.
-
This script works when I'm adding a new row to the database: $request = mysqli_real_escape_string($myConnection, $request); $query = mysqli_query($myConnection, "INSERT INTO table (name, email, phone, share, request, sendmail, date) VALUES('$name', '$email', '$phone', '$share', '$request', '$sendmail', now())") or die (mysqli_error($myConnection)); But when I update this code does not work. Gives me an error. $request = mysqli_real_escape_string($myConnection, $request); $query = mysqli_query($myConnection, "UPDATE table SET how = '$praise', answerdate = NOW() WHERE id = '$pid'") or die (mysqli_error($myConnection)); If I add the following to variables: $var= stripslashes(trim($_POST['var'])); $var = mysqli_real_escape_string($var); It WILL go ahead and go. But then nothing is written to the database. Trying to get them dang ' things to go thru and usually the mysqli_real_escap_string does the trick. At least on Insert. Seems not to on update. Suggestions?
-
Oops. Sorry about that David. I added a new post about sessions I titled something like just to help others dealing with sessions that detailed the problem I was having. Basically I was redirecting pages with a header change and then oddly I would lose my session variable. When I changed the way I redirected with a print the problem went away and I was able to receive my session variables. Still haven't figured out why I lost them with the header redirect but after I had a solution I moved on from there but it's something I'm going to look into in the future. After this project is finished perhaps.
-
Thanks Barand. That did the trick. You're quickly becoming my favorite on here since you seem to always be quick to answer my stupid questions :-)
-
I have this pagination script that works well for my regular posts. But I want to paginate from the same database all the fields where a tinyint is 1 and not 0. So select all where "answered=1" in other words. Here is the query which only selects my total num rows. Can this be modified or should I just do a completely different query? A normal one? Here's the query: function pagination($query, $per_page = 10,$page = 1, $url = '?'){ $query = "SELECT COUNT(*) as `num` FROM {$query}"; $row = mysql_fetch_array(mysql_query($query)); $total = $row['num']; $adjacents = "2"; Since I don't want ALL rows just the rows where answered=1 can I change this or start from scratch? Or, if you have a great easy pagination script you don't mind tossing my way that would be awesome too! ;-)
-
Sessions...this May Help Others Dealing With The Issue
dpiearcy replied to dpiearcy's topic in PHP Coding Help
Actually I didn't. I had them just as shown in my code above. Didn't use full paths in either case. Changed nothing else either. Just that and it started working. Which is strange because all my admin area scripts I use sessions on I've never had a problem. Not sure why this made a diff on this project. But it did. -
After struggling all day with trying to get my session variables to carry over to the next page I nearly gave up. I knew I had my variable set because I could echo it out on the page it was on. But as soon as I went to the next page it wouldn't work. So I tried one last thing... Instead of doing a header redirect to the next page I used the old fashioned: print "<script>"; print " self.location='newpage.php';"; print "</script>"; and as soon as I made that changed I was able to echo both my session variable and the local variable I created from the session variable. For some reason This: header("location: newpage.php"); Will destroy your session. There may be a work around I'm not aware of someone can share with me but after being half bald now from frustration hair pulling I figured I would pass along the information because I didn't find this on the 5,348,283,489 websites I visited today reading about sessions.
-
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.
-
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).
-
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.
-
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.
-
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.
-
Never mind. I figured it out. Didn't the whole Homer Simpson "DURH" when I saw my error.
-
I have browsed this forum and noticed other threads dealing with sessions but didn't find a solution in any of those either. I thought it could be my browser not accepting cookies (but it does accept the cookie I write for my admin section) so I tested in Chrome, Safari, Firefox, and IE (YUCK!) and am not passing that variable in any of them.