I Have A Screwball PHP Problem (Resolved...Sort Of)

17 replies
I know enough PHP to be dangerous. I am no expert, but I can do some
basic stuff.

Anyway, here's the problem.

I have a script that I created on a server that I've been using for several
years now. It works fine.

I wanted to take the script and move it over to another server on another
host, create an identical table and run it for another domain.

The code on both is identical. Yet, on the new server, I get the following
error:

Warning: extract() [function.extract]: First argument should be an array in /home/xxxxx/public_html/track.php on line 27

Now, I know what the problem is.

It's here:

$row=mysql_fetch_array($result);
extract($row);

$result is coming back empty. It shouldn't. I've gone over the whole code
and even put in echo test prints throughout the whole thing.

Bottom line: Things are not getting retrieved from the database.

Given that the code is the same, I then looked at my PHP version on
each. They say they're the same BUT... I am getting the following
differences in the server versions.

The one that works:

Server version: 5.0.67-community

The one that doesn't work

Server version: 5.0.51a-community

Everything else, including the MySQL version (4.1.22) is the same.

I have gone over everything. It's the only variable between the two
setups as the code is identical. It just won't run on the other server.

So...I have to figure out what changes I have to make in order to get
this code to work.

I don't even know where to begin.

I learned PHP 4 (I think 4.14 but not sure, been so long), it's what I am
using, and I don't know what I have to change the syntax of anything
(or everything) on my new server.

If somebody has a QUICK thing that I can look at, just throw some
suggestions in this thread.

