473,325 Members | 2,805 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,325 software developers and data experts.

Insert Query through PHP does not insert data into MySQL Table

3
I am using the following code. Why it does not insert record in the MySQL Table through php script:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $dbhost='localhost';
  3. $dbuser='root';
  4. $dbpass='newpass';
  5. $mysqldb='mysql';
  6.  
  7. if(isset($_POST['add'])){
  8.  
  9. $username=$_POST['username']; // echo test for $username is OK
  10. $password=$_POST['password']; // echo test for $password is OK
  11.  
  12. $conn=mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting MySQL'); mysql_select_db($mysqldb) or die ('Error connecting database');
  13.  
  14. $query = "INSERT INTO user (host, user, password, select_priv, insert_priv, update_priv) VALUES ('localhost', '$username', PASSWORD ('password'), 'Y', 'Y', 'Y')";
  15.  
  16. //more code to close database and html form
  17. ?>
Plz help me regarding this.

Regards
Dec 9 '07 #1
2 2113
pbmods
5,821 Expert 4TB
Heya, Servo.

You need to execute your query using mysql_query().

Please use CODE tags when posting source code:

[CODE=php]
PHP code goes here.
[/CODE]
Dec 9 '07 #2
pbmods
5,821 Expert 4TB
While you're at it, check out this article for more information on creating MySQL User accounts.
Dec 9 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: Jack | last post by:
I have a text file of data in a file (add2db.txt) where the entries are already entered on separate lines in the following form: INSERT INTO `reviews` VALUES("", "Tony's", "Lunch", "Great...
0
by: Alexander Newald | last post by:
------=_NextPart_000_003E_01C34934.FBC032B0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Hello, I'm looking for a solution to write a sql...
11
by: Randell D. | last post by:
Folks, I have a table of addresses and a seperate table with contact names - All addresses tie to one or more names - I would like to keep track of the number of names 'belonging' to an address...
0
by: Rajesh Kapur | last post by:
I have a master slave configuration on linux machines running MySQL 4.0.21. Once every hour, a process deletes about 9000 rows and re-inserts fresh data on the master. The master process completes...
10
by: Python_it | last post by:
Python 2.4 MySQL-python.exe-1.2.0.win32-py2.4.zip How can I insert a NULL value in a table (MySQL-database). I can't set a var to NULL? Or is there a other possibility? My var must be variable...
9
by: David Eades | last post by:
Hi all Complete newbie here, so apologies if this is the wrong forum. I've been asked to use mysql and asp to make a simple bidding system (rather like a simple ebay), whereby users can use a...
5
by: Bonzol | last post by:
Hello, PHP n00b here. Using SQL just working off some examples, I have no problem selecting data, but I cant seem to be able to insert. If someone could see where im going wrong <!DOCTYPE...
14
by: Ben | last post by:
I don't know whether anyone can help, but I have an odd problem. I have a PSP (Spyce) script that makes many calls to populate a database. They all work without any problem except for one...
7
by: dongletran06 | last post by:
Hi, Please help me find out what wrong with my codes in inputting from my form to mysql database using drop down menu. Below is the codes I used. Only the drop down is not working but the "input...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.