LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   mysql / php (https://www.linuxquestions.org/questions/linux-general-1/mysql-php-340738/)

I_AM 07-06-2005 06:15 PM

mysql / php
 
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
include("_private/data.php");

$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());

mysql_close($conn);

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:

include("_private/data.php");

$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());

mysql_close($conn);

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.

TO RECAP:
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)

rose_bud4201 07-06-2005 06:54 PM

I've never found phpMyAdmin to be all that wonderful, really...it could be a config problem, but since it did indeed find the original two records, it looks like it is accessing the database at least.
Is there an output/logfile for it anywhere, that you could check?

It sounds like your php scripts are doing the job, though!

thermite_1033 07-07-2005 04:18 AM

i think you're forgetting to commit the changes made by your script


All times are GMT -5. The time now is 07:42 AM.