[help] Html -> PHP Problems

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
Da P3s7
Forum Commoner
Posts: 30
Joined: Wed Jul 19, 2006 3:25 pm
Location: /usr/src/kernels/ 2.6.15-1.2054_FC5-i686

[help] Html -> PHP Problems

Post by Da P3s7 »

Code: Select all

$sql = "INSERT INTO main(Name,Description,Path,Executed,Sold,Price) Values('$_get[Name]','$_get[Description]','$_get[Path]','$_get[Executed]','$_get[Sold]','$_get[Price]')";
When i SELECT from the table i get

Code: Select all

, , , 0, 0, 0.
, , , 0, 0, 0.
You're gonna say : Of course u get that cos u got single quotes around variables.
Well i already tryied heredoc syntax but i get errors.
Could any1 point the right syntax pls ?
Last edited by Da P3s7 on Fri Jul 21, 2006 4:05 pm, edited 1 time in total.
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

2 things, do a print_r on the $_GET variable (Notice case of the word get) And then echo out the sql statement to see what that looks like.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

You might want to do..

Code: Select all

print_r($_GET);
and double check those variables are populated.

hawleyjr beat me..

I would reformat the query as well. This is how I prefer to format queries such as this..

Code: Select all

$sql = "INSERT INTO `main` (`Name`, `Description`, `Path`, `Executed`, `Sold`, `Price`) VALUES ('" . mysql_real_escape_string($_GET['Name']) . "', '" . mysql_real_escape_string($_GET['Description']) . "', '" . mysql_real_escape_string($_GET['Path']) . "', '" . mysql_real_escape_string($_GET['Executed']) . "', '" . mysql_real_escape_string($_GET['Sold']) . "', '" . mysql_real_escape_string($_GET['Price']) . "')";
User avatar
Da P3s7
Forum Commoner
Posts: 30
Joined: Wed Jul 19, 2006 3:25 pm
Location: /usr/src/kernels/ 2.6.15-1.2054_FC5-i686

Post by Da P3s7 »

Code: Select all

Array ( [Name] => abc [Description] => bcd [Path] => cde )
But the point is that now it seems like it passes text but it wont pass numbers..... i get

Code: Select all

abc, bcd, cde, 0, 0, 0.
Whereas i entered "12, 23, 34" for each "executed, sold, price". (for the last 3 zeros)

Is ...

Code: Select all

<input type="text">
...passing numbers?
I dont see a reason for it but hey.....
If it's not then is there an alternative?

Thx btw astions and hawleyjr.

P.S. I tried to manually enter in the address bar the rest of the variables he was supposed to pass.... He accepted and it outputted

Code: Select all

aa, bb, cc, 22, 22, 22.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Why has nobody mentioned that $_GET is case sensitive? ;)

Code: Select all

$_get[Name] //wrong
EDIT | Errr... I'm an idiot. Sorry hawley :oops:
User avatar
Da P3s7
Forum Commoner
Posts: 30
Joined: Wed Jul 19, 2006 3:25 pm
Location: /usr/src/kernels/ 2.6.15-1.2054_FC5-i686

Post by Da P3s7 »

Well mind you $_GET is caps in the code (after astions post..... thx again btw).....
Also in case the array's values are case-sensitive (ill have to look into it as im still pretty new to php) i entered them bearing case-sensitivity in mind.
User avatar
kbrown3074
Forum Contributor
Posts: 119
Joined: Thu Jul 20, 2006 1:36 pm

Post by kbrown3074 »

Why dont you just push the $_GETs into variables and do it that way?
User avatar
Da P3s7
Forum Commoner
Posts: 30
Joined: Wed Jul 19, 2006 3:25 pm
Location: /usr/src/kernels/ 2.6.15-1.2054_FC5-i686

Post by Da P3s7 »

can you be more explicit pls?
Thx
User avatar
kbrown3074
Forum Contributor
Posts: 119
Joined: Thu Jul 20, 2006 1:36 pm

Post by kbrown3074 »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Code: Select all

$name=$_get['Name'];
   $descr = $_get['Description'];
   $path = $_get['Path'];
   $exec = $_get['Executed'];
   $sold = $_get['Sold'];
   $price = $_get['Price'];
$sql = "INSERT INTO main(Name,Description,Path,Executed,Sold,Price) Values('$name','$descr','$path','$exec','$sold','$price')";

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
Da P3s7
Forum Commoner
Posts: 30
Joined: Wed Jul 19, 2006 3:25 pm
Location: /usr/src/kernels/ 2.6.15-1.2054_FC5-i686

Post by Da P3s7 »

the problem with that was solved... the problem now it's that html doesnt seem to pass the rest of the array values ( executed, sold, price) to the $_GET array...
As i said... i tryied to pass the values manually (i typer after the "?Name=aa&Description ......" "&Executed=22 ......." etc) and it seems like php enters these values into mysql.

Ideas?

P.S. Does php work within a simple html file?.....
or do i have to make it .php?

P.S.S : Btw as hawleyjr stated $_GET is case-sensitive... so $_get will not work
Last edited by Da P3s7 on Fri Jul 21, 2006 12:47 pm, edited 1 time in total.
User avatar
kbrown3074
Forum Contributor
Posts: 119
Joined: Thu Jul 20, 2006 1:36 pm

Post by kbrown3074 »

with the insert line..it will enter it into mysql. not sure what you are asking. Do you want to pass the get's to another page after you put them in the table?
User avatar
Da P3s7
Forum Commoner
Posts: 30
Joined: Wed Jul 19, 2006 3:25 pm
Location: /usr/src/kernels/ 2.6.15-1.2054_FC5-i686

Post by Da P3s7 »

look at my first post after the thread start post and youll understand what i mean
User avatar
Da P3s7
Forum Commoner
Posts: 30
Joined: Wed Jul 19, 2006 3:25 pm
Location: /usr/src/kernels/ 2.6.15-1.2054_FC5-i686

Post by Da P3s7 »

Would editing the html and adding the $_GET array values manually with code work?
Somthing like:
on submit $_GET("name") = name
etc...

Dunno but it doesnt look like it can be done otherwise?

Edit: Nobody willing to help ?? :(
Edit to feyd: I wasnt assuming you dont have anything better to do but some threads that still havent been answered go to the bottom without getting some answer.

P.S. i am patient except that i need this code ASA i can get it.... That means that I am in a hurry while i dont care about how long it takes for you to respond (let's not exagerate ;))
P.S.S.: Not to be rude.... but why did you even bother to post since you didnt even suggest the shortest tip possible ?
Last edited by Da P3s7 on Fri Jul 21, 2006 4:36 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Da P3s7 wrote:Nobody willing to help ?? :(
Have some patience. Most of us have things to do beyond posting here.
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

How about you post your HTML..
Post Reply