Koozali.org: home of the SME Server

Can't seem to write to my mysql database

makamum

Can't seem to write to my mysql database
« on: June 26, 2005, 04:05:29 PM »
OK guys,  SME 6.1, pretty much a clean install.  I'm trying to learn more about php and mysql.  I've installed the phpmyadmin from nightspirit's contrib.  I can create databases, tables, users, enter data into the tables (via phpmyadmin) but when I write a script in php to enter the data into the database I get nothing. It acts as if the data was written to the db but it wasn't.  I can read data previously written into the table via phpmyadmin fine. I can also pull data from the database and display it via php fine. It seems to be a permission issue but I can't find anything. Is there anything I have overlooked?  Would one of the Great and Allpowerfull SME Gods smile down on me and help me with my problem?

gardnc

Can't seem to write to my mysql database
« Reply #1 on: June 26, 2005, 11:32:46 PM »
makamum,

phpMyAdmin (in SME) uses the mysql root user/password and so can mask problems with ordinary users.  Because you sppecify you can run mysql queries in php code, and get valid results, I have to assume you have established the permissions for a user and related the user and permissions to a particular server/IP.

In the permissions forms in phpMyAdmin, you want to be sure not to give regular users any "global" permissions, but instead pick the database(s) you want to give the user access to, and then to write in the data base be sure they have insert and update permissions under the Data section.

If you still can't write to the database, you will need to capture the mysql error provided as a result of the query and either look it up or post it here for someone to help with.

makamum

Can't seem to write to my mysql database
« Reply #2 on: June 27, 2005, 04:43:07 AM »
Thanks for the reply Gardnc,
I've gone back to writing a basic php script that just pokes information into a table every time I run it.  
<?php
//connect to the database
$dbcnx = mysql_connect("localhost", "username", "password") or die
('Could not connect to the db server:' . mysql_error() );
mysql_select_db (test) OR die ('Could not select the database: ' . mysql_error() );
$query ="INSERT INTO testtable (name) values ('jeff')";
$result = @mysql_query ($query);
?>

It is working!

I've been working out of Larry Ullman's PHP and MySql book and I  can't even get one of his scripts to work.  Don't get me wrong,  the book is great.  Looks like the problem may be a short between the keyboard and the chair.  
Thanks again