I am getting the following error when I use mysql_query() in PHP.

"Call to undefined function: mysql_query() "

This is using the basic connection stuff I have used on my outside host so I know the syntax is correct.

I have recently set up a box with RH Linux 8.0 and installed Apache (v2.0), PHP (v4.2.2) and mySQL (v3.23.52) from the RPM. I can access mySQL fine from the terminal and I don't seem to get an error when I connect, but as soon as I hit the mysql_query call it chokes.

Since I'm a total newbie with Linux I am hoping I don't have to rebuild and reinstall anything because I don't really know my way around yet. Is this possibly due to something set incorrectly in the php.ini file?

One thing might be the path to one of the necessary files is not right. It seems that the guy who did the install for me put it all on one partition and I am not finding things in the usual paths. Maybe you could tell me what to look for.

TIA

-Labrat

    you shouldn't have to reinstall anything. it may be the variables inside your mysql_query() statement. Post some code...

      OK...

      I have run the query from the terminal and it works fine. From the error message I was thinking that whatever module that houses that function "mysql_query()" wasn't working or recognized properly. I just don't know if it's something I can fix in a configuration file or if it's something to do with the installation.

      Another thing I noticed in some other posts is that the mysql_select_db function takes both the db name and the connection variable which I obviously don't have here. I will try that when I get back home but any insight would be appreciated.

      $dbcnx = @mysql_pconnect("localhost", "root", "password");
      if (!$dbcnx)
      {
        echo "Error: Could not connect to database.  Please try again later.";
        exit;
      }
      mysql_select_db("mk");
      $query = "select cate_id, cate_name from category order by cate_name";
      $result = mysql_query($query);
      

        OK, I made this simple test and it didn't work either.

        Here is some text<br>
        The php should be here: <br>
        <p>
        <?php   
        $dbcnx = mysql_connect("localhost", "root"); if (!$dbcnx) { echo "Error: Could not connect to database. Please try again later."; exit; } //end if ?>

        I get the error:
        "Fatal error: Call to undefined function: mysql_connect() in /home/xxxx/public_html/test_mysql.php on line 13"

        So it really looks like a problem with my set up, I'm guessing.

        How can I fix this?

        TIA
        -Labrat

          The connect string doesn't need to be in there, but if you have multiple connections going, that will bind it to a specific connection string. When I get to work tomorrow I'll try your scripts.

            Write a Reply...