Beginner Help Urgently Needed

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
stub
Forum Newbie
Posts: 8
Joined: Tue Mar 01, 2011 2:11 am

Beginner Help Urgently Needed

Post by stub »

OK. I inherited some PHP script code, but I seem to have messed something up. I can't seem to figure out how to fix.

So it appears to be missing "portfolio.php" between the last "/" and the "?" I would have thought this would have been easy to spot and fix, but I just cannot figure it out.

Any help would be gratefully received.
Last edited by stub on Sat Mar 05, 2011 6:56 am, edited 1 time in total.
Peter Kelly
Forum Contributor
Posts: 143
Joined: Fri Jan 14, 2011 5:33 pm
Location: England
Contact:

Re: Beginner Help Urgently Needed

Post by Peter Kelly »

For starters your going to have to show us your code as we cant help if we cant see.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Beginner Help Urgently Needed

Post by John Cartwright »

Please use descriptive titles, and avoid the usage of words like "Urgent", since we treat all threads here with equal priority (yours is no different).

Thanks.
stub
Forum Newbie
Posts: 8
Joined: Tue Mar 01, 2011 2:11 am

Re: Beginner Help Urgently Needed

Post by stub »

OK. Here's the code for the working website

And here's the code for the non-working website
Last edited by stub on Sat Mar 05, 2011 6:47 am, edited 3 times in total.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Beginner Help Urgently Needed

Post by John Cartwright »

We need to see the PHP code, not the html.

And please only post the relevant code (or what you think it may be).. posting entire large scripts is difficult to follow.

EDIT | You updated your code, cool.
stub
Forum Newbie
Posts: 8
Joined: Tue Mar 01, 2011 2:11 am

Re: Beginner Help Urgently Needed

Post by stub »

OK I fixed the code in the time it took you to write your message, as I realized I'd posted the wrong code. See corrected code above. I have no idea where the problem is except that it's to do with the linking to the Categories, as I posted in my introductory message.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Beginner Help Urgently Needed

Post by Jonah Bron »

Here's the diff.

-- removed upon request --

As you can see, the only change that's not a comment is line 95. I suggest you revert the change and see what happens.
Last edited by Jonah Bron on Sun Mar 06, 2011 9:33 pm, edited 1 time in total.
stub
Forum Newbie
Posts: 8
Joined: Tue Mar 01, 2011 2:11 am

Re: Beginner Help Urgently Needed

Post by stub »

I tried that. But it didn't work. It would only show the index page. I had to revert back to show the portfolio page. So does that suggest the problem lies within the included $template/portfolio.php, compared to the original $template.index.php (which are mostly html code). Should I post those files instead?

What I actually did was to move the Categories away from the index page and to show them only on the (new) portfolio page. I did this by copying the index.php in both the main main folder and in the templates folder to a portfolio.php in these folders. Then I removed any reference to categories in the index files. I'm pretty sure I had this working at some point. But now the non-working page isn't showing the portfolio.php between the "/" and the "?". I'm pretty sure this is where the problem lies. But don't see why it is happening.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Beginner Help Urgently Needed

Post by Jonah Bron »

Is error reporting enabled? If not, enable it. That may help pin down the problem.
stub
Forum Newbie
Posts: 8
Joined: Tue Mar 01, 2011 2:11 am

Re: Beginner Help Urgently Needed

Post by stub »

The problem is, it's not reporting an error, it's serving up the index page.
It appears to be missing "portfolio.php" between the last "/" and the "?" I would have thought this would have been easy to spot and fix, but I just cannot figure it out.
Last edited by stub on Sat Mar 05, 2011 6:54 am, edited 1 time in total.
Peter Kelly
Forum Contributor
Posts: 143
Joined: Fri Jan 14, 2011 5:33 pm
Location: England
Contact:

Re: Beginner Help Urgently Needed

Post by Peter Kelly »

Try change

Code: Select all

$catidsort = (!is_null($catid) ? "&cat=$catid" : '');
to

Code: Select all

$catidsort = (!is_null($catid) ? "portfolio.php&cat=$catid" : '');
P.S if this is wrong I'm sorry currently in work only able to glance.
stub
Forum Newbie
Posts: 8
Joined: Tue Mar 01, 2011 2:11 am

Re: Beginner Help Urgently Needed

Post by stub »

Nope that didn't work.

Now this is the same as the source code when I view the source code for the original code. But I need "./?cat=1" to be reading "./portfolio.php?cat=1". Since we have already eliminated the source code in /portfolio/portfolio.php (we've seen it's the same code) it must be in the template file /portfolio/templates/default/portfolio.php, or a setting for the root directory somewhere? Yes/No?

I've just noticed something about the original code. the line quoted above shows exactly what I want "./portfolio/portfolio.php?cat=1" when hovered over in firefox. So I think this line (quoted above) should be and is the same in both, and it's just a directory setting problem (maybe). And so the question is, why doesn't the updated code show the complete link and how to fix it? I still think this is a simple fix, but I just cannot figure it out for myself (yet).

The strange thing is, I'm sure I had this working at some point.
Last edited by stub on Sat Mar 05, 2011 6:52 am, edited 2 times in total.
stub
Forum Newbie
Posts: 8
Joined: Tue Mar 01, 2011 2:11 am

Re: Beginner Help Urgently Needed

Post by stub »

OK. I think I've found the errant line of code.
Last edited by stub on Sat Mar 05, 2011 6:59 am, edited 2 times in total.
stub
Forum Newbie
Posts: 8
Joined: Tue Mar 01, 2011 2:11 am

Re: Beginner Help Urgently Needed

Post by stub »

OK. I fixed it. It was in the functions.php file in the /includes directory, Added the "portfolio.php" there.
$listhtml .= "<li$class><a href=\"./portfolio.php?cat=$cat[catid]\" title=\"$cat[description]\">$cat[title]</a> ($cat[numdomains])</li>\n";
I would be grateful if Jonah could delete the code he quoted when comparing the two files. Thank you.
Post Reply