Thanks.
#php #problem #screwball
  • Profile picture of the author Steven Fullman
    Steve,

    My guess. New server, therefore new (or restored) database.

    Different schema, somehow?

    Steve
    Signature

    Not promoting right now

    {{ DiscussionBoard.errors[375665].message }}
  • Profile picture of the author KirkMcD
    Most likey you have a different database and database login names, since you moved it to a different server.
    Verify the connection information in the script.
    {{ DiscussionBoard.errors[375676].message }}
  • Profile picture of the author zapseo
    so you ran phpinfo, Steven, and ALL the settings are the same ?

    Yep, Kirk -- that would definitely do it ... though usually php spits out an error
    saying it can't connect to the database...

    but those error messages have been known to get lost in the graphics ....
    and otherwise not seen.

    Check the error log file Steven?
    {{ DiscussionBoard.errors[375677].message }}
  • Profile picture of the author TheRichJerksNet
    Steven,
    Have you checked your database connection ??? User/pass

    Also I would XXXX out my server username there..

    James
    {{ DiscussionBoard.errors[375685].message }}
    • Profile picture of the author Steven Wagenheim
      yeah guys, I checked to make sure I'm connecting.

      $conn=mysql_connect("localhost","xxxxx_xxxxx","xxx xx") or die ("Not connected to database server");

      echo($conn);

      I removed the actual user name and password info here, but it's right and
      I am connecting.

      This is the most bizarre thing I have ever seen. I have gone through this
      line by line and can't understand why when it goes to pull the array it's
      coming up empty.
      {{ DiscussionBoard.errors[375691].message }}
  • Profile picture of the author Johnny Slater
    Steve.. gotta ask.. did you move the database to the new server? In other words is it trying to search an empty database or are you sure there is actually data there?
    Signature

    {{ DiscussionBoard.errors[375695].message }}
    • Profile picture of the author Steven Wagenheim
      Originally Posted by Johnny Slater View Post

      Steve.. gotta ask.. did you move the database to the new server? In other words is it trying to search an empty database or are you sure there is actually data there?
      Johnny, I actually just set up a whole new setup on the new server.

      Created the database, table, fields, everything.

      I made sure everything is identical.

      And like I said, it runs on the original server with my old host. It isn't
      running on the new host.

      I'm doing a line by line comparison to see if maybe copying it over (the
      PHP code) I might have hit a key or something that screwed a piece of
      the code up, but nothing.

      By all rights, this should work.
      {{ DiscussionBoard.errors[375703].message }}
      • Profile picture of the author Steven Wagenheim
        Know what? Heck with it. I'll just run it on the old domain and do a redirect
        from the new domain to access it.

        I wanted to use my new domain for tracking code but I can still do it. All
        I have to do is create a PHP code to redirect to the old URL which
        redirects to the page it's going to.

        The only thing I don't like about this setup is that both domains have to be
        up and running. If either one goes down, the script won't run. But it beats
        knocking my brains out trying to figure out why something that should work
        doesn't work.

        Thanks for all your suggestions.
        {{ DiscussionBoard.errors[375725].message }}
      • Profile picture of the author zapseo
        Dang!

        Going over 2 pieces of source code line-by-line???

        You need to learn some unix utilities.

        Like diff.

        FAR more reliable than human beings for detecting source differences.

        Didn't get an answer to the phpinfo question, though.

        <? echo phpinfo(); ?>

        run on each server -- compare the output...

        Or send both pages to me and I'll run diff for you.

        Comparing anything line by line sounds too painful for words.

        (don't, of course, leave the phpinfo(); script around where someone else can run it. For your eyes only.)

        Which version of php are you ACTUALLY running.

        Many servers have the option of running different versions.

        With that error -- it suggests that perhaps
        $result should be $result[] or something like that.
        But my php is pretty rusty.

        Or maybe $result needs to be declared as an array.

        Seems to me these were some of the differences between running
        php4 & php5 -- but I could be wrong!
        {{ DiscussionBoard.errors[375730].message }}
  • Profile picture of the author TheRichJerksNet
    Steven,
    Do you have error checking on ? Also have you checked your error logs ?

    Because that error indicates you either have a connection problem or there is no data..

    Edited to add:

    Steven Please Remove Your Server Username From Your Post

    Warning: extract() [function.extract]: First argument should be an array in /home/XXXXXX/public_html/track.php on line 27


    James
    {{ DiscussionBoard.errors[375698].message }}
  • Profile picture of the author derrickp
    Steven,

    Check if the new server is running phpsuexec

    Derrick
    Signature

    Slime England

    {{ DiscussionBoard.errors[375746].message }}
    • Profile picture of the author Steven Wagenheim
      Originally Posted by derrickp View Post

      Steven,

      Check if the new server is running phpsuexec

      Derrick
      Thanks Derrick, but it's not worth the hassle. I'm just going to run a redirect
      to the old server and be done with it.

      No sense fixing what ain't broken.
      {{ DiscussionBoard.errors[375756].message }}
    • Profile picture of the author zapseo
      Originally Posted by derrickp View Post

      Steven,

      Check if the new server is running phpsuexec

      Derrick
      Or its brothers & sisters whose names I've already forgotten, but some of whom are superior!

      The differences in how things work when running under phpsuexec are significant enough that you may well want to know about them....

      It took me months to get kiosk to resolve sendmail issues they introduced when they changed over to phpsuexec. I'm still not sure it all works right.
      {{ DiscussionBoard.errors[375770].message }}
  • Profile picture of the author Nato Guajardo
    That's why I don't deal with stuff like this. I rather just pay someone.

    I'm surprised you don't outsource this since you make over $20k/month.
    {{ DiscussionBoard.errors[375773].message }}
    • Profile picture of the author Steven Wagenheim
      Originally Posted by Nato Guajardo View Post

      That's why I don't deal with stuff like this. I rather just pay someone.

      I'm surprised you don't outsource this since you make over $20k/month.
      Nate, it's a script I wrote myself 6 years ago when I first started. It was
      pretty much after I graduated from web programming school. There was
      no need to outsource it since I wrote it during a time when I had no
      money to outsource, and I didn't need to. I knew I could handle it.

      Technically, it should be a simple matter of just transferring it over to
      the new server, but since the PHP versions are different, not the case.

      Since I can still run it on the old server, why pay somebody to do
      something that's not an absolute emergency?

      Thus, I didn't outsource it.

      Hope this clears that up.
      {{ DiscussionBoard.errors[375779].message }}
      • Profile picture of the author TheRichJerksNet
        Originally Posted by Steven Wagenheim View Post


        Technically, it should be a simple matter of just transferring it over to
        the new server, but since the PHP versions are different, not the case.
        It would be simple if both servers are the same .. Not running the same Php but are they running the same ext and etc .. For example if one has Apache compiled with SuExec and the other one don't then there is a huge different in how these servers runs..

        James
        {{ DiscussionBoard.errors[375821].message }}
        • Profile picture of the author TheRichJerksNet
          Steven,
          Download this phpinfo file and unzip and upload the file to each server.. Then go to yourdomain.com/phpinfo.php and compare to see if both servers are the same ..

          The reason being is you may need to actaully set permissions, this all depends upon how the build is done on the server...

          James
          {{ DiscussionBoard.errors[375830].message }}
          • Profile picture of the author Steven Wagenheim
            Originally Posted by TheRichJerksNet View Post

            Steven,
            Download this phpinfo file and unzip and upload the file to each server.. Then go to yourdomain.com/phpinfo.php and compare to see if both servers are the same ..

            The reason being is you may need to actaully set permissions, this all depends upon how the build is done on the server...

            James
            James, the Apache versions are different.

            One is 2.2.9 (works)

            One is 2.2.11 (doesn't work)

            I'll go through all the rest of the variables and see if anything looks like
            it could be the problem.
            {{ DiscussionBoard.errors[375841].message }}
            • Profile picture of the author zerofill
              And put

              error_reporting(E_ALL);

              At the beginning of your php file right under <?php
              So you can see all the errors heh
              Signature
              Serp Shaker
              The IM World Will Be Shaken to the Core!
              Join my list at: IMCool.Biz
              New Podcast --> podcast.imcool.biz
              {{ DiscussionBoard.errors[375856].message }}
            • Profile picture of the author Steven Wagenheim
              Originally Posted by Jeff Hope View Post

              Maybe the new server isn't using "localhost" for the MySQL server connection. Rare, but it happens.
              Thanks Jeff. I just checked. It does.
              {{ DiscussionBoard.errors[375864].message }}
  • Profile picture of the author zerofill
    Like what you are hearing from James and Johnny Steven...

    2 possibilities...

    1) Your connection info is wrong for the new database thus no data can be returned...

    2) You have no data in the new database...Thus...nothing is being returned hehe

    That is about the only 2 reasons that come to mind on why you would see that...I would bet on #2 hehe
    Signature
    Serp Shaker
    The IM World Will Be Shaken to the Core!
    Join my list at: IMCool.Biz
    New Podcast --> podcast.imcool.biz
    {{ DiscussionBoard.errors[375789].message }}
    • Profile picture of the author Steven Wagenheim
      Originally Posted by zerofill View Post

      Like what you are hearing from James and Johnny Steven...

      2 possibilities...

      1) Your connection info is wrong for the new database thus no data can be returned...

      2) You have no data in the new database...Thus...nothing is being returned hehe

      That is about the only 2 reasons that come to mind on why you would see that...I would bet on #2 hehe
      Hey Don, I thought that too, so I set the values in the tables for
      the fields I'm testing and it still comes back zip. So yeah, it's not
      connecting but it's not giving me a no connect error and I can't figure
      out WHY it's not connecting. I mean duh...connecting to a database
      is PHP 101.
      {{ DiscussionBoard.errors[375818].message }}
  • Profile picture of the author TheRichJerksNet
    Steven,
    Your main domain is running hostgator which I can almost promise you your server runs PhpSuExec, which for one does not require any type of 777 permissions, it also changes the servers ownership..

    By default most servers not running SuExec the servers ownership is "root" but running a server with SuExec the server ownership would be the username of the server, which is what it should be.

    This is why it is important for you to turn on error reporting because there maybe several differences in your servers and error reporting will be able to tell you much faster and easier..

    James
    {{ DiscussionBoard.errors[375882].message }}
    • Profile picture of the author Steven Wagenheim
      Originally Posted by TheRichJerksNet View Post

      Steven,
      Your main domain is running hostgator which I can almost promise you your server runs PhpSuExec, which for one does not require any type of 777 permissions, it also changes the servers ownership..

      By default most servers not running SuExec the servers ownership is "root" but running a server with SuExec the server ownership would be the username of the server, which is what it should be.

      This is why it is important for you to turn on error reporting because there maybe several differences in your servers and error reporting will be able to tell you much faster and easier..

      James
      Well, you're into an area now that's beyond me and like I said, this just
      isn't worth spending any more time on.

      But thanks for the help.
      {{ DiscussionBoard.errors[375888].message }}
  • Profile picture of the author TheRichJerksNet
    You aint getting off that easy Steven ..lol

    Hey hostgator auto generates error_log files in ftp .. Check your ftp for error_log and see what errors are reported..

    James
    {{ DiscussionBoard.errors[375891].message }}
    • Profile picture of the author Steven Wagenheim
      Originally Posted by TheRichJerksNet View Post

      You aint getting off that easy Steven ..lol

      Hey hostgator auto generates error_log files in ftp .. Check your ftp for error_log and see what errors are reported..

      James
      Okay James, I checked the error log...nada.

      According to everything I've checked, this thing should be running fine.
      {{ DiscussionBoard.errors[375902].message }}

Trending Topics