thejake420 Posted July 11, 2007 Share Posted July 11, 2007 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 Quote Link to comment Share on other sites More sharing options...
btherl Posted July 11, 2007 Share Posted July 11, 2007 Try this: $res2 = mysql_query("SELECT COUNT(*) FROM $gallery_pictures WHERE aid = {$row['aid']}"); Quote Link to comment Share on other sites More sharing options...
mosi Posted July 11, 2007 Share Posted July 11, 2007 One thing I noticed in your variables, your missing a ; at the end of: $cpgdb_prefix = "freeclip_" Quote Link to comment Share on other sites More sharing options...
maxudaskin Posted July 11, 2007 Share Posted July 11, 2007 One thing I noticed in your variables, your missing a ; at the end of: $cpgdb_prefix = "freeclip_" That would do it... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.