Jump to content

ryan1234

Members
  • Posts

    18
  • Joined

  • Last visited

ryan1234's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. ryan1234

    Url

    Thanks. I've got it working, however it goes into a continuous loop. How would I stop this once I'm on the redirected page?
  2. ryan1234

    Url

    I'm trying to get the URL of the current page and if it equals the stated URL, then the page redirects. $page = $_SERVER['PHP_SELF']; if ($page == "index.php") { header('Location: index.php?id=1'); } However the code above doesn't seem to be working. Any ideas? Thanks.
  3. Solved, I wasn't posting the id properly. Thanks for all your help.
  4. Used error info and I get this message: Array ( [0] => 00000 [1] => [2] => ) Error info: 1
  5. $sql = "UPDATE newsitems SET headline = :h, author = :a, story = :s, image = :i WHERE id = :r" ; $query = $handle->prepare($sql); $params = array(":h" => $_POST['headline'], ":a" => $_POST['author'], ":s" => $_POST['story'], ":i" => $_POST['image'], ":r" => $row_id); $query->execute($params);
  6. Not one it is redirected back to the same page when the button is clicked.
  7. <form action="editphp.php?id=<?php echo $row['id']; ?>" method="POST"> Headline: <input type="text" name="headline" class="editblog" id="editheadline" value="<?php print $results['headline']; ?>"><br> Author: <input type="text" name="author" value="<?php print $results['author']; ?>"><br> Image (URL): <input type="text" name="image" value="<?php print $results['image']; ?>"><br> Story: <br><textarea cols="60" rows="20" id="editstory"><?php print $results['story']; ?></textarea><br> <input type="submit" value="Submit"> </form>
  8. Stooney tried what you said, didn't work. It sends the id like this: update.php?id=......... It's not updating the table, not too sure the exact problem.
  9. When a submit button is clicked it sends it to a page which contains the code below. It also sends 'id'. I've been trying to update a table in the database using the code below but it doesn't seem to be working. I think it's something to do with the line: WHERE id = " . $row_id ; $row_id = $_GET['id']; $sql = "UPDATE newsitems SET headline = :h, author = :a, story = :s, image = :i WHERE id = " . $row_id ; $query = $handle->prepare($sql); Any ideas? Thanks.
  10. Great that worked. Thanks.
  11. Thanks. Says this: Array ( [0] => 00000 [1] => [2] => ) Error info: 1
  12. I've added what you said and still getting the same error. Not too sure how to use the errorInfo function (bit of a novice sorry).
  13. At the beginning of my code I select the row where column id="a certain value" $id1 = $_GET['id']; $sql = "SELECT * FROM person WHERE = $id1"; $query = $handle->prepare($sql); $query->execute(); $results = $query -> fetchAll(PDO::FETCH_ASSOC); I then try and display the results <?php echo $results['name']; ?> However I keep getting this error: Notice:Undefined index: name .............. Any ideas? Thanks.
  14. Is this the best way of sending the id or...
×
×
  • 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.