Jump to content
xisto Community
caronthegerman

Random Image Rotation (change Image, Title, Url, Etc.) I require a script for this.

Recommended Posts

Hey guys,I've been trying to make a random image rotator that changes the url specifically so that the visitor can save the picture as a favorite or bookmark. All those I have tried will only show a random picture but the url continually remains at or others. I know I could make a php script that chooses randomly from many urls but that would mean I have to create an html file for every single one of my 150+ pictures that I want to rotate throughThanks for any help,Caron

Edited by moderator
The link provided had obscene material (see edit history)

Share this post


Link to post
Share on other sites

Sorry for double posting, seems like I can't edit my post ten minutes after posting..Anyways, using mod_rewrite, you can use PHP to choose a picture using $_GET, and then make the extension look like .jpg.html or whatever you want it to look like instead of ?picture=blabla.jpgIs that what you are looking for?Regards/Feelay | Nanashi

Share this post


Link to post
Share on other sites

Sorry for double posting, seems like I can't edit my post ten minutes after posting..
Anyways, using mod_rewrite, you can use PHP to choose a picture using $_GET, and then make the extension look like .jpg.html or whatever you want it to look like instead of ?picture=blabla.jpg
Is that what you are looking for?

Regards
/Feelay | Nanashi



Does this make the url be savable? Like if I change the url of a certain picture on the page that randomly selects one and a user saves that url and opens it the next day, will it show the same picture it did when he first saw it?

Share this post


Link to post
Share on other sites

Does this make the url be savable? Like if I change the url of a certain picture on the page that randomly selects one and a user saves that url and opens it the next day, will it show the same picture it did when he first saw it?

Yeah, it would be enough to just use the PHP $_GET function to show a certain picture, but it's still a little complicated..

My tip is that you insert every image name (example, image.jpg) in a database (the ID will be set automatically if you make it auto increase), and then you use the id of the database row to decide which picture to show.
For example:

<?php		$image_id=$_GET['imageid']; //The ID of the image	$get_image=mysql_query("SELECT * FROM `images` WHERE `image_id`='{$image_id}'"); //Check if the ID exists in the database	$array_image=mysql_fetch_array($get_image); //Array the query		$get_all_images=mysql_query("SELECT * FROM `images`"); //count all images so that we can check if the "next" button should show or not	$count_images=mysql_num_rows($get_all_images); //Count all the images		if(mysql_num_rows($get_image)==0) //If the imageID is not found in the database, echo an error	{		echo "Image not found";	}	else //Else, show the image	{?>		<div class="image">			<img src="images/<?php echo $array_image['image_name']; ?>" alt="<?php $array_image['image_name']; ?>" /> <!-- I set the directory as "images" as you can se, and then the name of the picture, which I assume is, for example, test.jpg -->		</div><?php	}		if($image_id>1)//If the current image_id is greater than 1, show the previous button	{?>		<a href="?imageid=<?php echo $imageid--; ?>">Previous</a><?php	}	if($image_id<$count_images) //If the current image_id is smaller than the total amount of images in the database, show the next button	{?>		<a href="?imageid=<?php echo $imageid++; ?>">Next</a><?php	}?>

Now if you try to type http://www.example.com/?imageid=20, you should see the picture that has ID 20 in the database.

Is this what you want?

Regards
/Feelay | Nanashi
Edited by Feelay (see edit history)

Share this post


Link to post
Share on other sites

I'm sort of new to this sort of thing. How do I add this stuff to a database? It's not like adding stuff to a directory on my server, right? Then I do what with the php code? Could you explain this step by step for me please. This php stuff is still kind of confusing for me.Oh and that's exactly what I want. Thanks. :)

Share this post


Link to post
Share on other sites

Well.. To begin with, do you have a database account?And have you ever created a table inside a database before?



I have a hosting plan and a domain with Dreamhost. I also have an MySQL database with my domain. However, I've never made a table inside a database before as far as I know. I did, though, make the database for my phpBB3 forum on this.

Share this post


Link to post
Share on other sites

Do you use PHPMyAdmin to manage the database?


I haven't but I will look up on that now.




Hi guys
This is butch. I just want to ask if what kind of programming languages used to develop the tunatic software?Is this Java?Is this C,C++,C#?I really need the answer guys.

Thank you!


Make your own topic.

Share this post


Link to post
Share on other sites

Great!
Tell me when you've learned how to make your own tables and insert new rows with PHPMyAdmin!




Well i've been trying and trying to install phpmyadmin on my snow leopard, but I can't find out what my username and password is. Apparently my username is root (installation guide) but I have no idea how to get my password. I searched the internet countless times, tried my ftp password, tried every password I could think of, but it still didn't work. I don't know what to do. D:

Share this post


Link to post
Share on other sites

