URL Syntax - I be stumped!
Moderator: General Moderators
-
AaronSmith
- Forum Commoner
- Posts: 32
- Joined: Fri Mar 28, 2003 3:14 pm
URL Syntax - I be stumped!
I am calling two things in one URL, and have no idea what this sort of thing is termed.
Here is the URL I am using, and it isn't working. My code is fine, but this URL is wrong - I just know it!
browse.php?id=217 page=3
What punctuation do I stick between "?id=217" and "page=3" ?
I appreciate any help with this...
Here is the URL I am using, and it isn't working. My code is fine, but this URL is wrong - I just know it!
browse.php?id=217 page=3
What punctuation do I stick between "?id=217" and "page=3" ?
I appreciate any help with this...
-
AaronSmith
- Forum Commoner
- Posts: 32
- Joined: Fri Mar 28, 2003 3:14 pm
-
AaronSmith
- Forum Commoner
- Posts: 32
- Joined: Fri Mar 28, 2003 3:14 pm
This is the page being called...
Code: Select all
<?
class classified
{
var $ID;
var $Created;
var $Expires;
var $AuthorID;
var $title;
var $description;
var $filename;
var $pictureID;
var $iquantity;
var $asking_price;
var $duration;
var $phonenumber;
var $city;
var $state;
var $shipping;
var $international;
var $payment;
var $category;
var $category2;
var $category3;
var $suggested_category;
function classified()
{
$this->AuthorID = $_SESSIONї'PHPAUCTION_LOGGED_IN'];
$this->iquantity = 1;
$this->shipping = 'buyer';
$this->payment = array();
$this->category = 0;
$this->category2 = 0;
$this->category3 = 0;
}
function save()
{
if ( empty($this->ID) )
{
$query = "INSERT INTO classifieds SET ";
$this->Created = time();
$this->Expires = $this->Created + $this->duration*24*60*60;
}
else
$query = "UPDATE classifieds SET ";
$query .= safe_pair("AuthorID=",$this->AuthorID);
$query .= safe_pair(", Category=",$this->category);
$query .= safe_pair(", Category2=",$this->category2);
$query .= safe_pair(", Category3=",$this->category3);
$query .= safe_pair(", Created=",$this->Created);
$query .= safe_pair(", Expires=",$this->Expires);
$query .= safe_pair(", object=",serialize($this));
if ( !empty($this->ID) )
{
$query .= safe_pair(" WHERE ID=",$this->ID);
}
$q = mysql_query($query) or class_error(mysql_error());
$id = mysql_insert_id();
if ( empty($this->ID) && $id > 0 )
{
$this->ID = $id;
}
return $this->ID;
}
function scan_form($a,$payment)
{
$errors = array();
if ( $this->ID != $aї'ID'] )
{
class_error("Intruder alert! ID mismatch.");
}
unset($aї'ID']);
foreach ( $a as $k => $v )
{
$aї$k] = strtr($aї$k],array("\''"=>"'",""e;"=>"""));
}
if ( empty($aї'title']) )
{
$errorsї'title'] = "You must provide an item title.";
}
if ( empty($aї'description']) )
{
$errorsї'description'] = "A description is required!";
}
if ( empty($aї'asking_price']) )
{
$errorsї'asking_price'] = "Did you forget an asking price or comment?";
}
global $class_duration_table;
if ( !isset($class_duration_tableї$aї'duration']]) )
{
$errorsї'duration'] = "Choose a standard duration.";
}
if ( empty($aї'city']) )
{
$errorsї'city'] = "City where goods are located.";
}
if ( empty($aї'state']) )
{
$errorsї'state'] = "State (or country) where goods are located.";
}
global $shipping_table;
if ( !isset($shipping_tableї$aї'shipping']]) )
{
$errorsї'shipping'] = "Select a shipping option.";
}
global $payment_table;
$this->payment = array();
unset($aї'payment']);
if ( isset($payment) )
{
foreach ( $payment as $key => $val )
{
if ( isset($payment_tableї$val]) )
{
$this->paymentї$val] = true;
}
else
{
$errorsї'payment'] = "Internal error: unknown payment";
unset($paymentї$key]);
}
}
}
if ( empty($payment) && !isset($errorsї'payment']) )
{
$errorsї'payment'] = "Select at least one payment option.";
}
if ( empty($aї'category']) || $aї'category'] < 1 )
{
$errorsї'category'] = "You must select a primary category.";
$aї'category'] = 0;
}
if ( !empty($aї'category2']) && $aї'category2'] > 0 )
{
if ( $aї'category2'] == $aї'category'] )
{
$errorsї'category2'] = "Duplicate category";
}
}
else $aї'category2'] = 0;
if ( !empty($aї'category3']) && $aї'category3'] > 0 )
{
if ( $aї'category3'] == $aї'category']
|| $aї'category3'] == $aї'category2'] )
{
$errorsї'category3'] = "Duplicate category";
}
}
else $aї'category3'] = 0;
foreach ( get_class_vars('classified') as $k => $v )
{
if ( isset($aї$k]) )
$this->$k = $aї$k];
}
return $errors;
}
}
$class_duration_table = array(
10 => "10 days",
30 => "1 month",
365 => "1 year"
);
function get_classified($search_id)
{
global $query_string;
$q = safe_query("select * from classifieds"
. " where ID =", $search_id)
or class_error(mysql_error() . "<br><pre>" . $query_string . "</pre>");
if ( mysql_num_rows($q) != 1 )
class_error("Internal error: row not unique");
$row = mysql_fetch_assoc($q);
$obj = unserialize($rowї'object']);
$obj->ID = $rowї'ID']; // may not be assigned when INSERTed
return $obj;
}
function class_search($cat,$pagelimit)
{
global $query_string;
$table = "classifieds";
$pagelimit = "2";
$strSQL = mysql_query("SELECT * FROM $table");
$totalrows = mysql_num_rows($strSQL);
$pagenums = ceil ($totalrows/$pagelimit);
if ($page==''){
$page='1';
}
$start = ($page-1) * $pagelimit;
$starting_no = $start + 1;
$space = " ";
return snarf_array('classifieds','ID','ID',
" WHERE (Category=$cat OR Category2=$cat OR Category3=$cat) "
. " AND Expires>" . time()
. " ORDER BY Created DESC LIMIT $start,$pagelimit" );
}
function class_textsearch($key,$limit)
{
global $query_string;
return snarf_array('classifieds','ID','ID',
" WHERE UPPER(object) LIKE UPPER('%". mysql_escape_string($key) . "%')"
. " AND Expires>" . time()
. " ORDER BY Created DESC $limit" );
}-
AaronSmith
- Forum Commoner
- Posts: 32
- Joined: Fri Mar 28, 2003 3:14 pm
what values are you getting?AaronSmith wrote:I was just trying that... and getting the same two items over and over regardless of the page. I must have something else wrong too.
I've written pagination before, but this two variable question of category and page is stumping me. Any common mistakes I should look at?
Code: Select all
if ($page==''){
$page='1';
}If youre register_globals = ON, ignore this post.
Read the last link in my signature.
register gobals should be off for security reasons.JAM wrote:...makes it not working if you have your register_globals = off.Code: Select all
if ($page==''){ $page='1'; }
If youre register_globals = ON, ignore this post.
Read the last link in my signature.
assuming 4.1.0 or higher, he shoudl get the get variables like this:
Code: Select all
if(isset($_GET['variable']){ // if it was passed in the GET string
$variable=$_GET['variable'];
}else{ // it wasn't passed, what's the default?
$variable='default value';
}-
AaronSmith
- Forum Commoner
- Posts: 32
- Joined: Fri Mar 28, 2003 3:14 pm
http://www.php.net
go look up register globals. you might decide you want them OFF.
it's a security risk. expect that any place that has 4.1.0 or higher (when it was turned off by default) has it off and most likely wont turn it on.
coding in a dev env is good as long as you know the dev env is more restrictive than a possible deployment environment.
means you know it will work.
go look up register globals. you might decide you want them OFF.
it's a security risk. expect that any place that has 4.1.0 or higher (when it was turned off by default) has it off and most likely wont turn it on.
coding in a dev env is good as long as you know the dev env is more restrictive than a possible deployment environment.
means you know it will work.
-
AaronSmith
- Forum Commoner
- Posts: 32
- Joined: Fri Mar 28, 2003 3:14 pm
You could add this on pages you are testing...
or perhaps only
Code: Select all
<?php
phpinfo();
?>Code: Select all
<?php
phpinfo(32);
?>
Last edited by JAM on Tue Sep 09, 2003 10:29 am, edited 1 time in total.
printr($_GET);AaronSmith wrote:I appreciate the advice. I will look into it per your suggestion.
How do I find what values are being passed? At one time, I had a file I could access that would tell me - but do not know the contents of such a thing. I've only been doing this for a short while.
(i might have the call a bit off)
-
AaronSmith
- Forum Commoner
- Posts: 32
- Joined: Fri Mar 28, 2003 3:14 pm