php mysql db code question
Does anybody know about php and mysql? I ran both on an old XP installation, and now I'm trying to move all the db files over to linux. I'm using Debian 3.1 and apache2... php 4 and mysql along with phpmyadmin. I moved my db files over from my windows partition, and can look at the contents of the files with phpmyadmin. This makes me think I moved them OK.
I start my php aplication from my browser using localhost. It seems my php application can read from the first table fine, even multiple times from the first table, then when the application tries to read for the first time from another table (in the same database) I get an error. mysql_select_db() has trouble selecting the database, so the next line, mysql_query() doesn't work. Code:
//this is from the second file I was working on XP with php5. I don't know if this is a problem. I am prepared to go through my code and change lines one by one (in fact I expect to) but only when it makes sense. I would like a php.ini setting or something that will make this work.:confused: |
And what is the error? One thing I notice is that you use $link and $Link.
|
The actual code looks like this:
Code:
$Link = mysql_connect($host, $user, $password); BUT it doesn't matter right now!! In an attempt to fix this problem I tried to reinstall php4, and in the process messed things up and now do not have working mysql at all. I apologize to anyone reading this. I really messed up!! Sorry. |
For when it's working again:
1) You no not check the result of the connect. If it fails, you don't know and you pass an invalid connection to mysql_select_db. 2) It's nice to have your own error message, but it does not tell you what goes wrong. Use of mysql_error() is often more usefull. |
I got php4 and mysql to work again, but the same exact problem as above appears.
If I take out the if() statements and the personalized error statements, the code looks something like this: Code:
$Link = mysql_connect($host, $user, $password); Quote:
|
When I moved my database from Windows to linux I retyped the name of the database folder wrong. I changed an uppercase letter to a lowercase letter. Then when I was trying to get my php scripts to work I must have made the same change on some of my scripts in the declaration for the variable "$DBname". I have gotten everything to work now. ALSO, I tried mysql_error() and it was helpfull. Thanks to everyone who looked at this. Thanks Wim.
|
All times are GMT -5. The time now is 06:20 AM. |