LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-06-2005, 06:15 PM   #1
I_AM
Member
 
Registered: Mar 2005
Posts: 103

Rep: Reputation: 15
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)
 
Old 07-06-2005, 06:54 PM   #2
rose_bud4201
Member
 
Registered: Aug 2002
Location: St Louis, MO
Distribution: Xubuntu, RHEL, Solaris 10
Posts: 929

Rep: Reputation: 30
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!
 
Old 07-07-2005, 04:18 AM   #3
thermite_1033
Member
 
Registered: May 2004
Location: Antwerp, Belgium
Distribution: slackware
Posts: 112

Rep: Reputation: 18
i think you're forgetting to commit the changes made by your script
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
mysql-server4.1 and mod php-mysql conflig kernelvn *BSD 0 06-18-2005 11:52 AM
Problem getting PHP to recognize MySQL, Using PHP 4.0 and MySQL 4.0.20 d2army Programming 4 06-27-2004 08:54 PM
php4 mysql, installation, php-pages with mysql info stay empty dnla Linux - Software 2 03-14-2004 02:54 PM
Installing MySQL.4.0.17 and php support for Mysql on RedHat 9.0 Neha Linux - Software 13 12-29-2003 12:06 AM
Apache Mysql Php: mysql with php doesn't work breakerfall Linux - Networking 6 12-27-2003 08:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration