Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

mysql issue with database/script

Discussion in 'General Discussion' started by Secret Agent, Jul 6, 2005.

  1. Secret Agent

    Secret Agent Guest

    I ran a few php scripts with requests to the MySQL database and found that my records were indeed being added. The problem lies in the web client you have for reading the MySQL databases (phpMyAdmin). That client wasn't being updated, so, for example, I kept adding test records to my "Products" table, but any test I tried in phpMySQL revealed that I only had 2 records (what I started with). I ran a php script and found that I actually had more than 10 records in that table.

    I have created a simple php script:

    //Adding the product to the database

    $conn = mysql_connect($servername, $username, $password); mysql_select_db("bhsadmin_BlueHighwayData", $conn);

    $sql = "INSERT INTO Products values ('', '$_POST[prodname]', '$_FILES[downloadfile][name]', '$_FILES[screenshot][name]', '$_FILES[thumbnail][name]', '$_POST[filename]')";

    $result = mysql_query($sql, $conn) or die(mysql_error());


    The main point is the $sql variable, which gives the MySQL command.
    Everything, parameter-wise, matches up (it's a valid request). Now, I run that with the appropriate variables (from the appropriate form) and it seems to add correctly. In fact, when I echo out $result, it echos out "1", meaning the request went through with no problems. Now, I go to phpMyAdmin and it still states that I have only 2 records in Products (which is what I started with). I ran this script a few times and it still said I had only 2 records. Then, I ran another php script:


    $conn = mysql_connect($servername, $username, $password); mysql_select_db("bhsadmin_BlueHighwayData", $conn);

    $sql = "SELECT * FROM Products WHERE 1";

    $result = mysql_query($sql, $conn) or die(mysql_error());


    while ($Array = mysql_fetch_array($result)) {
    echo $Array['name'];

    When I run THAT, it gives me all my records (meaning it lists the 'name'
    field of all the records). It gives me my 2 original records, plus all the other test ones I've added. Additionally, I ran "SELECT * FROM Products WHERE 1" within phpMyAdmin (in the built-in interface to run MySQL requests). When I run that within phpMyAdmin, it only gives me my original two records.

    1. phpMyAdmin only recognizes my 2 original records 2. Running MySQL requests in PHP scripts that are working correctly, reveal that I have more than 2 records in my database.

    CONCLUSION (At least the only one I can see):
    phpMyAdmin is not reading the MySQL database correctly.

    What could cause this exactly? Script config, phpmyadmin itself, etc?

    WHM 10.1.0 cPanel 10.2.0-C89
    Centos 3.5
    phpMyAdmin 2.6.1-pl2
    mysql (4.1.11-standard)

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice