473,404 Members | 2,195 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

mysql user

Hello,
I'm trying to create my first php app, and i want it to get it's data
via a mysql database. In the app i've got a connection file that defines my
database information and as the mysql root user i did:
grant all on app.* to appuser@localhost identified by 'password';
this did not return an error. My appuser can connect to mysql using
commandline mysql but when i try to use a form to insert data my built-in
error checks are not tripped leading me to believe that insertion was
successful, but again from commandline mysql i do a
select * from table;
i get an empty set returned. Any help appreciated.
Thanks.
Dave.
Jul 20 '05 #1
3 1371
dave wrote:
grant all on app.* to appuser@localhost identified by 'password';
I see nothing wrong with the grant syntax.
this did not return an error. My appuser can connect to mysql using
commandline mysql but when i try to use a form to insert data my built-in
error checks are not tripped leading me to believe that insertion was
successful, but again from commandline mysql i do a
select * from table;
i get an empty set returned. Any help appreciated.


A little more information would be nice.

echo the queries you are using to insert data and copy-paste those here.
Also from mysql command line, give command "desc yourtablename" which
will give information about the table structure, copy-paste that also here.

Also you could copy-paste the line(s) which you are using to establish
connection to database (and select the database, in case you are doing
that on another line), to make sure there's no error in there.
Jul 20 '05 #2
Hello,
Thanks. Here is the additional information.
For the below information i've changed the databasename, username, and
password and the $values are passed via a form.

mysql_connect ('localhost', 'databaseuser', 'databasepassword') ;
mysql_select_db ('database');

$sql = "INSERT INTO databasetable (timestamp,title,entry) VALUES
('$timestamp','$title','$entry')";
$result = mysql_query($sql) or print ("Can't insert into table
databasetable.<br />" . $sql . "<br />" . mysql_error());

if ($result != false)
{
print "Your entry has successfully been entered into the database!";
}

mysql_close();
}

?>

Here's my table structure:

mysql> desc databasetable;
+-----------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+----------------+
| id | int(20) | | PRI | NULL | auto_increment |
| timestamp | int(20) | | | 0 | |
| title | varchar(255) | | | | |
| entry | longtext | | | | |
+-----------+--------------+------+-----+---------+----------------+
4 rows in set (0.00 sec)

Hope this helps.
Thanks.
Dave.
Jul 20 '05 #3
dave wrote:
mysql_connect ('localhost', 'databaseuser', 'databasepassword') ;
mysql_select_db ('database');
If you didn't change the values for your grant-clause (below)
grant all on app.* to appuser@localhost identified by 'password';


That should be:
mysql_connect ('localhost', 'appuser', 'password') ;
mysql_select_db ('app');

I actually tested your code on my computer (with minor changes), and it
inserted the row correctly into database and I was able to view it from
console.

You could try this code on your computer to see if it works: ( Change
the database, username and password if you used different values in your
grant. )

<?php
$timestamp = 5;
$title = "title";
$entry = "testest";

mysql_connect ('localhost', 'appuser', 'password') ;
mysql_select_db ('app');

$sql = "INSERT INTO databasetable (timestamp,title,entry)
VALUES('$timestamp','$title','$entry')";
$result = mysql_query($sql) or print ("Can't insert into table
databasetable.<br />" . $sql . "<br />" . mysql$

if ($result != false)
{
print "Your entry has successfully been entered into the database!";
}

mysql_close();
?>
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mark Adams | last post by:
I am a relative newbie to MySQL. I had a Postfix+Courier+MySQL mail server running for several months. It took me a week or so to get it up and running in September. Now, I did a clean upgrade to...
0
by: Mark Adams | last post by:
I really need some help with this. MySQL will not start on boot despite everything I've done to make sure that it is set to do so. When I start it as root from a terminal with...
0
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest...
4
by: Adam Smith | last post by:
I have a dedicated server running 'FreeBSD 4.9 STABLE' at a hosting site. They have done some default installations, presumably from the CVS ports package ??. Herein lies the problem, "I do not...
0
by: ./Rob & | last post by:
Hi gang: I'm experiencing a problem with MySQL -- I updated MySQL from version 4.1.0 to 4.1.10 and now when I login as root it doesn't show all the databases I should have access to, nor it...
5
by: MLH | last post by:
I'm supposed to set a password for the MySQL root user. The output of mysql_install_db instructed me to run the following commands... /usr/bin/mysqladmin -u root -h appserver password mynwewpasswd...
8
by: sundeep.kumara | last post by:
hi all, I am a newbie .....I have compiled the source code of mysql-4.1.9 on PPC-Linux Its not giving any errors during configure,make or make install. But,when i try to start the server...
6
Atli
by: Atli | last post by:
This is an easy to digest 12 step guide on basics of using MySQL. It's a great refresher for those who need it and it work's great for first time MySQL users. Anyone should be able to get...
39
by: alex | last post by:
I've converted a latin1 database I have to utf8. The process has been: # mysqldump -u root -p --default-character-set=latin1 -c --insert-ignore --skip-set-charset mydb mydb.sql # iconv -f...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.