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

Data isn't saving to mysql database

21
I hv a form in my php file to accept some data from the user.

Then as shown below I capture the data using PHP.

the data is getting captured in the variables no prob with that.

but the data isn't getting saved to the database.

it should have something to do with my if cluases. pls let me knw the error.

thanks in advance...!!!! :)

Expand|Select|Wrap|Line Numbers
  1.   <?php
  2.                                       if (isset($_POST['btnok'])) 
  3.                                     {
  4.                                               $image_id  =  $_GET['id'];                                                           
  5.  
  6.                                             $title = $_POST['lsttitle'];
  7.                                             $fname = $_POST['txtfname'];
  8.                                             $lname = $_POST['txtlname'];
  9.                                             $email = $_POST['txtemail'];
  10.                                             $message = $_POST['txtmessage'];
  11.  
  12.                                             echo "$title........";
  13.                                             echo"<br />";
  14.  
  15.  
  16.                                             $db_host = 'localhost';
  17.                                             $db_user = 'root';
  18.                                             $db_pwd = 'dba';            
  19.  
  20.                                             $database = 'gallery';
  21.  
  22.                                             if (!mysql_connect($db_host, $db_user, $db_pwd)) die("Can't connect to database");
  23.  
  24.                                             if (!mysql_select_db($database)) die("Can't select database");
  25.  
  26.                                             if ($message==null or $fname==null)
  27.  
  28.                                                 {
  29.                                                     echo "Please fill all required fields";
  30.                                                 }
  31.  
  32.                                             elseif ($fname==null or $lname==null)
  33.  
  34.                                                 {
  35.                                                     echo "Please fill all required fields";
  36.                                                 }
  37.  
  38.                                             else
  39.  
  40.                                                 {
  41.                                                 $result = mysql_query("insert into inquiries(i_inq_title, i_inq_fname, i_inq_lname, i_inq_email, i_inq_message, i_inq_painting_id) values ('".$title."', '".$fname."', '".$lname."', '".$email."', '".$message."', '".$image_id."')") or die("MYSQL Returned: ". mysql_error());
  42.  
  43.                                                         if($result==false)
  44.  
  45.                                                             {
  46.                                                                 echo "Couldnt complete the inquiry please try again!";
  47.                                                             } 
  48.  
  49.                                                         else
  50.  
  51.                                                             {                
  52.                                                                 echo"did it";
  53.                                                                 //mysql_close();
  54.                                                             }
  55.                                                 }
  56.                                         }    
  57.  
  58.                                 ?>
  59.  
Aug 7 '08 #1
2 1575
nse111
21
and one of those $fname within if() should be $email. sorry mistyped.

I get this smg all the time. just cnt c y

"Please fill all required fields"
Aug 7 '08 #2
nse111
21
sorry it's a silly question. found the answer. for anyone who seeks tha answer it's simply that the

or


should be

||
Aug 7 '08 #3

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

Similar topics

5
by: Phil Powell | last post by:
I've read some online resources that utilize various MySQL command-line actions to migrate data from Access to MySQL. The situation is this: a group of co-workers of mine will be using an Access...
32
by: Neil Ginsberg | last post by:
We're using SQL Server 7 with an Access 2000 MDB as a front end with ODBC linked tables. I recently created a new set of tables for the app, and users are complaining that unsaved data is being...
2
by: Sune | last post by:
Hi, Does anyone know a website with a guide on how to upload binary data to a MySQL database using ASP? I have a script that i spent a lot of hours on getting to work, but after i upgraded my...
3
by: Kenneth Courville | last post by:
Hello, This problem has been a little unusual for me. I have an Access database, and, on several forms, I've seen this issue occur wotj listbox and combobox controls. Basically, I'm just...
5
by: adrin | last post by:
hi, i am writing a program that is supposed to create a database of my music and albums. i want it to consist of 3 'modules' input<->processing<->output. input should enable reading data from cd...
1
by: im2kul2 | last post by:
I'd be GREATLY APRECIATED if someone could bail me out of this one! I logged into my server an hour ago just to find that the root partition is 100% filled: /dev/mapper/VolGroup00-LogVol00...
4
by: Dave | last post by:
I have some data values that will will rarely change over the life of the program. I don't think it is wise to save it in a database. Is it ok to save them in Properties.Settings if I have many...
1
by: TheTeapot | last post by:
I'm looking for a PHP database class which allows database connections to mysql, AND (text/XML) files to store information. I'm looking to use the file storage in a small intranet usage of my...
12
lifeisgreat20009
by: lifeisgreat20009 | last post by:
I am a newbie to Struts and JSP...I have been working on the code below for 5 hours now..I googled a lot but couldn't get much help so finally I am here.. Hoping of getting my problem solved. Please...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.