Jump to content

jumpinjacq

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jumpinjacq's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Yes, the connection variable has to be included. So just as an update to this issue, it seems that my testing is what did me in, there must be a caching or session thing going on because I've created another table to test and the update worked the first time only, then I went back to the original table and added another record and again the update worked fine. The problem ensues when I try to test by clearing the values in the database columns and then going back to my page, refreshing and expecting that the "completed" status will not be there, but it is, even though the columns show no values in the database. No explanation yet, but either way, it will work as is.
  2. If php5 means version, then my server has PHP Version 5.2.13.
  3. Yes, as you can see in the latest code, I've done exactly that, I've changed it so that all three queries/results are different. Unfortunately, that did not fix the problem. But thanks for the idea. One thing I have to wonder, is why is it that the update query shows up after a page refresh, I've tried unsetting the submit value in several places and unless I unset at the beginning of the page, which prevents updates in any event, it remains on the screen telling me that the update is running, but not affecting the database. This seems to be a fundamental misunderstanding on my part as to how the code runs and I still feel that there is a caching effect here and I don't know if it's a matter of understanding it or simple a procedural issue.
  4. I've done a lot of playing around, so if there will be some code that is not going to make sense, but I forgot to mention one thing, if I remove the updating part completely and leave only the query, I upload, then refresh the page and get the proper values showing: wrong SELECT * FROM orientation WHERE memberid = 1 blue green So now the database values are being pulled correctly.
  5. Yes, there is. It's so odd, I've been playing around a bit: Here is the test I've set up as it stands now. Just a simple display of some of the info and I'll show what is displayed and some of the quirks that are happening... $done_welcome_video = 'wrong'; echo $done_welcome_video; echo '<br>'; if(isset($_POST['done_welcome'])) { $memberid = 1; $query1 = "UPDATE orientation SET done_welcome_video = 'done' WHERE memberid = $memberid"; echo $query1; echo '<br>'; $result1 = mysqli_query($dbc, $query1); if($result1) { echo 'good'; echo '<br>'; unset($_POST['a']); } else { echo 'bad'; echo '<br>'; } } if(isset($_POST['done_booking'])) { $memberid = 1; $query2 = "UPDATE orientation SET done_booking_session = 'done' WHERE memberid = $memberid"; echo $query2; echo '<br>'; $result2 = mysqli_query($dbc, $query2); if($result2) { echo 'good'; echo '<br>'; unset($_POST['b']); } else { echo 'bad'; echo '<br>'; } } $memberid = 1; $query3 ="SELECT * FROM orientation WHERE memberid = $memberid"; echo $query3; echo '<br>'; $result3 = mysqli_query($dbc, $query3); $row = mysqli_fetch_array($result3, MYSQLI_ASSOC); $done_welcome_video = $row['done_welcome_video']; $done_booking_session = $row['done_booking_session']; echo $done_welcome_video; echo '<br>'; echo $done_booking_session; echo '<br>'; ?> <form action="" method="post"> <input type="submit" name="done_welcome" value="welcome" /> </form> <form action="" method="post"> <input type="submit" name="done_booking" value="booking" /> </form> In the database: done_welcome_video = blue done_booking_session = green The result on screen after reloading the page from scratch: wrong SELECT * FROM orientation WHERE memberid = 1 blue done after I click the welcome button, which should update done_welcome_video to "done", this is what I get on the screen wrong UPDATE orientation SET done_welcome_video = 'done' WHERE memberid = 1 good SELECT * FROM orientation WHERE memberid = 1 done done after I click the booking button, which should update done_booking_session to "done", this is what I get on the screen wrong UPDATE orientation SET done_booking_session = 'done' WHERE memberid = 1 good SELECT * FROM orientation WHERE memberid = 1 done done Then I refresh phpmyadmin screen and the values are blue and green as they were. I hope that makes it a little bit clearer as to what is happening.
  6. Here is an example of one of the tests that I ran just to check if my process was right, a simple update and select and checking to see if my variables were coming out in the wash. And that is why I can't understand why my other code is not working. $done_welcome_video = 'wrong'; echo $done_welcome_video; echo '<br>'; if(isset($_POST['a'])) { $memberid = 1; $query = "UPDATE orientation SET done_welcome_video = 'red' WHERE memberid = $memberid"; echo $query; echo '<br>'; $result = mysqli_query($dbc, $query); if($result) { echo 'good'; echo '<br>'; unset($_POST['a']); } else { echo 'bad'; echo '<br>'; } } if(isset($_POST['b'])) { $memberid = 1; $query = "UPDATE orientation SET done_welcome_video = 'black' WHERE memberid = $memberid"; echo $query; echo '<br>'; $result = mysqli_query($dbc, $query); if($result) { echo 'good'; echo '<br>'; unset($_POST['b']); } else { echo 'bad'; echo '<br>'; } } $memberid = 1; $query ="SELECT * FROM orientation WHERE memberid = $memberid"; echo $query; echo '<br>'; $result = mysqli_query($dbc, $query); $row = mysqli_fetch_array($result, MYSQLI_ASSOC); $done_welcome_video = $row['done_welcome_video']; echo $done_welcome_video; echo '<br>'; $done_welcome_video = 1; echo $done_welcome_video; ?> <form action="" method="post"> <input type="submit" name="a" value="red" /> <input type="submit" name="b" value="black" /> </form> One of the strangest things that I've noticed is that the code is recognizing that the task has been completed, but the database shows no data at all. It's almost like my code has cached the values.
  7. I've done quite a bit of testing to see where the problem might be. Including what some of you have suggested. I made sure all the variables contained information and the right information, also checked for query errors, none, I got 1 as a $result response. I tested the query in the sql command prompt and the update worked. Then I started right from scratch and added bit by bit right from creating a simple query to changing update values to see if they would update in the table and display with the subsequent SELECT queries. All worked perfectly until I put it in the format that I have above. I like the your idea jcbones, I'll study your example as it may be a good solution in any case.
  8. Hi there, I'm having a problem with updating a record with an UPDATE mysql query and then following that query with a SELECT query to get those values just updated. This is what I'm trying to do...I'd like a member to be able to complete a recommended task and upon doing so, go to a page in their back office where they can check off that task as "Completed". This completed task would be recorded in their member record in our database so that when they return to this list, it will remain as "Completed". I'm providing the member with a submit button that will call the same page and then update depending on which task is clicked as complete. Here is my code: $memberid = $_SESSION['member']; // Check if form has been submitted if(isset($_POST['task_done']) && $_POST['task_submit'] == 'submitted') { $taskvalue = $_POST['task_value']; $query = "UPDATE membertable SET $taskvalue = 'done' WHERE id = $memberid"; $result = mysqli_query($dbc, $query); } $query ="SELECT task1, task2, task3 FROM membertable WHERE id = $memberid"; $result = mysqli_query($dbc, $query); $row = mysqli_fetch_array($result, MYSQLI_ASSOC); $_SESSION['task1'] = $row['task1']; $_SESSION['task2'] = $row['task2']; $_SESSION['task3'] = $row['task3']; ?> <h4>Task List</h4> <table> <form action="" method="post"> <tr> <td>Task 1</td> <td><?php if($_SESSION['task1'] == 'done') {echo '<div>Completed</div>';} else{ echo '<input type="submit" name="task_done" value="Mark As Completed" />';} ?></td> </tr> <input type="hidden" name="task_value" value="task1" /> <input type="hidden" name="task_submit" value="submitted" /> </form> <form action="" method="post"> <tr> <td>Task 1</td> <td><?php if($_SESSION['task1'] == 'done') {echo '<div>Completed</div>';} else{ echo '<input type="submit" name="task_done" value="Mark As Completed" />';} ?></td> </tr> <input type="hidden" name="task_value" value="task2" /> <input type="hidden" name="task_submit" value="submitted" /> </form> <form action="" method="post"> <tr> <td>Task 1</td> <td><?php if($_SESSION['task1'] == 'done') {echo '<div>Completed</div>';} else{ echo '<input type="submit" name="task_done" value="Mark As Completed" />';} ?></td> </tr> <input type="hidden" name="task_value" value="task3" /> <input type="hidden" name="task_submit" value="submitted" /> </form> </table> The problem that I am having is that the database is not updated with the value "done" but after submission, the screen displays "Completed" instead of "Mark As Completed". So the value is being picked up as "done", but that is why I have the SELECT after the UPDATES, so that there is always a current value for whether a task is done or not. Then I refresh and the screen returns the button to Mark As Complete. Also, when I try marking all three tasks as, sometimes all three are updated, sometimes only one or two and again, I leave the page or refresh and the "Marked As Completed" buttons come back. Bizarre. If anyone can tell me where my logic is going wrong, I would appreciate it.
  9. Looks like the httpd.conf file needs to be modified to allow what I'm trying to do, but I can't find it, most likely because I'm on shared hosting. But there is the option to add an Apache Handler in Panelbox UI, maybe that is where I need to set this up? I'll contact their admin and see what I can find out. Any thoughts on this?
  10. That all makes sense, thank you. I tried the code that you provided and I'm getting a 500 internal error. The only rewrites I have I've provided below: RewriteEngine on DirectoryIndex index.shtml index.html index.php RewriteCond %{HTTP_HOST} ^mywebsite.com$ [OR] RewriteCond %{HTTP_HOST} ^www.mywebsite.com$ RewriteRule ^/?$ "http\:\/\/www\.mywebsite\.com\/otherfile\/" [R=301,L] Would these be causing a problem? The 500 internal error is across the site, no url works.
  11. Hi Gizmola, Thanks for the quick reply. I kinda figured it would be a mod rewrite. I've looked at about about ten different sites and gone into tutorials to try to figure it out, but haven't been successful in understanding how to do this. Do you know where I can find some example code? Or even a tutorial that will get me up to speed?
  12. Hi everyone, I'm developing an affiliate tracking process and after a lot of thought, I was wondering if someone might be able suggest if I'm on the right track. I'm trying to get away from the usual ...?id=135845 type of links. I was thinking about two possibilities: 1. (I don't know if this is possible), but to generate a subdomain with php at the time an affiliate signs up and then track them by extracting the subdomain to identify the affiliate, or 2. Somehow, maybe using a mod rewrite, using the affiliate username at the end of a url, ex. www.website.com/username , you can see that there is no extension, but when a person comes to that url, it will display the contents of www.website.com and I'd extract the username 'username' from the url and query the database to identify the affiliate. Any thoughts on how this can be done?
  13. Just wanted to say hello. I've just joined the site although I've visited many times before. I'm looking forward to some great PHP experiences.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.