Just came across a bizarre phenomenon (to me at least), when testing some new PHP pages.
On my local dev PC (Win2K, IIS, MySQL 3.x), the page was displaying correctly. On my live system (Red Hat 7, Apache 1.3.x, MySQL 3.x), the database was not returning anything. Running the queries through phpMyAdmin showed that they were not to blame.
Took me ages to notice that I had forgotten to call my include file that contains all the connection code to link to MySQL. Quite rightly, the live system therefore decided that no connection was possible.
I'm puzzled as to why it should be working on the Windows box though. Does the windows version of PHP try to make a connection if it cannot find one, and search available databases until it finds an appropriate table? If so, can this be switched off in PHP.INI as it constitutes a huge data-integrity risk.
Thanks,
PHP and MySQL - odd behaviour
Moderator: General Moderators
You need to make sure your file is in the include path on your Linux box, or implicitly set the include path in your script:
- Rook.
Code: Select all
<?php
ini_set(include_path, "/home/apache/htdocs/includes");
?>http://de.php.net/mysql_query
If this happens (and succeeds) depends on your php/mysql configuration and the query.resource mysql_query ( string query [, resource link_identifier])
...
If link_identifier isn't specified, the last opened link is assumed. If no link is open, the function tries to establish a link as if mysql_connect() was called with no arguments, and use it.
Yes, but you could if you want to learn, fix it so it works on all platforms. I personally loose to many potentional customers if I write something for *nix only, and I bet that so thinks most of the mayor proffessionals.m3rajk wrote:you need to get a better dev. there's differences between the operating systems that can cause issues.
That is pershaps of course not true in your case.
That part is very true. If you are an serious freelancer working at home and dont feel/have the time to make it a dualplatform safe code, you could use a server with dualboot...m3rajk wrote: you should make your dev and deployment environments be the same. you're using a LAMP deployment, you should have a LAMP dev
Thanks for all the replies.
I use Win2K cos that's what my office laptop is and I use it at home to develop. The live system is not a commercial site (it's my own site that runs a multi-user game for me and my friends) so there is no great concern regarding potential customers!
I actually do some of the development on an eComstation box (OEM version of OS/2 Warp 4 Server for eBusiness), and also on my home XP box on which I run Apache. This seemingly mad approach has enabled me to learn a lot more about the underlying technologies and how they interact (or not!), which to me is a good thing. Obviously, if I were developing a commercial site, I would replicate the live environment as closely as I could on my dev PC. This is what I do with the ASP and ColdFusion sites that I (and my team - can't take all the glory
)have written for clients.
Volka, I think that your explanation:
Anyway, thanks again for all the replies.
Jean-Yves
I use Win2K cos that's what my office laptop is and I use it at home to develop. The live system is not a commercial site (it's my own site that runs a multi-user game for me and my friends) so there is no great concern regarding potential customers!
I actually do some of the development on an eComstation box (OEM version of OS/2 Warp 4 Server for eBusiness), and also on my home XP box on which I run Apache. This seemingly mad approach has enabled me to learn a lot more about the underlying technologies and how they interact (or not!), which to me is a good thing. Obviously, if I were developing a commercial site, I would replicate the live environment as closely as I could on my dev PC. This is what I do with the ASP and ColdFusion sites that I (and my team - can't take all the glory
Volka, I think that your explanation:
almost certainly explains the behaviour that I encountered.If no link is open, the function tries to establish a link as if mysql_connect() was called with no arguments, and use it.
Anyway, thanks again for all the replies.
Jean-Yves