Skip to main content
Known Participant
December 7, 2017
Answered

DW MX 04 LOGIN FORM...

  • December 7, 2017
  • 1 reply
  • 743 views

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

    This topic has been closed for replies.
    Correct answer Nancy OShea

    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?


    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

    1 reply

    Legend
    December 7, 2017

    One possibility is you could be trying to mix mysql, the old workflow with mysqli, the new workflow?

    curtgusAuthor
    Known Participant
    December 7, 2017

    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.

    curtgusAuthor
    Known Participant
    December 8, 2017

    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.


    Both sites are on the same server.