4 Replies - 1518 Views - Last Post: 08 October 2012 - 12:21 PM

#1 DoxramosPS  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 174
  • Joined: 07-October 12

MySQLI real escape string not implementing.

Posted 07 October 2012 - 08:52 PM

I've updated a query of mine to mysql_real_escape_string. I've used this same format in another page and it worked flawlessly, but now it is not registering and I'm wondering if anyone can possibly spot something I'm overlooking.

My actual query is as follows.
$link     = mysqli_connect("$server", "$user", "$pass", "webdb");
    $page = mysqli_real_escape_string($link, (string) $_POST['page']);
    $content    = mysqli_real_escape_string($link, (string) $_POST['content']);
$query = "UPDATE `pages` 
              SET `content`='$content' 
              WHERE `name`='$page'";

    mysqli_query($link, $query);
    mysqli_close($link);
header("location: index.php");
?>

And then my form is as follows.

<form action="update_content.php" method="post">
    <textarea name="content" cols="60" rows="10"></textarea>
    <input type="hidden" name="page" value="Index" />
    
   <br /><input type="submit" value="Update" />
   </form>


Is This A Good Question/Topic? 0
  • +

Replies To: MySQLI real escape string not implementing.

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3576
  • View blog
  • Posts: 10,440
  • Joined: 08-June 10

Re: MySQLI real escape string not implementing.

Posted 07 October 2012 - 10:33 PM

the only things I see are
- you donít check, whether your query suceeds or not.
- why use header() when you can use include()?
Was This Post Helpful? 0
  • +
  • -

#3 DoxramosPS  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 174
  • Joined: 07-October 12

Re: MySQLI real escape string not implementing.

Posted 08 October 2012 - 12:03 PM

I actually solved this issue which was actually an overlook by me.
It actually doesn't have the header there anymore and it instead redirects to the original page (Which is still requiring some work.)
If anybody runs into this issue; check your variables! I racked myself for hours just to find out that my webdb variable was listed as webdb not $webdb when it went to connect therefore it wasn't connecting to any database and since I had an autoredirect I never saw the issue until I commented out the redirect.
Was This Post Helpful? 0
  • +
  • -

#4 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5388
  • View blog
  • Posts: 27,383
  • Joined: 10-May 07

Re: MySQLI real escape string not implementing.

Posted 08 October 2012 - 12:10 PM

View PostDoxramosPS, on 08 October 2012 - 03:03 PM, said:

If anybody runs into this issue; check your variables!

This is a common resolution to the php/mysql questions asked here. Members often code it to work & never error check.

Thank you for sharing your solution!
Was This Post Helpful? 0
  • +
  • -

#5 DoxramosPS  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 174
  • Joined: 07-October 12

Re: MySQLI real escape string not implementing.

Posted 08 October 2012 - 12:21 PM

To be honest. I was somewhat embarrassed to post my solution after I realized just how much of it was completely user error haha. Shows that it doesn't matter how many times you have put it in it doesn't mean that you will always do it right.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1