Jump to content

Help with VIEW variables not being seen


Voodoo Jai

Recommended Posts

I have decided to change my select table query to a select view query. Unfortunately it now does not accept the GET variable passed from the URL.

 

Here is the statement:

<?php
$Take_Takeaway = "1";

if (isset($_GET['TakeawayID'])) {
  $Take_Takeaway = (get_magic_quotes_gpc()) ? $_GET['TakeawayID'] : addslashes($_GET['TakeawayID']);
}
mysql_select_db($database_LostMyMenu_conn, $LostMyMenu_conn);
$query_NewView = sprintf("SELECT NewView.TakeawayID,  NewView.Takeaway_Name, NewView.Line1,
NewView.Line2, NewView.Map_Link 
WHERE NewView.TakeawayID = %s 
AND NewView.List_type = list_type. List_TypeID 
AND NewView.City = city.CityID", $Take_Takeaway);
?>

 

when this worked before changing I had to create a variable for the TakeawyID in the WHERE clause shown as "%s" and also "$Take_Takeaway". So why is it defaulting to the first ID of the table the view accesses.

I know someone will point out the assignment of the value "1" at the beginning but this was how it worked before OK. If I comment it out it still defaults to "1".

 

Many thanks

VoodooJai

 

(PS bet its a simple typo that I cant see for looking)

Link to comment
https://forums.phpfreaks.com/topic/118961-help-with-view-variables-not-being-seen/
Share on other sites

Your script is susceptible to sql injection.

 

See: ?TakeawayID=1 UNION ALL DROP TABLE yourTable --

 

Stick single quotes around %s, that should secure it (to some extent) and maybe fix it. I'd suggest using mysql_real_escape_string() over addslashes() though.

Your script is susceptible to sql injection.

 

See: ?TakeawayID=1 UNION ALL DROP TABLE yourTable --

 

Stick single quotes around %s, that should secure it (to some extent) and maybe fix it. I'd suggest using mysql_real_escape_string() over addslashes() though.

No change still after your suggestions, how could I check that my script is secure, what should I be doing.

 

Thanks VoodooJai

well it should be more or less secure as long as you don't allow user variables posted in outside of single quotes.

 

I purposefully did wrong syntax earlier, I don't think that you can use UNION ALL for non-select queries so it shouldn't run (?). Putting it in for your GET wouldn't be a good test to see if you are secure...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.