The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.
Okay, I'm trying to get a signature that changes images every time you refresh or go to a different page with my posts on it. However, I can't seem to figure out how to get it right.
Apparently, there's some sort of script or file that I have to have in order to do this properly, but I'm not sure what it is. Google has yielded pretty crappy results as far as help goes, so please don't post the picture of Angry Gary Coleman shouting, "GOOGLE, MOTHERFUCKER! DO YOU USE IT?!" Please?
Either of those within the first couple of links has complete scripts that show how to do something like this. So you throw a page with a script like that up somewhere and point your sig to it.
Note: I'm not positive that this will work as I haven't tried putting a non-image link into the sig.
I am totally inept at coding, I guess. I wasn't sure how to edit the code you posted so it would work for me, so I went to this site here and more or less came up with this:
(Edit: I just found out that you can't use HTML in sigs, so this is rather pointless now. Still, here if anyone wants it)
I actually wrote a little java script last year for the webpage at work that does just this. And here it is.
var Images = new Array()
Images[0] = '/source_to_image/here.jpg'
Images[1] = '/source_to_image/also_here.png'
var j = 0
var p = Images.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
preBuffer[i] = new Image()
preBuffer[i].src = Images[i]
}
var whichImage = Math.round(Math.random()*(p-1));
function showImage(){
document.write('<img src="'+Images[whichImage]+'">');
}
Just add more images to the array, and put in their sources. Note that the more pics you have in the array, the more effective this script will be (for example, the same pic being shown twice will be less likely). The page that displayed the pic the script chose looked something like this:
Of course, there's no reason you couldn't lump the script and page into one entity, but I'll leave that up to you. You also don't have to position the thing centre, but I did for the page I made. Hope this proves simple enough to use.
I am totally inept at coding, I guess. I wasn't sure how to edit the code you posted so it would work for me, so I went to this site here and more or less came up with this:
Well right away I see a potential problem... you have two <?php right away, and then a ?>. This is basically opening and closing the PHP code blocks. So the ?> may be closing off the entire thing in which case none of the subsequent code is happening. Take out the <?php and ?> around the include line because you don't need them since you're already in a PHP code block. I'm also not even sure why you have the include line there at all?
Also this probably won't work if you can't put HTML in a sig. Because all this is doing is making an HTML page with a single image on it. The code I posted is actually sending itself as an image file (that's what the header stuff is doing).
Here's an edited version of my code to do what you want.
<br />
<b>Warning</b>: readfile(/music/signature/1.gif): failed to open stream: No such file or directory in <b>/srv/www/htdocs/web4/html/music/signature/Signature.php</b> on line <b>17</b><br />
You may want to just try putting the images in the same folder as the PHP script, at least to test to see if it's working. Then change the path to:
$image_path = $image_name;
I'm guessing it's having an issue about actually finding the picture, because it is at least trying to open the image.
Times like this I wish I knew PHP. Is there a default working folder that you need to escape out of? Do you need to specify that /music/signature is mounted from your account's home folder rather than from the current location of the script itself?
I would think that it's liiiiiikely got something to do with that. You could try Daenris's suggestion and just use the same folder for both. I'd suggest also using sensible folder naming conventions, like /images/signature instead of /music/signature but I'm a freak that way :P
Pheezer on
IT'S GOT ME REACHING IN MY POCKET IT'S GOT ME FORKING OVER CASH
CUZ THERE'S SOMETHING IN THE MIDDLE AND IT'S GIVING ME A RASH
Times like this I wish I knew PHP. Is there a default working folder that you need to escape out of? Do you need to specify that /music/signature is mounted from your account's home folder rather than from the current location of the script itself?
I would think that it's liiiiiikely got something to do with that. You could try Daenris's suggestion and just use the same folder for both. I'd suggest also using sensible folder naming conventions, like /images/signature instead of /music/signature but I'm a freak that way :P
Yeah... or alternatively to my suggestion earlier of using the same folder, you could try using an absolute path which may work. Like use "http://www.mywebsite.com/music/signature" as the folder. Though I haven't tested that either, and the first thing I would do is use the same folder, just to make sure the script is otherwise working. After you know that it's working you can worry about fixing the path information.
Edit: Okay, I actually did just test it and it is a path issue. Using a path relative to your site base like /music/signature doesn't work. If you use an absolute path (http://...... as above) it works. If you use something relative to where your script is (like ../music/signature) it will work. As an example I have my script in a folder called test on my root directory. I put the images into music/signature off my root directory. So in my script I used ../music/signature (so up one directory from test, then music/signature) and it works.
Okay, but what is the actual link starts out with music.blahblahblah.etc/signature? Could that be an issue? I've thrown everything into the same folder, which, in my web editor shows up as /html/music/signature.
If you mean the link to put in the script to access the image, like I said if they're in the same folder as the PHP script you don't need to list a folder. Just use the image name alone as the location.
If you mean the link to put in the script to access the image, like I said if they're in the same folder as the PHP script you don't need to list a folder. Just use the image name alone as the location.
What I'm trying to say is all of my links start look something like this: "music.fenproduction.thibros.com/blahblahblah" 'cause nothing shows up any other way. Would this cause a problem with paths or would it not make a difference?
Edit: Also, my signature.php file is in my /music/signature folder.
I'm really not sure what you're asking. What links?
Edit: Can you post the exact code you're using right now? If they're in the same folder you don't need to use anything other than the image name. So just "1.gif" or whatever. You can completely eliminate the $image_path. If they're in another folder you need to reference the path using either paths relative to the script (like "../blah/1.gif") or an absolute path (like http://blah.com/images/1.gif).
Edit2: Also, so you know... those images you have and are trying to use are over the 50kb recommended size for forum sigs on here.
Oh... I know why they're bigger... I saved them as bitmaps in MSPaint and uploaded them to my provider like a stupid poopyhead instead of saving them as gifs in GIMP like a smart person.>_< Problem solved.
Edit: Also, that parse error isn't the same problem. That was showing up because you close quotes around /music/signature" but didn't open them. Of course, as I mentioned the script wouldn't have worked as it was anyway. But let me know if the above works (it should).
No problem. It still seems to choke for me on like... one image I think. Not sure which one, but you might want to double check on the format that they're in or something.
To put it in your signature, just use the img tags within the signature edit box:
[html]
[/html]
Because it won't accept it if you just try to put it in the signature image link field below that.
Heh... while I appreciate the props, your sig should only be 80px high total. Since your image is 500x80 (the max size for a sig) you can't also include text with it. If you want any lines of text there you'll need to make the sig image shorter.
Posts
http://www.google.com/search?source=ig&hl=en&rlz=&q=javascript+random+image+display&btnG=Google+Search
Or PHP
http://www.google.com/search?hl=en&safe=off&q=php+random+image+display&btnG=Search
Either of those within the first couple of links has complete scripts that show how to do something like this. So you throw a page with a script like that up somewhere and point your sig to it.
Note: I'm not positive that this will work as I haven't tried putting a non-image link into the sig.
I just did a quick thing in php using the second link from that google search as a base and tested it in my signature, and it appears to work.
Then you just insert an image in your sig using IMG tags (it doesn't appear to work to just point the sig to the image).
And do you have images in the folder with the code for it to display?
Basically, my code up there generates a random number from 0-3 and will display the corresponding image from the same folder (img0.jpg, img1.jpg...)
I actually wrote a little java script last year for the webpage at work that does just this. And here it is.
Just add more images to the array, and put in their sources. Note that the more pics you have in the array, the more effective this script will be (for example, the same pic being shown twice will be less likely). The page that displayed the pic the script chose looked something like this:
Of course, there's no reason you couldn't lump the script and page into one entity, but I'll leave that up to you. You also don't have to position the thing centre, but I did for the page I made. Hope this proves simple enough to use.
Well right away I see a potential problem... you have two <?php right away, and then a ?>. This is basically opening and closing the PHP code blocks. So the ?> may be closing off the entire thing in which case none of the subsequent code is happening. Take out the <?php and ?> around the include line because you don't need them since you're already in a PHP code block. I'm also not even sure why you have the include line there at all?
Also this probably won't work if you can't put HTML in a sig. Because all this is doing is making an HTML page with a single image on it. The code I posted is actually sending itself as an image file (that's what the header stuff is doing).
Here's an edited version of my code to do what you want.
I haven't tested it but this should do what you want it. Then you put it into the Signature box using IMG tags pointed at the PHP script location.
There's a guy on another forum with a rotating signature and apparently it's saved a .cgi.
So far, it doesn't matter what I do to the pages, I end up with a blank page or a page with just ;?> on it.
It seems to have worked for me. I tried it yesterday after posting some sample code.
It's also significantly more badass to just use the htaccess tricks so that normal people can't figure out how the image changes all the time.
CUZ THERE'S SOMETHING IN THE MIDDLE AND IT'S GIVING ME A RASH
I used Daenris' modified code and made a .php file.
Here's the link: http://music.fenproductions.thibros.com/signature/Signature.php
Here's what the page source looks like:
Where did I go wrong?
CUZ THERE'S SOMETHING IN THE MIDDLE AND IT'S GIVING ME A RASH
$image_path = $image_name;
I'm guessing it's having an issue about actually finding the picture, because it is at least trying to open the image.
I would think that it's liiiiiikely got something to do with that. You could try Daenris's suggestion and just use the same folder for both. I'd suggest also using sensible folder naming conventions, like /images/signature instead of /music/signature but I'm a freak that way :P
CUZ THERE'S SOMETHING IN THE MIDDLE AND IT'S GIVING ME A RASH
Yeah... or alternatively to my suggestion earlier of using the same folder, you could try using an absolute path which may work. Like use "http://www.mywebsite.com/music/signature" as the folder. Though I haven't tested that either, and the first thing I would do is use the same folder, just to make sure the script is otherwise working. After you know that it's working you can worry about fixing the path information.
Edit: Okay, I actually did just test it and it is a path issue. Using a path relative to your site base like /music/signature doesn't work. If you use an absolute path (http://...... as above) it works. If you use something relative to where your script is (like ../music/signature) it will work. As an example I have my script in a folder called test on my root directory. I put the images into music/signature off my root directory. So in my script I used ../music/signature (so up one directory from test, then music/signature) and it works.
If it's in a folder named signature, and named signature.php, then the link to put in an img tag in your signature would be like http://www.blah.com/music/signature/signature.php
If you mean the link to put in the script to access the image, like I said if they're in the same folder as the PHP script you don't need to list a folder. Just use the image name alone as the location.
What I'm trying to say is all of my links start look something like this: "music.fenproduction.thibros.com/blahblahblah" 'cause nothing shows up any other way. Would this cause a problem with paths or would it not make a difference?
Edit: Also, my signature.php file is in my /music/signature folder.
Edit: Can you post the exact code you're using right now? If they're in the same folder you don't need to use anything other than the image name. So just "1.gif" or whatever. You can completely eliminate the $image_path. If they're in another folder you need to reference the path using either paths relative to the script (like "../blah/1.gif") or an absolute path (like http://blah.com/images/1.gif).
Edit2: Also, so you know... those images you have and are trying to use are over the 50kb recommended size for forum sigs on here.
Like, the link to my avatar is "http://music.fenproductions.thibros.com/avas/GoldenSeducer.png" The URL starts with "music."
Anyway, the actual script I'm using right now is this (and God, I hope I haven't gone in circles. I'm so inept at coding...):
I still get the "There's an error in line 7" message when I try to view the page. (http://music.fenproductions.thibros.com/signature/signature2.php)
Here... put exactly this into signature.php and see if it works.
Edit: Also, that parse error isn't the same problem. That was showing up because you close quotes around /music/signature" but didn't open them. Of course, as I mentioned the script wouldn't have worked as it was anyway. But let me know if the above works (it should).
Oh, the image lines were me trying to experiment a little. It was a failed attempt.
To put it in your signature, just use the img tags within the signature edit box:
[html]
[/html]
Because it won't accept it if you just try to put it in the signature image link field below that.