Jump to content

Why wont this work?


miracle_potential

Recommended Posts

I'm fairly new to php sort of 6 months. So forgive me if this code is squiffy.

 

My code for a shop I'm programming for a friend just comes up with a blank page. Can anyone help I cant really see any major issues but its probably just my inexperience.

 

Basically the page that refers to product.php has a series of links in it that have preset queries for the catagory. So like myfile.php?cat=earings

 

And I could only think that parse_url() would be a good way to get the data from it to use in a query.

 

I've attatched a zip file of three files that seem to be having trouble with. Thanks guys!

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/101515-why-wont-this-work/
Share on other sites

k i ve found error in prodfunc.php

dont use [] in these ....

$catagory_array = array(
$cats_list => "earings",
$cats_list => "necklaces",
$cats_list => "bracelets",
$cats_list => "anklets",
$cats_list => "hair accessories",
$cats_list => "alchemy gothic range",
$cats_list => "brooches",


in url_constants.php replace single quote with  double quote..like this....
$url = parse_url("http://www.noirorchidemporium.co.uk/products/products.php?cat=',['PHP_URL_QUERY']");

Link to comment
https://forums.phpfreaks.com/topic/101515-why-wont-this-work/#findComment-519289
Share on other sites

Hrmm I have one more issue I've changed most of the code and moved the class to parse the URL into the prodfunc.php file.

 

Basically what I need is when someones click on the link ...href="link.php?cat=earings"> they get taken to a page and this script runs determining from the URL what the catagory is.

 

But I'm trying to debug this thing at the moment and its just outputting

 

test
the catagory is.

.
Error starting class

 

using the debugging stuff I put at the bottom of my script the code is

include("../connect.php");

$url_constants = new url_constants;

class url_constants
{
var $url_constants;

function url_constants(){
$url = parse_url("http://www.noirorchidemporium.co.uk/products/products.php?cat=',['PHP_URL_QUERY']");
$url_constants = strtolower($url);
$url_constants = preg_replace('+, , $url_constants');
return $url_constants;
}
}

$product = new product;

class product{

var $catagory;//get the catagory from the url
var $referal_loc;//address of last page visited incase of error

function product_catagory(){

//refferal page is loaded for referance if catagories check fails
$referal_loc = $HTTP_SERVER_VARS['HTTP_REFERER'];
$this->catagory = $url_constants;
if($catagory == ""){
	header("Location:".$referal_loc);
	}
	elseif($catagory(!is_array($catagory_array()))){
	header("Location:".$referal_loc);
	}
		else{
		query($catagory);
		}
}

function catagory_array(){

//associative array set for catagories, used for checking in a later step of the catagory 
//selection process
$catagory_array = array(
$cats_list => "earings",
$cats_list => "necklaces",
$cats_list => "bracelets",
$cats_list => "anklets",
$cats_list => "hair accessories",
$cats_list => "alchemy gothic range",
$cats_list => "brooches",
	);
}

function query($catagory){//including the debugging steps
global $referal_loc;
echo "the catagory is". $catagory .".<br /><br />". $referal_loc.".<br /><br />";
if(!$product){
echo "Error starting class";
}
elseif($catagory(is_array($catagory_array()))){
	$catagory_query($catagory);
	}
}
}

 

I cant work out why nothings being echo'd to make sure thigns are getting set and stuff, any help would be awesome

Link to comment
https://forums.phpfreaks.com/topic/101515-why-wont-this-work/#findComment-519434
Share on other sites

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.