sql problems


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

I am having a small problem with my sql statement. it is inserting into 4 of the fields.

fields it is inserting into:
First
Did you know?Explore Trending and Topic pages for more stories like this.
Last
email
password

it is saying the record has been added. is there something wrong with the sql statement?

Code: <?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="95887rj"; // Mysql password
$db_name="bccsl"; // Database name
$tbl_name="managers2"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

$sql = sprintf("INSERT INTO Managers (First, Last, Address, City, Postal, Home, Cell, Email, Password, Church, Team)VALUES ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')",$_POST['firstname'],$_POST['lastname'],$_POST['address'],$_POST['city'],$_POST['postal'],$_POST['home'],$_POST['cell'],$_POST['email'],$_POST['password'],$_POST['church'],$_POST['team']);

if (!mysql_query($sql))
{
die('Error: ' . mysql_error());
}
echo "1 record added";

?>
No comments posted yet

Your Answer:

Login to answer
263 Like 53 Dislike
Previous forums Next forums
Other forums

Weekly Calendar
Hi, I am looking at creating a weekly calendar. The calendar will read from Monday - Sunday. Does an

Packet Design
Hi All,
Im new about network programming and I want to design a protocol but I have some question

want a code for uploading and downloading
i m trying to upload and download to my site..i need upload and download code ...i use a code for up

updating a single value to multiple non consecutive rows
I need to update the same value to multiple non consecutive rows. I need to add an experation date t

Multiple if statements
Ok so seems basic but for some reason I'm not doing it right. What I want is to be able to have 2 se

How to change www in url with a specified name
Hi
I'm trying to change the url http://www.sitename.com/apparels to something like below
http:

double and single quotes in text fields acting up... help please
Single quotes, when entered into a text field, create an sql error upon Submit. It seems to create t

IF Statement & Two Tables With Different Echoes
I'm retrieving two tables in a single query using UNION ALL, like so:

Code: $query = "SE

How to insert random unique values in 2 columns ?
I have table with 2 columns

Create Table code_for_code (
first_code varchar2(10) uni

Accept only alpha characters
I've got this bit of code ready for accepting a phrase:

Code: if (!eregi ("", $_POS

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