Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

insertin double value

Codes here !

Moderators: macek, egami, gesf

insertin double value

Postby nehakarnatak » Wed Sep 12, 2012 3:08 am

<?php
session_start();
include("connect_wec.php");

$q1="INSERT INTO category( Category)
VALUES
( TRIM( '$_POST[category]' )) ";





if (!mysql_query($q1))




die('Error:qry_Create_Categ: ' . mysql_error());



}

//header("Location: Http://localhost/crm/admin/Create_Categ ... ategCreate");

header("Location: http://indiaenergycongress.in/crm/admin ... atagCreate");


exit();



?>
nehakarnatak
New php-forum User
New php-forum User
 
Posts: 11
Joined: Tue Feb 28, 2012 10:06 pm

Re: insertin double value

Postby NigelRen » Wed Sep 12, 2012 5:12 am

Could you please explain what you are expecting and what's actually happening.

There is one obvious problem at
Code: Select all
$q1="INSERT INTO category( Category)
VALUES
( TRIM( '$_POST[category]' )) ";

The value isn't being retrieved properly. Should be something like
Code: Select all
$q1="INSERT INTO category( Category)
VALUES
( TRIM( '".$_POST["category"]."' )) ";

This comes down to when accessing things like $_POST - you normally have to put the name of the field your after in quotes. This because it acts as an index - which is a string, and strings are normally enclosed in quotes.
NigelRen
php-forum Active User
php-forum Active User
 
Posts: 450
Joined: Fri Aug 05, 2011 9:53 am


Return to mySQL & php coding

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.