473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

$mysqli->real_escape_string() not working

Hi there,

Can anyone tell me why the escape_string routines work on my PC but not on the server?

I am using object version of mysqli

PC PHP version = 5.2.9-2
Server PHP version = 5.3.2-1

Expand|Select|Wrap|Line Numbers
  1. if ($mysqli->set_charset("utf8")) {
  2. }
  3.  
  4. $okName = $mysqli->real_escape_string($_POST['Name']);
  5. $okName = htmlspecialchars(okName);
  6.  
test string = (Toby is a good <>'"-/)

output on my pc = (Toby is a good &lt;&gt;\'\&quot;-/)
output on server = (Toby is a good <>'"-/), ie unchanged

Thanks
May 17 '14 #1

✓ answered by Luuk

If you see a '<' in your browser,
Than the source might look like '&lt;'

7 2830
Luuk
1,047 Expert 1GB
Change line 5 to:
Expand|Select|Wrap|Line Numbers
  1. $okName = htmlspecialchars($okName);
  2.  
May 17 '14 #2
Thanks for your reply Luuk.

I did have $okName in my program. That was a typing error in my question. Sorry.

Any other ideas? What can be the difference between the systems on my PC and the server?
May 19 '14 #3
Luuk
1,047 Expert 1GB
How are you viewing the output of your server?
If you do this in a browser, did you do a 'view source'?
May 19 '14 #4
Thanks for your reply Luuk.

This is part of the code for a registration form. I save the user info to a mysql database. I am trying to validate the user input to eliminate potential problems such as chars "/<>'"\".

I test the code on my PC before migrating it to the server. So the code is the same in both environments.

I look at the db records created and noticed the functions have no effect on the server. I use the app "mySQL Query Browser" to look at the records on my pc and a browser to display server records. No haven't use "view source" to do that. Server is down right now. Output

db record on my pc = (Toby is a good &lt;&gt;\'\&quot;-/)
db record on server = (Toby is a good <>'"-/), ie unchanged

thanks for your help. Ideas? Here is a bit more of my code .

Expand|Select|Wrap|Line Numbers
  1.     $okName = $mysqli->real_escape_string($_POST['Name']);
  2.     $okName = htmlentities($okName);
  3.  
  4.     $sql = "INSERT INTO OnlineTbl (UserName,..) VALUES ('okName',..)";
  5.  
  6.     if (!$mysqli->query($sql)) {
  7.         die("Error: ".$mysqli->error);
  8.     }
  9.  
  10.  
May 20 '14 #5
Luuk
1,047 Expert 1GB
If you see a '<' in your browser,
Than the source might look like '&lt;'
May 20 '14 #6
Yes, you are right.

I didn’t realise the browser would convert chars back automatically.

Thank you very much Luuk. Problem solved.
May 24 '14 #7
mHealth
13
Your server may have different configuration/version of mysql.
Jun 8 '14 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Gary | last post by:
I am trying to use the "System.Windows.Forms.SendKeys" class for triggering the Ctrl+P key. Syntax: System.Windows.Forms.SendKeys.Send("^(P)"); This is not working ..what could be the...
6
by: Mullin Yu | last post by:
hi, i have a web service that has file operations on Windows OS, and there may be a file concurrency issue if only one working directory e.g. c:\working therefore, i want to have a unique sub...
3
by: | last post by:
Hello, I am hoping someone else has thought about a date time calculation i need to perform. I would like to be able to calculate the number of "working minutes" between 2 dates, given my...
8
by: Hardy Wang | last post by:
Hi: Is it possible for me to create/open web application from remote machine other than port 80? And create application directly under virtual web site instead of creating a virtual directory?...
4
by: GP | last post by:
We are facing a strange problems everything works fine when we are using the visual studio environment .But when we deploy it in the webserver the save buttons/submit buttons which has the cause...
5
by: Martin Heuckeroth | last post by:
Hi We are working on a webservice application and are having some problems with the cookies and/or sessions. We have them working on our intranet but then its not working on the internet. We...
5
by: tshad | last post by:
I have been working with setting my drop boxes to allow double clicking to select an item. It worked fine until I made some changes. I then stripped the page down to the bare essentials to find...
8
by: jojobar | last post by:
Okay, I am trying to do is to test the webresource in 2.0 1. I created a new project with assembly name (and default assembly name) "Office". 2. I added the following to the AssemblyInfo.cs...
2
by: Don | last post by:
I'm having problems with intellisense, autocomplete, etc. suddenly not working in certain classes of a project I'm working on. All the options are set, and it all works fine for most classes, but...
9
by: MSDNAndi | last post by:
Hi, I have a set of simple webservices calls that worked fine using .NET Framework 1.0. I am calling a Java/Apache based webservices, the calling side is not able to supply a proper WSDL. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.