11 Replies - 768 Views - Last Post: 11 April 2009 - 05:30 PM Rate Topic: -----

#1 musya  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 11
  • View blog
  • Posts: 1,012
  • Joined: 25-April 07

$_GET problems

Posted 10 April 2009 - 10:21 PM

Okay this is wierd,

here is some test code to get a variable called delete from the address bar

	echo $_GET['delete'];
	if($_GET['delete'])
	{
		echo'hello';
		$sql = "DELETE FROM `users` WHERE `user_id` = '".$_GET['delete']."' LIMIT 1";
		echo $sql;
		//$result = mysql_query($sql) or die(mysql_error());
		
	}


the address looks like this
users.php?delete=26


Whats wrong im not sure, it just doesnt echo.

Thank you for your help.

Is This A Good Question/Topic? 0
  • +

Replies To: $_GET problems

#2 gregwhitworth  Icon User is offline

  • Tired.
  • member icon

Reputation: 219
  • View blog
  • Posts: 1,604
  • Joined: 20-January 09

Re: $_GET problems

Posted 10 April 2009 - 10:28 PM

I'm not sure - have you tried shoving it into a variable first - I read somewhere that anything later than php 4.x you have to grab the data first - before you can mess with it for some reason.

Also, you may not want to name your variable or GET item 'delete,' seeing as how that may be a specified php command and thus wouldn't work.

Here's one of my working examples:

$pageId = $_GET['pageId'];



--

Greg

This post has been edited by gregwhitworth: 10 April 2009 - 10:29 PM

Was This Post Helpful? 0
  • +
  • -

#3 musya  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 11
  • View blog
  • Posts: 1,012
  • Joined: 25-April 07

Re: $_GET problems

Posted 10 April 2009 - 10:48 PM

I changed it to del instead of delete, and still nothing, weird thing is though is that the echo 'hello' inside the if doesn't echo either. If it matters that ?delete=blah is set by javascript, I use it to go to users.php and set a specific number for delete based on what php passes into the function.
Was This Post Helpful? 0
  • +
  • -

#4 Auzzie  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 43
  • View blog
  • Posts: 573
  • Joined: 20-January 09

Re: $_GET problems

Posted 11 April 2009 - 12:28 AM

Well i just copied and pasted your code example (minus the sql) and it worked fine for me....
Was This Post Helpful? 0
  • +
  • -

#5 musya  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 11
  • View blog
  • Posts: 1,012
  • Joined: 25-April 07

Re: $_GET problems

Posted 11 April 2009 - 11:42 AM

wierd, I dont get it.
Was This Post Helpful? 0
  • +
  • -

#6 SpaceMan  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 10
  • View blog
  • Posts: 507
  • Joined: 20-February 03

Re: $_GET problems

Posted 11 April 2009 - 11:47 AM

would look close at what is loading before this.

see if it is getting unset somehow.
Was This Post Helpful? 0
  • +
  • -

#7 musya  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 11
  • View blog
  • Posts: 1,012
  • Joined: 25-April 07

Re: $_GET problems

Posted 11 April 2009 - 12:34 PM

nope nothing unsetting it, Ill try a few things then ill post back to let you guys know.
Was This Post Helpful? 0
  • +
  • -

#8 SpaceMan  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 10
  • View blog
  • Posts: 507
  • Joined: 20-February 03

Re: $_GET problems

Posted 11 April 2009 - 12:40 PM

$smartassmode = TRUE;
buy a mac.

This post has been edited by SpaceMan: 11 April 2009 - 12:41 PM

Was This Post Helpful? 0
  • +
  • -

#9 ghqwerty  Icon User is offline

  • if($spareTime > 0){ $this->writeCode(); }
  • member icon

Reputation: 43
  • View blog
  • Posts: 903
  • Joined: 08-August 08

Re: $_GET problems

Posted 11 April 2009 - 12:44 PM

View Postmusya, on 11 Apr, 2009 - 05:48 AM, said:

I changed it to del instead of delete, and still nothing, weird thing is though is that the echo 'hello' inside the if doesn't echo either. If it matters that ?delete=blah is set by javascript, I use it to go to users.php and set a specific number for delete based on what php passes into the function.



does it echo the sql too? i reckon 1 of 2 things, if it does then try adding a space between the echo and the ' thats affected things for me before, and if it echoes neither then its because $_GET['delete'] isn't there. try using

if(isset($_GET['delete'])){// or use if(!empty($_GET['delete'])){ // try both 
  echo "Get delete exists!";
}else{
  echo "Get delete DOESN'T exist";
}



then we can determine the error and a way to solve it

another thing. if that still doesn't work try using $_REQUEST['delete'] instead of $_GET both SHOULD work but just check it.

as greg mentioned try adding it into a variable first that works for me most the time

good luck
Was This Post Helpful? 0
  • +
  • -

#10 SpaceMan  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 10
  • View blog
  • Posts: 507
  • Joined: 20-February 03

Re: $_GET problems

Posted 11 April 2009 - 01:16 PM

i usually do a validation, same time..

if(is_numeric($_GET['delete'])){


Was This Post Helpful? 0
  • +
  • -

#11 musya  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 11
  • View blog
  • Posts: 1,012
  • Joined: 25-April 07

Re: $_GET problems

Posted 11 April 2009 - 03:08 PM

I'm a F*$#ing idiot, i put that code inside an if statment that doesnt run at that specific time. what a f$(%ing waste of time, sorry guys thank you for all of your help though.

EDIT:
I hope you dont all hate me yet ;)

This post has been edited by musya: 11 April 2009 - 03:08 PM

Was This Post Helpful? 0
  • +
  • -

#12 SpaceMan  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 10
  • View blog
  • Posts: 507
  • Joined: 20-February 03

Re: $_GET problems

Posted 11 April 2009 - 05:30 PM

LOL!!!!

i never did that!!!

hmm, more then 1 time day i dont think....

Confucius say, if at first you don;'t succeed, don't tell anyone..........

have fun
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1