nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

PHP Warning: mysql_real_escape_string() [<a href='function.mysql-real-escape-string

This is a discussion on PHP Warning: mysql_real_escape_string() [<a href='function.mysql-real-escape-string within the Web servers forums, part of the Mastering Servers category; Hello, here is a little info before I ask for any help Database Server MySQL + CentOS Code: [root@centos home]# ...


Go Back   nixCraft Linux Forum > Mastering Servers > Web servers

Linux answers from nixCraft.


Web servers Discussion on Apache, Nginx and Lighttpd HTTP/web server and configuration issues.

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-12-2009, 08:21 PM
Junior Member
User
 
Join Date: Dec 2009
OS: CentOS
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
mhbernheim is on a distinguished road
Talking PHP Warning: mysql_real_escape_string() [<a href='function.mysql-real-escape-string

Hello, here is a little info before I ask for any help

Database Server MySQL + CentOS
Code:
[root@centos home]# mysql --version
mysql  Ver 14.12 Distrib 5.0.45, for redhat-linux-gnu (i686) using readline 5.0
Application Server PHP + Apache + CentOS
Code:
root@uploader [~]# php -v
PHP 5.2.9 (cli) (built: Nov 22 2009 10:22:42)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
    with eAccelerator v0.9.6-rc1, Copyright (c) 2004-2007 eAccelerator, by eAccelerator
Apache
Code:
root@uploader [~]# httpd -v
Server version: Apache/2.0.63
Server built:   Nov 22 2009 10:07:08
Cpanel::Easy::Apache v3.2.0 rev4891

Basically, the uploader server receives the file via Perl, and then perl redirects to another script in PHP to handle the inclusion of the file into the database,this process works fine, but sometimes, intermittently throws this error out:


Code:
[04-Dec-2009 06:08:19] PHP Warning:  mysql_insert_id() [<a href='function.mysql-insert-id'>function.mysql-insert-id</a>]: A link to the server could not be established in /home/x/public_html/connect.php on line 111
[08-Dec-2009 23:03:43] PHP Warning:  mysql_pconnect() [<a href='function.mysql-pconnect'>function.mysql-pconnect</a>]: Can't connect to MySQL server on 'x.x.x.x' (113) in /home/x/public_html/adodb/drivers/adodb-mysql.inc.php on line 382
[08-Dec-2009 23:03:44] PHP Warning:  mysql_real_escape_string() [<a href='function.mysql-real-escape-string'>function.mysql-real-escape-string</a>]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home/x/public_html/connect.php on line 102
[08-Dec-2009 23:03:44] PHP Warning:  mysql_real_escape_string() [<a href='function.mysql-real-escape-string'>function.mysql-real-escape-string</a>]: A link to the server could not be established in /home/x/public_html/connect.php on line 102
[08-Dec-2009 23:03:44] PHP Warning:  mysql_real_escape_string() [<a href='function.mysql-real-escape-string'>function.mysql-real-escape-string</a>]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home/x/public_html/connect.php on line 103
[08-Dec-2009 23:03:44] PHP Warning:  mysql_real_escape_string() [<a href='function.mysql-real-escape-string'>function.mysql-real-escape-string</a>]: A link to the server could not be established in /home/x/public_html/connect.php on line 103
[08-Dec-2009 23:03:44] PHP Warning:  mysql_real_escape_string() [<a href='function.mysql-real-escape-string'>function.mysql-real-escape-string</a>]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home/x/public_html/connect.php on line 103
[08-Dec-2009 23:03:44] PHP Warning:  mysql_real_escape_string() [<a href='function.mysql-real-escape-string'>function.mysql-real-escape-string</a>]: A link to the server could not be established in /home/x/public_html/connect.php on line 103
[08-Dec-2009 23:03:44] PHP Warning:  mysql_real_escape_string() [<a href='function.mysql-real-escape-string'>function.mysql-real-escape-string</a>]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home/x/public_html/connect.php on line 104
[08-Dec-2009 23:03:44] PHP Warning:  mysql_real_escape_string() [<a href='function.mysql-real-escape-string'>function.mysql-real-escape-string</a>]: A link to the server could not be established in /home/x/public_html/connect.php on line 104
[08-Dec-2009 23:03:44] PHP Warning:  mysql_real_escape_string() [<a href='function.mysql-real-escape-string'>function.mysql-real-escape-string</a>]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home/x/public_html/connect.php on line 105
[08-Dec-2009 23:03:44] PHP Warning:  mysql_real_escape_string() [<a href='function.mysql-real-escape-string'>function.mysql-real-escape-string</a>]: A link to the server could not be established in /home/x/public_html/connect.php on line 105
[08-Dec-2009 23:03:44] PHP Warning:  mysql_real_escape_string() [<a href='function.mysql-real-escape-string'>function.mysql-real-escape-string</a>]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home/x/public_html/connect.php on line 107
[08-Dec-2009 23:03:44] PHP Warning:  mysql_real_escape_string() [<a href='function.mysql-real-escape-string'>function.mysql-real-escape-string</a>]: A link to the server could not be established in /home/vureel/public_html/connect.php on line 107
[08-Dec-2009 23:03:44] PHP Warning:  mysql_real_escape_string() [<a href='function.mysql-real-escape-string'>function.mysql-real-escape-string</a>]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home/x/public_html/connect.php on line 108
[08-Dec-2009 23:03:44] PHP Warning:  mysql_real_escape_string() [<a href='function.mysql-real-escape-string'>function.mysql-real-escape-string</a>]: A link to the server could not be established in /home/x/public_html/connect.php on line 108
[08-Dec-2009 23:03:44] PHP Warning:  mysql_real_escape_string() [<a href='function.mysql-real-escape-string'>function.mysql-real-escape-string</a>]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home/x/public_html/connect.php on line 109
[08-Dec-2009 23:03:44] PHP Warning:  mysql_real_escape_string() [<a href='function.mysql-real-escape-string'>function.mysql-real-escape-string</a>]: A link to the server could not be established in /home/x/public_html/connect.php on line 109
[08-Dec-2009 23:03:44] PHP Warning:  mysql_insert_id() [<a href='function.mysql-insert-id'>function.mysql-insert-id</a>]: A link to the server could not be established in /home/x/public_html/connect.php on line 111
At first, I thought it was Lighttpd dying, so we reinstalled the server with Cpanel and it still happening There is another server who accesses that same database with 1.5 million users per day and has never had any errors connecting, however this small uploading server (the only one we have), seems to have a hard time connecting, I kindly remind that this happens intermittently and seems to happen more often when the server is under a bit of load... nothing extraordinary though
Reply With Quote
  #2 (permalink)  
Old 12-12-2009, 06:34 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,709
Thanks: 11
Thanked 244 Times in 183 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Can you paste your my.cnf file? Do you use some sort of mysql query caching and acceleration?
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
  #3 (permalink)  
Old 12-12-2009, 07:05 PM
Junior Member
User
 
Join Date: Dec 2009
OS: CentOS
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
mhbernheim is on a distinguished road
Default

Sure Nixcraft,

Code:
[mysqld]
max_connections = 4900
key_buffer = 512M
myisam_sort_buffer_size = 64M
join_buffer_size = 1M
read_buffer_size = 1M
sort_buffer_size = 2M
table_cache = 2500
thread_cache_size = 64
wait_timeout = 3600
connect_timeout = 300
max_allowed_packet = 16M
max_connect_errors = 1000
query_cache_limit = 4M
query_cache_size = 48M
query_cache_type = 1
skip-innodb

[mysqld_safe]
open_files_limit = 8192

[mysqldump]
quick
max_allowed_packet = 16M

[myisamchk]
key_buffer = 64M
sort_buffer = 64M
read_buffer = 16M
write_buffer = 16M
We dont use any acceleration or cache, however, our SELECT *'s on the webserver are cached using AdoDB's file cache, but on the uploading application server there is no cache being used, the folks at the datacenter suggest that the latency might just be too high for MySQL but that seems ridiculous.
Reply With Quote
  #4 (permalink)  
Old 12-12-2009, 07:51 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,709
Thanks: 11
Thanked 244 Times in 183 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

How much memory do you have on this myql server? How many connection do you open at pick to mysql? MySQL needs lots of memory and fast disk I/O system. Try increasing the query cache, and buffers. See if it helps. If I were you here is what I will do to nail do the problem
  1. Turn on sar including disk I/O
  2. Download sar log locally and run Ksar and find out what causing the problem.
  3. Install mtop to monitor mysql load and slow queries
  4. Tune mysql server caching and buffering
  5. Add more RAM and fast storage

Quote:
Access denied for user 'nobody'@'localhost
Do you have nobody user to access database? IF not this can be hacking attempt to gain access to database.
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
  #5 (permalink)  
Old 12-12-2009, 08:01 PM
Junior Member
User
 
Join Date: Dec 2009
OS: CentOS
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
mhbernheim is on a distinguished road
Default

This is my main concern, the main site, which holds the application and handling all of the video views, etc.. also connects to that same database server, however, this little server always has issues connecting, it sometimes works flawlessly and somethings it will just have trouble connecting. The server has 4GB of Memory.

For the nobody user accessing the database, I would believe that because PHP was not able to connect to the remote database it is now trying to access localhost as a database.


mtop shows this:

load average: 1.14, 0.91, 0.60 mysqld 5.0.45 up 11 day(s), 20:52 hrs
101 threads: 1 running, 41 cached. Queries/slow: 137.8M/0 Cache Hit: 100.00%
Opened tables: 0 RRN: 2.2K TLW: 2.6M SFJ: 0 SMP: 0 QPS: 160
Reply With Quote
Reply

Tags
errors , linux , mysql , php , unix


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Howto: PHP Block phpinfo() function asim.mcp Web servers 4 25-10-2009 11:05 PM
[Solved] Help with execvp function in C program ! demuytree Coding in General 3 17-06-2009 01:16 PM
fattach function which package sathiya Linux software 2 02-06-2008 05:41 PM
Adding storage function to a mail server satimis Databases servers 0 04-01-2008 01:15 PM
call function in bash mala_un Shell scripting 9 18-08-2006 01:36 AM


All times are GMT +5.5. The time now is 03:53 AM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38