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
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

problem with array - multilingual page
this is my test page :
Code: <?php
if(isset($_GET['lang'])) {
if($_GET['la

mail()
Hi all. I have a problem with emails. I am trying to set up a mail system where customers can subscr

Force download script not handling files with spaces properly
I have a regular old php force download script, uses this code:

Code: header("Cache-Cont

Parse Error
Hi Guys,

I have a function in my class which returns a string link variable. The problem is i

losing variables between php brackets
Hi

have got this code:
Code: $id=mysql_result($result,0,"itemid");
$title=mys

getting most records by count
Code: [Select]<?php

$connect = mysql_connect("localhost","dam

data type in column definition
Hi,
I create a table with column called "Direction of Travel code ".
The travel codes in t

need help in php variable
i have a php variable on one page
Code: [Select]$lastId = mysql_insert_id($db);
echo $lastId;<

Day of week
I am using PHP version 5.0.5
I have a varaible ($DATE (date format yyyy-mm-dd)) that is being inc

Trying to add functions to table
I have this list of characters and I'm trying to figure out what I have to do to put the results of

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