If you've installed PHPMyAdmin on your PC, and if you are trying to connect to your local database server, you'll have to install MySQL.Else if you want to connect to your hosted database, you'll have to figure out how to change the server you are trying to connect to using PHPMyAdmin, because I'm afraid I don't know how to do that =/

Share this post


Link to post
Share on other sites

If you want to setup phpmyadmin on your own server then you will have to write your own config file containing the username and password. There is an install script that comes with phpmyadmin that can help you with this however I've never used it.

 

You can use this config to simply define the username and password then phpmyadmin assumes the default host is localhost, however you can define many different config settings in this config file to change that.

 

If you are wanting to setup a local copy of phpmyadmin however are wanting it to connect to your database on a hosted account somewhere on the web etc. then you will have to be careful as this can be both a massive security threat and also impossible in some cases as certain web hosts do not allow external connections to mysql and all access must be done locally.

 

A good working example of how to create your config file can be found here http://forums.xisto.com/no_longer_exists/

To get started, you'll need to create a file named config.inc.php directly within your phpMyAdmin directory. (There may be a config.sample.inc.php file in there already and, if you wish, you can create a copy of it and name it config.inc.php to use it as a template.)

 

Note: phpMyAdmin first loads libraries/config.default.php and then overrides those values with anything found in config.inc.php. If the default value is okay for a particular setting, there is no need to include it in config.inc.php. You'll need a few directives in your config.inc.php file though to get going and a simple configuration may look like this:

 

 

<?php

$i=0;

$i++;

$cfg['PmaAbsoluteUri'] = 'http://forums.xisto.com/no_longer_exists/&%2339;;

$cfg['Servers'][$i]['host'] = 'MySQL.example.com';

$cfg['Servers'][$i]['auth_type'] = 'cookie';

$cfg['blowfish_secret'] = 'Joey did 125 jumping jacks Tuesday morning!';

$cfg['Servers'][$i]['user'] = '';

$cfg['Servers'][$i]['password'] = '';

?>

 

Your settings need to be entered in between the ' ' marks after the equal signs. A description of the settings follows, as well as the specific changes you need to make to the above sample configuration to have it work on your FutureQuest hosting package:

 

$cfg['PmaAbsoluteUri'] = 'http://forums.xisto.com/no_longer_exists/&%2339;; -- replace example.com with your domain name and pma with the name of the directory that contains your phpMyAdmin files

 

$cfg['Servers'][$i]['host'] = 'MySQL.example.com'; -- replace example.com with your domain name

 

$cfg['Servers'][$i]['auth_type'] = ''; -- dictates the authentication method used when connecting to your phpMyAdmin installation - see below

 

The options for authentication are:

cookie (recommended method)

http

config

signon

cookie and http authentication methods - These methods are considered more secure than the config method, as your username and password are not stored on the server in your configuration file.

 

The 'http' option uses the Apache http authentication method. The 'cookie' method uses cookies and has the advantage that you can "Log Out" at the end of your session, deleting the cookie. The above sample config.inc.php file is based on the cookie authention mode.

 

config method - This method requires storing your MySQL username and password in the file on the server. Therefore, if you choose to use the config option, you will need to be sure to password protect the directory that your phpMyAdmin files reside in as otherwise anyone who would find the directory to your phpMyadmin installation would then be able to access your databases. This is EXTREMELY important. Do not skip the password protection step if you choose the config method. For information on how to password protect directories, visit the Password Protection Tutorial.

 

 

$cfg['blowfish_secret'] = ''; -- used with the cookie method only. If you specified cookie in the auth_type above, type in a random phrase up to 46 characters long for this setting. This passphrase is just used internally to encrypt the password - you will not be prompted for it later.

 

$cfg['Servers'][$i]['user'] = ''; -- MySQL username if you are using config method - otherwise leave blank

 

$cfg['Servers'][$i]['password'] = ''; -- MySQL password only if you are using config method - otherwise leave blank

 

Make sure you don't have any blank lines at the end of the file and save it as config.inc.php.

 

Now, open your web browser and visit

http://forums.xisto.com/no_longer_exists/

(replace example.com with your domain name and pma with whatever directory your phpMyAdmin is in). You should see a welcome page and, after logging in with your MySQL username and password if you used the cookie method above, you will be able to start working with your databases!

 

Important Note: For security reasons, phpMyAdmin now recommends that all installations protect access to the ./libraries and ./setup/lib subfolders in your phpMyAdmin directory. The easiest way to do this is probably just to password protect your entire phpMyAdmin directory. For information on how to password protect directories, visit the Password Protection Tutorial. !!! Remember !!! If you used the config authentication method, you will want to immediately password protect your phpAdmin directory to secure it and prevent general access.

 

FutureQuest strongly recommends password protecting ALL phpMyAdmin installations, even if using the cookie or http authentication options, as extra protection against unauthorized access.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.