RE: [PHP] $_POST in MySQL query issue...

This is a discussion on RE: [PHP] $_POST in MySQL query issue... within the PHP General forums, part of the PHP Programming Forums category; Adam Reiswig wrote: > Greetings to all. I am trying for the life of me to place a $_POST[] > ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-17-2003
Jake McHenry
 
Posts: n/a
Default RE: [PHP] $_POST in MySQL query issue...

Adam Reiswig wrote:
> Greetings to all. I am trying for the life of me to place a

$_POST[]
> variable in my MySQL query. I am running the latest stable
> versions of
> PHP, MySQL and Apache 2 on my Win2kPro machine. My
> register_globals are
> set to off in my php.ini. My code I am attempting create is

basically
> as follows:
>
> $table="elements";
> $sql="insert into $table set Name = '$elementName'";
>
> This works with register_globals set to on. But, I want to
> be able to
> turn that off. My code then, I am guessing, be something as

follows:
>
> $table="elements";
> $sql="insert into $table set Name = '$_POST["elementName"]'";
>
> Unfortunately this and every other combination I can think of,
> combinations of quotes that is, does not work. I believe the
> source of
> the problem is the quotes within quotes within quotes. I also tried:
>
> $sql='insert into $table set Name = '.$_POST["elementName"]; or
> $sql="insert into $table set Name = ".$_POST['elementName'];
>
> and several other variations.
>
> Can anyone give me some pointers to inserting $_POST[]
> statements inside
> of query statements? I am sure there must be a way but I
> have spent a
> lot of time on this and am really stumped here. Thanks for any

help.
>
> -Adam Reiswig
>
> PS if anything here is not clear to you, please let me know and I'll
> clarify as I can. Thanks again.


Do this first:

$elementName = $_POST["elementName"];

Then you don't have to change your sql statement. That's what I've
been doing all day yesterday and today in my time clock program. It's
less time consuming than changing all of the sql queries.

Jake McHenry
Nittany Travel MIS Coordinator
http://www.nittanytravel.com
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:08 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0