Jump to content

Recommended Posts

I don't do it like that but it may be

 

$q = "Select * From cpanel_users WHERE Usr_Username= {mysqli_real_escape_string($dbc, $Post_Username)}";

 

This should be close to it.

 

edited mysqli_real_escape_string after post below

Link to comment
https://forums.phpfreaks.com/topic/268381-mysql-real-escape/#findComment-1377957
Share on other sites

See Example 1 at the php.net link that shlumph posted.

 

The most general purpose way is to use sprintf since it separates the php syntax as much as possible from the sql syntax. It's also very similar to how you would form a query using prepared statements, so when you are ready to move onto that step, things will already look familiar.

Link to comment
https://forums.phpfreaks.com/topic/268381-mysql-real-escape/#findComment-1378080
Share on other sites

As @PFMaBiSmAd mentioned above using sprintf - http://en.wikipedia.org/wiki/SQL_injection (take a look at Escaping )

Example:

$query = sprintf("SELECT * FROM `Users` WHERE UserName='%s' AND Password='%s'",
                  mysql_real_escape_string($Username),
                  mysql_real_escape_string($Password));
mysql_query($query);

 

Best way to prevent SQL injection is prepared statements and parametrical queries, using PDO or mysqli.

Link to comment
https://forums.phpfreaks.com/topic/268381-mysql-real-escape/#findComment-1378560
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.