473,699 Members | 2,413 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP won't post to database

Hi Guys,

I really am a novice and found a script on webmonkey. Basically all I want
to do is to add records to my database. In my database I have a table called
research_main with the fields already created.

I have tried to bodge a script to work for me. it doesn't. It looks as
though it works but I get no data posted. What have I done wrong?

If you want me to put a statement in anywhere to check something please let
me know where you want me to put it as I really am useless with this.

can you tell me what is wrong with this script.

:-( I am trying honest

<html>

<body>

<?php

if ($submit) {

// process form

$db = mysql_connect(" localhost", "uname", "password") ;

mysql_select_db ("dbtouse",$db) ;

$sql = "INSERT INTO research_main
(date_inv,info, medium_name,pla ce_name,date_de ath,verified_ev ent,closed_even t
) VALUES
('$date_inv','$ info','$medium_ name','$place_n ame','$date_dea th','$verified_ e
vent','$closed_ event')";

$result = mysql_query($sq l);

echo "Thank you! Information entered.\n";

} else{

// display form

?>

<form method="post" action="<?php echo $PHP_SELF?>">

<p>Date Of Event:
<input name="date_inv" type="Text" id="date_inv">
<br>

Information to be researched:
<textarea name="info" cols="75" rows="5" id="info"></textarea>
<br>

Medium or Researchers name: :
<input name="medium_na me" type="Text" id="medium_name " maxlength="30">
<br>

Place Name: :
<input name="place_nam e" type="Text" id="place_name " maxlength="50">
<br>
Date of Investigation:
<input name="date_deat h" type="text" id="date_death" >
<br>
Verified Event:
<input name="verified_ event" type="radio" value="radiobut ton">
Yes
<input name="verified_ event" type="radio" value="radiobut ton" checked>
No<br>
Event Closed:
<input name="closed_ev ent" type="radio" value="radiobut ton">
Yes
<input name="closed_ev ent" type="radio" value="radiobut ton" checked>
No<br>

<input type="Submit" name="submit" value="Enter information">
</p>
</form>
<?php

} // end if

?>

</body>

</html>

Jul 17 '05
10 2267

"Dan Weeb" <da********@hot SPAMLESSmail.co m> wrote in message
news:c0******** ***********@new s.demon.co.uk.. .
$result = mysql_query($sq l) or die('No Query!');
OK Thanks It was a faulty query.

How do I make sue that my php fields match my database? I want the dates
and the radio buttons to put correct info into the database fields


Take a look at http://www.tonymarston.co.uk/php-mysql/dateclass.html for a
class which both validates and formats dates.

--
Tony Marston
http://www.tonymarston.net
For example in the database

date_event is type date
medium_name is type varchar
info_research is type blob
place_name is type varchar
date_invest is type date
date_death is type date
verified_event type char(3)
closed_event type char(3)

In the php script I have the fields setup as

date_event is type text <------------ Needs to be a date in format
dd/mm/yyyy
medium_name is type text
info_research is type textarea
place_name is type text
date_invest is type text <------------ Needs to be a date in format
dd/mm/yyyy
date_death is type text <------------ Needs to be a date in format
dd/mm/yyyy
verified_event radiobutton
closed_event type radiobutton

Currently if I enter date of 21/12/2004 it displays as 2112-20-04

Thanks so much

Paul

Jul 17 '05 #11

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

Similar topics

10
3340
by: Wayne Aprato | last post by:
I have a database that was written in Access 2003 using the Access 2000 file format. When I run the mdb in Access 2003 everything works fine. If I run it in Access 2000 the timer event won't fire on my forms. This is crazy. Has anyone seen this behaviour? Any help appreciated.
11
1816
by: John Ortt | last post by:
Hi everyone. I have a database which I have developed in Access 2000 which is working nicely. The problem is that my customer only has Access 97. I tried to convert the database but the main menu won't work. I has two parts, a mainmenu and a submenu which displays the option buttons.
30
7691
by: MikeC | last post by:
Good People, I'm writing a backup utility that uses a chdir() to go into the source directory (in which the files reside that I want to back up), so I don't want to use chdir() to get into the target directory (where the backup copies will be kept, on another drive). I can successfully test whether the target directory exists or not using findfirst(), but if it doesn't, I wanted to create it using mkdir(), but it doesn't like the path...
5
3473
by: Slavan | last post by:
I have an update statement that I'm executing against Oracle database from my C# code and it won't work. UPDATE MenuCaptions SET Caption = N@Caption WHERE MenuId = @MenuId AND CultureId = @CultureId Caption is an nvarchar type. MenuId and CultureId are integers. I get Exception with the following message: ORA-00933: SQL command not properly ended. It seems that problem lies in Caption column, because when I changed
4
2999
by: dac | last post by:
I am quietly going insane on this project. I've never worked on a project like this one before. All my previous sticky forms were for data entry, not editing. I don't know how to display the form with data from the database, allow the user to update it, and then display the form again with POST data. I can get the data out of the database and get the user updates back into the database, but how do I get the filled-out form back to the user...
2
3200
by: adamace5o | last post by:
When i try to use post variables with php and mysql i can't get the insert into statement to accept varibles as values. If i use 'test' instead of $test it does work. I suspect it is something to do with the javascript im using but i can print the correct values so why am i unable to use them to enter data to a database? sorry i am new to all this here is the updatedata.php file <?php session_start(); $host="localhost"; // Host...
12
3277
by: tekctrl | last post by:
Environment; Win2K PC with 1Gb of RAM and plenty of HD space running Access 2002 Issue; Access presents a blank data entry form in the Forms view when the New Record icon is used. However, it won't allow any fields to have data entered into them. I can edit & save existing records without problem. When I go into the Tables view, I can add records and data ok and save without problem. I go back into the Table and I can see the data. ...
12
6026
by: godiva | last post by:
Hi, Last week one client had errors caused by another program which led the IT guys to wipe out and rebuild the hard drive on one particular computer. Prior to this happening, the people in this department were using a 2000 format database through Access 2007 without any issues. Since IT rebuilt said hard drive, one user now gets a message when attempting to open the same database that 2007 cannot open older format databases. The...
2
3230
jamwil
by: jamwil | last post by:
What's up guys. I'm having some issues... I've created a method as part of my lifestreaming class which takes an rss feed, and puts the data into a database... It's fairly simple... Check it....///// // feed // // LOADS THE RSS FEED FOR // LOOPS THROUGH AND FORMATS/FILTERS POSTS // PULLS THE TIMESTAMP OF THE LATEST UPDATE FROM THE DB // IF THERE ARE NEW POSTS, ADD THEM TO THE DATABASE ///// public function feed($feed,$type) { if...
0
8689
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8618
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8916
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8885
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6534
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4376
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3058
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2348
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2010
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.