4WebHelp
 FAQ  •  Search  •  User Groups  •  Forum Admins  •  Smilies List  •  Statistics  •  Rules   •  Login   •  Register
Toggle Navigation Menu

 Why doesn't code work?
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic
Author Message
brainfuelmedia
Junior WebHelper
Junior WebHelper


Joined: 28 May 2002
Posts: 5
Location: Canada

PostPosted: Tue May 28, 2002 4:21 pm (15 years, 4 months ago) Reply with QuoteBack to Top

Any idea why this won't work??

<?php

$id = "agr_lig_liq_+Calcium_6%";

//split the id into component parts
$idCut = explode("+", $id);

//get the $path in form - e.g. agr_lig_liq_
$path = $idCut[0];

//change $path to a valid path
$path = ereg_replace("_", "/", $path);

//get the text path
$txtPath = "prod_txt/" . $path;

//get the pdf path
$pdfPath = "pdfs/" . $path;

//get the product id
$prodId = $idCut[1];

//set the prod title for the page
$prodTitle = ereg_replace("_", " ", $prodId);

//get the main category icon and title for the page
$type = explode("_", $idCut[0]);
$type = type[0];
$catIcon = "logo_front_" . $type . ".gif";
$catTitle = "prod_title_" . $type . ".gif";

//so now we have $txtPath, $pdfPath, $prodTitle, $catIcon, and $catTitle
?>

Thanks to all,
Ryan

<mod edit>Subject edited</mod edit>
OfflineView User's ProfileFind all posts by brainfuelmediaSend Personal MessageVisit Poster's WebsiteYahoo Messenger
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Tue May 28, 2002 4:22 pm (15 years, 4 months ago) Reply with QuoteBack to Top

If you could be more precise, it would help. What do you mean by "it won't work"?

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
brainfuelmedia
Junior WebHelper
Junior WebHelper


Joined: 28 May 2002
Posts: 5
Location: Canada

PostPosted: Tue May 28, 2002 4:29 pm (15 years, 4 months ago) Reply with QuoteBack to Top

When I try to execute this code in a web page, in this case "product.php", the page will not execute. If I remove the code from the web page, the web page renders, but of course the variables listed in the html portion of the page are empty because the php code is no longer there.

It appears to me that I am either missing something in the php code (i.e. a syntax mistake, mis-used operator, etc.) or the cgi server this code is running on is restricting something in this php code.

I'm confused... Very Happy

BTW, thanks for the quick reply.

Ryan
OfflineView User's ProfileFind all posts by brainfuelmediaSend Personal MessageVisit Poster's WebsiteYahoo Messenger
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Tue May 28, 2002 4:44 pm (15 years, 4 months ago) Reply with QuoteBack to Top

When you run product.php on its own, does an error appear?

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
Justin
4WebHelp Addict
4WebHelp Addict


Joined: 07 Jan 2002
Posts: 1060

PostPosted: Tue May 28, 2002 4:59 pm (15 years, 4 months ago) Reply with QuoteBack to Top

I just ran it on it's own, and I got :

Parse error: parse error in /hsphere/local/home/justin/dev.ecddns.com/test.php on line 28
OfflineView User's ProfileFind all posts by JustinSend Personal MessageSend email
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Tue May 28, 2002 5:01 pm (15 years, 4 months ago) Reply with QuoteBack to Top

Change:
Code:
$type = type[0];
to
Code:
$type = $type[0];

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
brainfuelmedia
Junior WebHelper
Junior WebHelper


Joined: 28 May 2002
Posts: 5
Location: Canada

PostPosted: Tue May 28, 2002 5:05 pm (15 years, 4 months ago) Reply with QuoteBack to Top

I just got another email pointing that out... told you I was a newbie Very Happy

Thanks for the help!!

I have another question now though. Sorry...

I want a user to be able to click on a link from another page:

i.e. <a href="product.php?id=agr_lig_liq_+Calcium_6%">Calcium 6%</a>

and the product.php page to recieve the variable $id from this refering page.

Is the above method the correct way to do this?? Do I need to put this information in a form?? Do I need a submit button??

Thanks for you help again,
Ryan

PS if you need example pages I can include a link for you.
OfflineView User's ProfileFind all posts by brainfuelmediaSend Personal MessageVisit Poster's WebsiteYahoo Messenger
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Tue May 28, 2002 5:06 pm (15 years, 4 months ago) Reply with QuoteBack to Top

If you plan on including the ID in the URL, no form is needed.

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
brainfuelmedia
Junior WebHelper
Junior WebHelper


Joined: 28 May 2002
Posts: 5
Location: Canada

PostPosted: Thu May 30, 2002 6:34 pm (15 years, 4 months ago) Reply with QuoteBack to Top

Thank You!!
OfflineView User's ProfileFind all posts by brainfuelmediaSend Personal MessageVisit Poster's WebsiteYahoo Messenger
Display posts from previous:      
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic


 Jump to:   




You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot edit your posts in this forum.
You cannot delete your posts in this forum.
You cannot vote in polls in this forum.


Page generation time: 0.051263 seconds :: 17 queries executed :: All Times are GMT
Powered by phpBB 2.0 © 2001, 2002 phpBB Group :: Based on an FI Theme