Copy link to clipboard
Copied
Have run into a problem in designing a login form. A persistent error such as:
Warning: mysql_select_db() expects parameter 2 to be resource, null given in /home/ibtib/public_html/chsn/login2.php on line 19
Warning: mysql_query() expects parameter 2 to be resource, null given in /home/ibtib/public_html/chsn/login2.php on line 24
Am not able to resolve this.
Curt L. Gustafsson
CS6 is now almost 6 years old and still contains deprecated MySQL behaviors which should never be used on any project.
See link below.
Simple User Registration & Login Script in PHP and MySQLi | All PHP Tricks
Copy link to clipboard
Copied
One possibility is you could be trying to mix mysql, the old workflow with mysqli, the new workflow?
Copy link to clipboard
Copied
First I only changed mysql_select to mysqli_select . This does not result in any change.
Then I changed every instance of mysql to mysqli .
In each case the result is unchanged. In other words: This does not result in either case does not fix the issue.
Warning: mysql_select_db() expects parameter 2 to be resource, null given in /home/ibtib/public_html/chsn/login2.phpon line 19
Warning: mysql_query() expects parameter 2 to be resource, null given in /home/ibtib/public_html/chsn/login2.php on line 24
Also, when I make the change in the code itself, adding the "i" to mysql = mysqli, the code changes from red to black, which probably means it is no longer active -- my hunch, only.
Copy link to clipboard
Copied
curtgus wrote
First I only changed mysql_select to mysqli_select . This does not result in any change.
It doesnt work like that I'm afraid. mysqli has its only way of connecting and selecting.
Copy link to clipboard
Copied
curtgus wrote
First I only changed mysql_select to mysqli_select . This does not result in any change.
Then I changed every instance of mysql to mysqli .
It does not work that way. MySQLi is separate code from deprecated MySQL.
You cannot mix the 2 or use them interchangeably as you have here.
DW MX is too old to be of any value to modern PHP coders.
Copy link to clipboard
Copied
I have CS6 but have not made the change yet.
The strange thing is that I have another site which has the identical code. It works just fine. This might mean the issue is somewhere else but is affecting the lines referenced above.
Any suggestions for proceeding?
Copy link to clipboard
Copied
CS6 is now almost 6 years old and still contains deprecated MySQL behaviors which should never be used on any project.
See link below.
Simple User Registration & Login Script in PHP and MySQLi | All PHP Tricks
Copy link to clipboard
Copied
curtgus wrote
The strange thing is that I have another site which has the identical code. It works just fine.
The other site might be on an older PHP version. If your server has PHP 7, the deprecated MySQL code won't work at all. In some cases, servers with PHP 5.6 won't work either because error reporting is enabled.
The best overall solution is to use modern code and stay away from the deprecated server behaviors.
Copy link to clipboard
Copied
Both sites are on the same server.