help with insert


Posted on 16th Feb 2014 07:03 pm by admin

Hi there,

I am trying to insert some data into a database, but for some reason, it is not inserting.

Can anyone see anything wrong with my code:


<?php

$host = "***";
$username = "***";
$password = "***";


$connection = mysql_connect($host, $username, $password);
mysql_select_db("***, $connection");

mysql_query("INSERT INTO events14 (name)
VALUES ('$_POST[name]')");

?>


I have also set up an ID field which auto increments and this seems to be working, but nothing is being entered into the "name" field.

This is my form:


<form action="add_event.php" method="post">
<input type="text" name="name" id="textfield" />
<input type="submit" name="button" id="button" value="Submit" />
</form>



The file with the php code is called add_event.php, so everything is on one page.

Any ideas what I have wrong

No comments posted yet

Your Answer:

Login to answer
241 Like 17 Dislike
Previous forums Next forums
Other forums

Syntax Help
Code:


im having trouble with that code snipped
Parse error: syntax error, unexpec

Why is this query failing?
Why is this not working?
$query = "SELECT * FROM `users` WHERE `userid` = " . $USERID

disable all input buttons
Hello Friends,

suppose i do have a file ( file.php ) has a submit button

Code: [Sele

Variable Clash
In the past I've had variables clash. For example:

Code: <?php
$c = 5;
$ca

Unexpected T_Variable ?
Hi all,
I dont really know what I am doing!! I know I'm doing something wrong, and I know its on

Really need helps regarding Pagination with Sort
I need someone helps regarding pagination problem...i actually want to make my page limited to let s

Calling variables
I want to call this to my website but it doesn't display what I want it to,

Code: <h5&

Help a newbee save my job !
Hey guys i am dying here i am new to php and would like for someone to help me with this problem

[function.file]: failed to open stream: No such file or directory
Okay I wrote this little script to upload a csv file that is located on my webhosts server to a mysq

Format timestamp from mysql
When I tried this:
Code: date("m/d/Y H:i A", $row['timestamp'])
I got 12/31/1969 18:

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash