Page 1 of 2
[help] Html -> PHP Problems
Posted: Thu Jul 20, 2006 10:03 am
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 ?
Posted: Thu Jul 20, 2006 10:11 am
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.
Posted: Thu Jul 20, 2006 10:11 am
by Benjamin
You might want to do..
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']) . "')";
Posted: Fri Jul 21, 2006 10:00 am
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
Whereas i entered "12, 23, 34" for each "executed, sold, price". (for the last 3 zeros)
Is ...
...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
Posted: Fri Jul 21, 2006 10:36 am
by Chris Corbyn
Why has nobody mentioned that $_GET is case sensitive?
EDIT | Errr... I'm an idiot. Sorry hawley

Posted: Fri Jul 21, 2006 10:43 am
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.
Posted: Fri Jul 21, 2006 12:17 pm
by kbrown3074
Why dont you just push the $_GETs into variables and do it that way?
Posted: Fri Jul 21, 2006 12:21 pm
by Da P3s7
can you be more explicit pls?
Thx
Posted: Fri Jul 21, 2006 12:28 pm
by kbrown3074
feyd | Please use 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
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]
Posted: Fri Jul 21, 2006 12:34 pm
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
Posted: Fri Jul 21, 2006 12:46 pm
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?
Posted: Fri Jul 21, 2006 12:48 pm
by Da P3s7
look at my first post after the thread start post and youll understand what i mean
Posted: Fri Jul 21, 2006 4:04 pm
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 ?
Posted: Fri Jul 21, 2006 4:24 pm
by feyd
Da P3s7 wrote:Nobody willing to help ??

Have some patience. Most of us have things to do beyond posting here.
Posted: Fri Jul 21, 2006 4:34 pm
by d3ad1ysp0rk
How about you post your HTML..