Discussion
Captions not saving correctly(back to index)I'm using Folderblog 3.0 Beta and everything is functioning properly except the captions that are being saved do not have the image name in the beginning of the file name. They are simply saved as _com.txt. Any ideas what could be causing this?
This thread is being recreated from an issue here for the sake of simplicity:
http://folderblog.org/discussion/1563
posted by
suffrin on 11 Dec 05 at 11:30 AM
Can you tell me which line of code creates the comment file in fb.php?
I assume this is the line:
$file = fopen("$comments_directory{$image}_com.txt", "a");
fwrite($file, stripslashes("$comment<>$name<>$date<>" . str_rot13($email) . "\n"));
I am running IIS, don't know if that is relevant
posted by suffrin on 11 Dec 05 at 11:40 AM
I placed
echo("$comments_directory{$image}_com.txt");
just below fwrite and it returned "comments/_com.txt" after submitting a comment
so then I tried
echo("$image");
and it returned nothing after submitting a comment
Could the problem be that $image is not being assigned correctly somehow?
posted by suffrin on 11 Dec 05 at 12:25 PM
Yes, exactly that is the problem. Now I would advise you to trace back where the $image variable is set.
posted by
ikue on 11 Dec 05 at 5:09 PM
Sorry, I'm having trouble understanding some things here and I don't know how to debug php because echo isn't working when I insert it in a function. $image appears to be defined here
$image = get("image");
using the get() function
function get($key) {
global $_POST;
if (array_key_exists($key, $_POST)) {
return (ini_get("magic_quotes_gpc")==1) ? stripslashes(trim(htmlspecialchars($_POST[$key]))) : trim(htmlspecialchars($_POST[$key]));
}
return false;
}
What I don't understand is what is the $_POST variable and how do I determine if or where "image" is in this array? if I try to put an echo command in this function the page simply does not load after I post a comment. If I echo("$_POST"); after fwrite, it simply returns "Array". Any ideas? Sorry for all the questions, there's just so little I know about PHP at the moment.
posted by suffrin on 12 Dec 05 at 4:34 PM
$_POST is a variable returned automatically by a server if you give any parameters to a website (e.g. fb.php?image=12345.jpg)
$_POST is indeed an array, and arrays have to be printed instead of echoed, try "print_r($_POST);". Then you see the existing contents.
By the way, echo always works, also in functions. With regard to your general problem, it seems fb gets no image name from the parameters. What is the URL you use when opening the fb website?
posted by
ikue on 13 Dec 05 at 2:38 AM
ikue, you are a tireless saint. You have helped me to fix my problem.
I got this returned after posting a comment using print_r($_POST); immediately after get("image");
Array ( [comment] => Test [name] => Test Commenter [email] => test@test.com [url] => http://test.com [doComment] => Submit Comment [cookie] => 1 )
I noticed there was no "Image" in this array and I started looking at the form code in the almanac template and noticed that the post data contained information from each of the fields showing up in $_POST. From there I started comparing templates and noticed that the following field was missing from the almanac template under the form data:
<input type="hidden" name="image" value="<#fbimagename#>" style="display: none;" />
Once I inserted this into the form it worked. The problem was in the almanac_main.php and here is the final code for the form for anyone who would like to cut and paste later.
<form method="post" action="<#fbcommentslink#>">
<div class="comform">
<textarea style="width: px;" cols="40" rows="4" name="comment"><#fbcomval#></textarea>
<input style="width: px;" name="name" size="44" maxlength="20" value="<#fbnameval#>" /> Name
<input style="width: px;" name="email" size="44" maxlength="40" value="<#fbemailval#>" /> Email
<input style="width: px;" name="url" size="44" maxlength="100" value="<#fburlval#>" /> URL
<input type="hidden" name="image" value="<#fbimagename#>" style="display: none;" />
<input id="submit" type="submit" value="Submit" name="doComment" /> <input id="check" type="checkbox" name="cookie" value="1" <#fbchecked#> /> Remember me</span>
</div>
</form>
posted by
suffrin on 13 Dec 05 at 1:28 PM
this is a link to the blog, btw:
http://www.mutechanteuse.com/motes
posted by
suffrin on 13 Dec 05 at 1:44 PM
I am really glad I could help you, although I also have to congratulate you to your detective sense! ;) Really a stupid hidden little bug with huge implications...
Take care!
posted by
ikue on 14 Dec 05 at 2:20 AM
Thank you both for pointing this out. But in my newest version of alamanac which is for the lastest official beta 3.16 this line of code is already integrated, but comments only work on the newest image, that is:
http://www.jowra.de/fb316/fb.php/
At the image "big one" comments work, but at all other images, there simply is happening nothing. No _com.txt or so, simply nothing.
If you need the new package for testing you can find it here:
http://www.jowra.de/downloads/almanac3.16.zip
Any ideas?
/www.jowra.de/downloads/
posted by
Jowra on 16 Dec 05 at 7:42 AM
Then there still seems to be a problem that fb just does not handle correctly the parameters (the image filename). First, do one thing: Compare the template codes of yours and the relaxation theme (which works fine on my blog), and if there are not any problematic differences do the same with the final output of these websites.
If that still doesnt work, we have to start some debugging internally in folderblog...
posted by
ikue on 18 Dec 05 at 7:47 AM
Post a Reply:
(back to index)