473,320 Members | 1,846 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,320 software developers and data experts.

i m trying to insert data in mysql with php but afther writen code data not submited

1
Expand|Select|Wrap|Line Numbers
  1. <html> <head><title>my form</title></head> <body bgcolor="gray"> <br><br><br><br><br><br> <dive align="center"> <form method="post" action="<?php $_php_self?>">
  2. username<input type="text" name="username"><br />
  3. email<input type="text" name="email"><br /> <input type="submit" name="submit"> </center> </body> </html> <?php
  4.  
  5. if(isset($_POST['submit']));
  6. {
  7. $username=$_POST['username'];
  8. $email=$_POST['email'];
  9.  
  10. /*variable define to the server and host*/
  11.  
  12. $localhost="localhost";
  13. $username="root";
  14. $password="";
  15. $tbl_name="user_values";
  16. /*connect to the database*/
  17. $con=mysql_connect('localhost','root','','user_values') or die("cannot connect");
  18. $find_db=mysql_select_db("os_1",$con)or die("cannot connect DB");
  19.  
  20. /*get values form form*/
  21. $name=$_POST['username'];
  22. $email=$_POST['email'];
  23. /*insert values html form to mysql database*/
  24.  
  25. mysql_query("INSERT INTO user_values 
  26. (u_name, email, pwd) VALUES('username', 'email' ) ") or die(mysql_error());  
  27.  
  28. echo "Data Inserted!";
  29.  
  30. }
  31.  
  32.  
  33.  
  34. ?>
Aug 27 '13 #1
3 1119
Exequiel
288 256MB
its not working because the pwd didnot determin in your insertion, you didnot put the value for pwd, try to put the value for pwd, like this code. . .
Expand|Select|Wrap|Line Numbers
  1. mysql_query("INSERT INTO user_values 
  2. (u_name, email, pwd) VALUES('username', 'email', 'yourpwd') ") or die(mysql_error());
Aug 28 '13 #2
Ammu
78
in your insert query where is the value for the field "pwd"?
and you get posted values to $name and $email.
so your code should be like this

Expand|Select|Wrap|Line Numbers
  1. $pwd = $_post[''];
  2. mysql_query("INSERT INTO user_values 
  3. (u_name, email, pwd) VALUES('$name', '$email' ,'$pwd' ) ") or die(mysql_error()); 
  4.  
Aug 28 '13 #3
Please do not post your DB user name and password in public forum.
Aug 28 '13 #4

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

Similar topics

2
by: Brett B | last post by:
I just installed mysql on linux. If I open a terminal, su to root, then type "mysql", I am able to connect to the server and run my queries. If I exit out of su so that I am my own id (baisley)...
2
by: pmud | last post by:
Hi, I am exporting data from an EDITABLE DATA GRID EXCEL. But the 1st column in data grid is Edit Column. I want to display all columns in Excel except for the Edit column. The following...
0
by: http://www.visual-basic-data-mining.net/forum | last post by:
Looking for data mining algorithms like Naive Bayes, Neural Networks, Apriori, Genetic Algorithms, Clustering, Decision Trees source code implementations in Visual Basic.NET. Can you please post a...
1
by: surya | last post by:
hi sir i have table hh .it has two columns one is hhno is integer datatype another hhdoc is xml data type like hh table hhno hhdoc ------------...
8
by: Garry | last post by:
How do I cycle through a MySQL query result one row at a time so that I can do some work on each individual row, instead of having the whole query scroll by. I need to have the ability to post...
10
by: simon.hibbs | last post by:
Lets say that I have an application consisting of 3 files. A main.py file, gui.py and a data.py which handles persistent data storage. Suppose data.py defines a class 'MyDB' which reads in data...
1
FSUKXAZ
by: FSUKXAZ | last post by:
I'm trying to change Identity on field w/Data using SQL Manager and cannot. The table is called Members and the field is called MemberID. It is already the Primary key, Not Null, and Unique...
3
by: Waruna | last post by:
Is there a way to block insert into mysql(5.0) using c api of mysql db.. i.e. say there is a table with 2 columns, one contains char other int then i want to insert 500 records at once,, as i...
4
by: ghjk | last post by:
I wan to add some data using php page to mysql db. But I got the error saying "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right...
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...
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: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
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
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.