thanks very one. it centos selinux problem, the selinux does not allows apache server connect to remote host, that why the script not working in web page.
regards, anru On 6 September 2011 11:33, ashley etchell <[email protected]> wrote: > When running from a browser, is the site running from on a different > IP address to the servers main IP, maybe the MySQL user has > IP/hostname restrictions. Check the user in MySQL. > > Ash > > On 6 September 2011 11:26, anru chen <[email protected]> wrote: >> that worked. >> >> I am wondering if the php is not compatiable with x86_64. >> >> regards, >> >> anru >> >> On 6 September 2011 11:24, Berend de Boer <[email protected]> wrote: >>>>>>>> "anru" == anru chen <[email protected]> writes: >>> >>> anru> Hi: my server is centos (CentOS release 5.6 (Final) ). >>> >>> anru> I have a strange problem with mysqli . the mysqli >>> anru> connection only works with command line script , not web >>> anru> page script. >>> >>> anru> I have fiollowing code inside my php script test.php: >>> >>> anru> $connection = mysqli_init(); >>> >>> anru> mysqli_real_connect($connection,$host,$user,$pass,$database); >>> anru> var_dump(mysqli_connect_errno(), mysqli_connect_error()); >>> >>> anru> so when run that file under command line, it is ok, but in >>> anru> web page, it return error code "2003", and error message >>> anru> Can't connect to MySQL server on xxxxxx >>> >>> Try connecting to the same host from command-line, i.e. something like: >>> >>> mysql -h $host -u --user=$user --password=$password $database >>> >>> That works? >>> >>> -- >>> All the best, >>> >>> Berend de Boer >>> >>> >>> ------------------------------------------------------ >>> Awesome Drupal hosting: https://www.xplainhosting.com/ >>> >>> -- >>> NZ PHP Users Group: http://groups.google.com/group/nzphpug >>> To post, send email to [email protected] >>> To unsubscribe, send email to >>> [email protected] >> >> -- >> NZ PHP Users Group: http://groups.google.com/group/nzphpug >> To post, send email to [email protected] >> To unsubscribe, send email to >> [email protected] > > -- > NZ PHP Users Group: http://groups.google.com/group/nzphpug > To post, send email to [email protected] > To unsubscribe, send email to > [email protected] -- NZ PHP Users Group: http://groups.google.com/group/nzphpug To post, send email to [email protected] To unsubscribe, send email to [email protected]
