Jump to content

replacing special characters in php form


jbille

Recommended Posts

Use this on all varables that select from the database.

$example=mysql_real_escape_string($example));

[code]
<?php
// Connect
$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')
  OR die(mysql_error());

// Query
$query = sprintf("SELECT * FROM users WHERE user='%s' AND password='%s'",
          mysql_real_escape_string($user),
          mysql_real_escape_string($password));
?>
[/code]
Link to comment
Share on other sites

I am trying to let the user enter 123-456 in the form, and I want to load that number in a database.  However when I try this it just loads 123 in mysql and it stops at the -.  The same goes for 2.50, this puts 2 in the database.  And when I try to use $number=str_replace("-","000000", $number); it puts a false number into mysql.  I am using 000000 because $number is an INT(30).
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.