Jump to content

Screwed up something in my syntax


thejake420

Recommended Posts

I had a perfectly good script, but when I tried to improve on it by replacing hardcoded URLs with variables, I ended up with a blank page upon execution.

 

The script makes use of two external files:

include "connect.php";
require("sitemap.class.php");

 

I created the variables...

$is_gallery_at_root = "1"; // (As compared to being in a sub-folder of the site)
$the_site = "http://www.mysite.com";
$the_folder = "/gallery/";
$cpgdb_prefix = "freeclip_"
$albumsdef = "albums";
$picturesdef = "pictures";
$gallery_albums = $cpdb_prefix . $albumsdef;
$gallery_pictures = $cpdb_prefix . $picturesdef;

 

I then tried to replace the original:

$res = mysql_query('SELECT aid FROM freeclip_albums ORDER BY aid');

with:

$res = mysql_query("SELECT aid FROM $gallery_albums ORDER BY aid");

 

I set up an if/else to decide whether or not to include a sub-folder in the URL that we'll be using:

if ( $is_gallery_at_root = 1 ) {
$the_gallery = $the_site;
echo $the_gallery;
} else {
$the_gallery = $the_site . $the_folder;
echo $the_gallery;
}

 

I then try to send the appropriate information over to the other script that does the actual writing of the sitemap:

$sitemap->add($the_gallery . 'testsitemap3.php?category=index');

 

And several parts along this theme:

$res = mysql_query("SELECT aid FROM $gallery_albums ORDER BY aid");
while ($row = mysql_fetch_assoc($res)) {
 	$res2 = mysql_query("SELECT COUNT(*) FROM $gallery_pictures WHERE aid = $row['aid']");
 	$count = mysql_result($res2, 0, 0);

 

And a little later on, there's this...

$sitemap->add("$the_gallery ' . 'picture.php?pos=-' . '{$row['pid']}");

 

Ok, so in the above, would someone be kind enough to tell me what (probably obvious) syntax error or errors I'm making? I'm almost sure it's due to a missing quote or curly-bracket somewhere that I didn't think of. I tried so many combinations of single quotes, double quotes, putting variables inside of curly brackets... Basically, anything I could think of, but none of them had the desired effect.

 

Oh... my variables are not within the scope of the functions in sitemap.class.php... I was considering declaring them as global within those functions, but it didn't seem like they would be needed, since they're here to generate the URL and the argument... then those two combined into one complete URL would be passed on in the format of "http://www.site.com/gallery/picture.php?picture=1"

 

Thanks... I appreciate any help that is offered.

 

 

Jake

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.