Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    449
    Rep Power
    0

    PHP & MySQL move from Linux to Win2000. HELP ! ! !


    I cant seem to work this out.
    I had my sql db on a linux 7.3 box and was accessing it via php pages.
    My boss wants it on a win2000 machine.
    I have installed IIS, PHP, MySQL on the iwn2000 box.
    CLI for MySQL works fine and db is working.
    IIS is working.

    I think the PHP part is the problem.
    The error I get is :

    Notice: Use of undefined constant localhost - assumed 'localhost' in c:\inetpub\wwwroot\validate-login.php on line 5

    I have register_globals = On.

    Help please, I dont know what Im doing here.
    Cheers
  2. #2
  3. No Profile Picture
    The Dude Abides
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Feb 2000
    Location
    grass valley,ca
    Posts
    1,062
    Rep Power
    20
    Well, I feel like Kevorkian helping you migrate from Linux to Winserver, but.....

    Before you start testing your current application, you should run some test php scripts. See if php is running properly (do a phpinfo), see if php can successfully talk to mysql. I'd just do a simple query on a database and see if it prints results.

    From your error message, it looks like it doesn't like what you've named your server. But I don't know exactly, I won't work with IIS.

    Tell your boss to get a grip. The linux box will do what you want just as fast as the newer Win2k box.
  4. #3
  5. No Profile Picture
    I AM A GOLDEN GOD
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Apr 2003
    Location
    Camarillo, California
    Posts
    5,929
    Rep Power
    1170
    This is a PHP problem, not MySQL. You've obviously used 'localhost' in such a way that PHP treats it as a constant.

    Show us the relevant portion of the script.

    Suggestion - turn off register_globals and learn to work without global vars.
  6. #4
  7. Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    449
    Rep Power
    0
    1. My boss works offsite to me (his tech guy) and he cant use linux. So he must use a win machine to edit and use the db.
    (Dont worry, I am a Linux Nazi too... but the simple fact is, you cant ask someone to learn a completely new os because YOU / I dont like the one they are familiar with)

    2.
    PHP Code:
    mysql_pconnect(localhost"user""password");
        
    mysql_select_db("databasename"); 
    is the problem line containing "localhost"

    is the code that has the problem line "localhost"


    3. Turning global vars off creates MUCH more problems.

    4. This has been copied directly from a working version on a linux box. What are the differences to a win ver.?

    5. The page that you come to when you open the address localhost in your browser has a db line on it and that line IS there. (That is to say there is a line extracted from the db on the first page and it DOES work. So I assume I can talk to the db ok.)

    6.
    PHP Code:
    Undefined variableuser_id in c:\inetpub\wwwroot\auth.php on line 5 
    is the line I get when I turn off "register_globals".

    7. I also get
    PHP Code:
    WarningUnknown(): Your script possibly relies on a session side-effect which existed until PHP 4.2.3Please be advised that the session extension does not consider global variables as a source of dataunless register_globals is enabledYou can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to offrespectivelyin Unknown on line 0 
    when I turn off "register_globals"
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    Cambridgeshire, UK / Marbella, Spain
    Posts
    81
    Rep Power
    15
    the error is telling you to put quote marks round localhost. Have you tryed that????

    PHP Code:
    mysql_pconnect("localhost""user""password"); 
  10. #6
  11. Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    449
    Rep Power
    0
    ok.. getting closer.. the "localhost" advice seemed to work. thanks
    now i am getting... (which I was before too)

    "Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in c:\inetpub\wwwroot\auth.php on line 87"

    I know what this error means but cant work out why.
    I can use the CLI and the db works fine.
    In my.ini I have set log=C:/mysql/sql.log ans the queries are being executed fine.

    So... db is working, php is working, php & Mysql is not working... ????

    (depressing.. I was just starting to think I new what I was talking about.... doh)
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    Cambridgeshire, UK / Marbella, Spain
    Posts
    81
    Rep Power
    15
    can you post the line of code where the error lies. If you said it worked before changing to iis it should be no problem, but i'll just check
  14. #8
  15. Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    449
    Rep Power
    0
    PHP Code:
            $fort mysql_query("SELECT fortune FROM fortune ORDER BY RAND() LIMIT 1");
            list(
    $fortune) = mysql_fetch_row($fort); 
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    Cambridgeshire, UK / Marbella, Spain
    Posts
    81
    Rep Power
    15
    Is there a rows of data returned by the query or is it null? ie, there is atleat one row of data in your fortune table
  18. #10
  19. Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    449
    Rep Power
    0
    there IS several rows of data in the fortune table
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    Cambridgeshire, UK / Marbella, Spain
    Posts
    81
    Rep Power
    15
    well the code is fine.
    1. is this there any other errors from other queries on the page?
    2. if there are other queries, are you getting the expected result on the page
  22. #12
  23. No Profile Picture
    I AM A GOLDEN GOD
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Apr 2003
    Location
    Camarillo, California
    Posts
    5,929
    Rep Power
    1170
    My boss works offsite to me (his tech guy) and he cant use linux. So he must use a win machine to edit and use the db.
    Why? Install PHPMyAdmin on the linux box, or give him shell access to the box. It's irrelevant to his usage that he has it on one machine or the other.

    Turning global vars off creates MUCH more problems.
    That's because your code as-is depends on global vars. It can cause MUCH more problems having register_globals on, but that's your call, not mine.


    PHP Code:
    $fort mysql_query("SELECT fortune FROM fortune ORDER BY RAND() LIMIT 1");

            list(
    $fortune) = mysql_fetch_row($fort); 
    Your code and SQL syntax looks fine, although your usage of list and mysql_fetch_row is incorrect; if all you have is one record to grab, use mysql_result().

    Aside from that, do you know if you have a valid connection? Change your code to look something like this:
    PHP Code:
    mysql_connect("localhost""user""pass") OR die("Connect error: " .mysql_error());
    mysql_select_db("database") OR die("DB select error: " .mysql_error());
    $sql "SELECT field FROM table LIMIT 1";
    echo 
    $sql// just for troubleshooting
    $result mysql_query($sql) OR die("Query error: " .mysql_error());
    echo 
    mysql_result($result0'field'); 
    So you have an error output for each step in the process, and you know what the problem is. Just giving 'mysql_fetch_row(): supplied argument is not a valid MySQL result resource' - there can be one of several things wrong with that...
    "Seriously, we're not a search engine, we're actual people." ~ ManiacDan

    BookMooch.com : Give books away. Get books you want.
  24. #13
  25. Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    449
    Rep Power
    0
    it is a login page with a "quip" (quote) on the page.
    The quip doesnt show (that is the fortune query) and the login doesnt work.
    So I assume all queries are not working.

    As I said. If I use a command line for the mysql query and enter it dorectly into mysql manually, I get the desired result.

    It is only via php that it breaks.

    My php page shows correctly in the browser so I assume php is pretty much working, the mysql works manually so I assume mysql is working... its just when the two have to work together that I get the probs.
  26. #14
  27. Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    449
    Rep Power
    0
    SELECT fortune FROM fortune LIMIT 1Query error: select command denied to user: 'user@localhost' for table 'fortune'



    Thanx Inxgeek.... now I know I havent given access to the user on the db.
  28. #15
  29. No Profile Picture
    I AM A GOLDEN GOD
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Apr 2003
    Location
    Camarillo, California
    Posts
    5,929
    Rep Power
    1170
    Something else I just noticed, your use of mysql_pconnect(); it may very well be that mysql.allow_persistent is turned 'off' in your php.ini file and thus not allowing you to connect.

    IMHO you're just as well off use mysql_connect() for all your connections.
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo