Jump to content
xisto Community

Feelay

Members
  • Content Count

    275
  • Joined

  • Last visited

Everything posted by Feelay

  1. 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
  2. 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
  3. I think what you are looking for is mod_rewrite. Check it out! This link taught me all I know about mod_rewrite, very useful: http://corz.org/server/tricks/htaccess2.php Welcome to Xisto by the way! Regards /Feelay | Nanashi
  4. My guess is that your database connection is at fault, and now I mean the username, password and host.You should double check it and make sure that it's correct.It's not supposed to be like the ones in the tutorial, it's supposed to be replaced with your MySQL account information =)
  5. Try changingmysql_select_db('register_database');to mysql_select_db('register_database') or die(mysql_error());also, please show my your regcheck.php
  6. Show me your database.phpRemember to hide the username, password and host.
  7. Your question made me curious, so I checked the settings, and then pressed on the "offline"-tab, and there you might find something interesting, I'm not quite sure, but you might want to check it out =)Edit------You might want to press the "read more" link to read about it and make sure it's what you want =)------Regards/Feelay | Nanashi
  8. I know this is a very late reply, but anyways, if you are still working on that website, and if you still haven't solved this problem, try changing "charecters" to "characters" =) If that doesn't work, make sure you have the database table set properly and make sure that the table name that you are referring to is correct by logging in to PHPMyAdmin or whatever software you use to customize your database. You told Yordan that it didn't say anything like that error in the script. The piece of code making that error possible to appear is "or die(mysql_error())". This piece of code helps you debug you SQL-queries. I've learned though that these lines should be removed before releasing the page for security reasons, keep that in mind. (Y) Regards /Feelay | Nanashi
  9. Feelay

    Hey!

    Thanks.Glad to see that you're still alive! (Y)
  10. Hey! Long time no see, I've been off for a while now, taking care of my real life, developing my knowledge and so on. I haven't posted a tutorial here for a very long time. Before I left this forum, Vujsa told me to learn AJAX to be able to make a div refresh without actually refreshing the whole page. And I had a very tough time learning AJAX. I gave up almost directly because I had a very tough time finding a good tutorial. Instead I gave up web developing for more than a year, and some months ago I started working for a company where I developed my knowledge. I recently made a chat that I'm still working on that you can check out, the link will be provided in the end of this tutorial. The chat is written in PHP and AJAX, the language I'm using is Swedish (I'll make an automatic language detection, and translate all the words in the language file when I have time for that), but the point is that this is what you will be able to do if you develop your knowledge in AJAX, and I am going to provide you with the basics, so that you can continue to develop your knowledge. Before we begin, let's make sure you know the basics of the following languages: HTML JavaScript PHP Note that this tutorial is very basic, and that it will only teach you how to load a PHP file into a div, instead of reloading the whole webpage to load the file.For an example of what you'll learn, check out this link: http://feelay.syntaxwebb.se/Xisto/ajaxbasictutorial/ Now let us begin, We'll begin with the index.php file, which will contain some links and a div. <!-------------------------index.php BEGINNING--------------------------><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://forums.xisto.com/no_longer_exists/;--'>http://forums.xisto.com/no_longer_exists/;-- Creator: Feelay | NanashiProject Name: AJAX TutorialVersion Number: 1.0Contact: angelnight93@gmail.comUse this code as you wish.--><html xmlns="http://forums.xisto.com/no_longer_exists/; xml:lang="en" lang="en"> <head> <title>Simple AJAX tutorial</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><?php //I'm including the file ajax.php, because the AJAX-code will be inside another file named ajax.php, this is only to not mess up the index.php, I like my files to be clean. include("ajax.php"); ?> </head> <body> <a href="#">link</a><a href="#">link</a><a href="#">link</a> <div id="container"><?php include("home.php"); ?></div> </body></html><!-------------------------index.php ENDING--------------------------> As you can see, I haven't made anything special to the links yet, but don't you worry about that, we'll get back to this file soon. What I did was to give the DIV an "id". The reason is because when we are working with AJAX, we will "point" our functions to this DIV using its ID. I also included the home.php into this DIV. Now when the page is refreshed, you will see the content of home.php inside it. Now just save this file and create a new file named ajax.php. <!-------------------------ajax.php BEGINNING--------------------------><script type="text/javascript"> //The function load_content is the function we'll use to load the data into the DIV when pressing a link. //As you can see, I'm using parameters to know which link was pressed. //Of course you can add more parameters. I used about five parameters in my //Latest game, to decide which DIV that was supposed to be updated, to decide which file to load, //If I wanted to send any $_GET parameters, if I wanted to run a function when the link was pressed, //And so on. It's all up to your own imagination. But today we'll keep this at a basic level, //We'll just use one parameter, and this parameter will decide which file to load when the link is pressed. //An example is, if the links parameter is set to "contact.php", then the file contact.php will be loaded //Inside the DIV we created in index.php. function load_content(file) { //This try&catch statement is nothing that you have to remember, just save it somewhere //And copy&paste it whenever you want to use AJAX on your webpage. //This is where all the "magic" happens. The variable named xmlhttp contains the XMLHttpRequest, //Which makes it possible to communicate between the server and the client (browser) without refreshing the page. //The try statement tries if the browser supports AJAX, and if it does, then the xmlhttp variable will be set. //If not, the catch statement alerts the alert that you are seeing below. try { var xmlhttp = window.XMLHttpRequest?new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { alert("Warning! Ajax is not supported by your browser!\nYou should upgrade your browser. We recommend that you use Mozilla Firefox.\n Go to https://www.mozilla.org/en-US/firefox/new/?utm_source=firefox-com&utm_medium=referral to download it."); } //Now we'll use the xmlhttp variable that we created above, to check the "readystate". //There are different types of "Readystates", I'll just copy&paste them from the internet, //and try to explain the important ones as good as I can, but most of them are already explained. //I'll just quote what I've not written. If you have more questions about the different "Readystates", //Just ask them, and I'll try to answer them as good as I can. /* "0 Uninitialized" "Represents an "uninitialized" state in which an XMLHttpRequest object has been created, but not initialized." "1 Open" "The open() method has been successfully called." The open method is being used in the bottom of this AJAX function, xmlhttp.open();. "2 Sent" "Represents a "sent" state in which a request has been sent to the server with the send() method, but a response has not yet been received." "3 Receiving" "Represents a "receiving" state in which the HTTP response headers have been received, but message body has not yet been completely received. " "4 Loaded" "The data transfer has been completed.", meaning the data for the DIV should now be ready to be inserted into the DIV in our case. */ //onreadystatechange = function(){---} runs the following function every time the "readystate" changes. //This function contains an if-statement that checks if the readyState equals 4. If it doesn't, nothing will happen. //Of course you can make a loading bar appear or something, but I wont show you how to do that in this tutorial, //Maybe in the next one. //If the readyState DOES equal 4, a familiar JavaScript line will run, and replace the current text inside the DIV, //With the new one that we are getting from the file we are loading. //xmlhttp.responseText -> The text that is being "extracted" or something from the file we are loading by pressing the link. //I wont explain more on this line, because I suppose you already know JavaScript. xmlhttp.onreadystatechange = function() { if(xmlhttp.readyState == 4) { document.getElementById("container").innerHTML=xmlhttp.responseText; } } //The xmlhttp.open is the line that decides which file that will be opened, and also which method to use to open it. //In this case we are using POST, and the file we want to open is set to "file", which is the parameter we set in the function earlier. xmlhttp.open("POST", file); //I've got no comments on the following line, since I've not really figured it out myself. All i know is, //That it needs to contain some sort of data, in this case "null", or else Internet Explorer will act wierd as usual. xmlhttp.send(null); }</script><!-------------------------ajax.php ENDING--------------------------> As you can see, the AJAX isn't that hard, remove all the comments and you'll see that it's only a few lines.I know that it's a lot of text, but I also know that you'll manage =) Now let us fill the missing part of index.php, shall we? <!-------------------------index.php BEGINNING--------------------------><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://forums.xisto.com/no_longer_exists/;--'>http://forums.xisto.com/no_longer_exists/;-- Creator: Feelay | NanashiProject Name: AJAX TutorialVersion Numer: 1.0Contact: angelnight93@gmail.comUse this code as you wish.--><html xmlns="http://forums.xisto.com/no_longer_exists/; xml:lang="en" lang="en"> <head> <title>Simple AJAX tutorial</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><?php //I'm including the file ajax.php, because the AJAX-code will be inside another file named ajax.php, this is only to not mess up the index.php, I like my files to be clean. include("ajax.php");?> </head> <body> <a href="#" onclick="load_content('home.php')">Homepage</a> | <a href="#" onclick="load_content('aboutme.php')">About me</a> | <a href="#" onclick="load_content('enjoy.php')">Enjoy</a> <div id="container"><?php include("home.php"); ?></div> </body></html><!-------------------------index.php ENDING--------------------------> As you can see, I added an onclick-event to every link. Inside the onclick-event, the function "load_content" is inserted, and inside the parenthesis the file name is inserted surrounded by two single-quotations-marks. Now let's create the files home.php, aboutme.php and enjoy.php. <!-------------------------home.php BEGINNING--------------------------><p>This is the homepage. This is how the DIV looks before we mess it up.</p><!-------------------------home.php ENDING--------------------------> <!-------------------------aboutme.php BEGINNING--------------------------><p>Some text about me, I don't really think you are interested.</p><!-------------------------aboutme.php ENDING--------------------------> <!-------------------------enjoy.php BEGINNING--------------------------><p>Hopefully you enjoyed this tutorial! Cheers, Feelay | Nanashi</p><!-------------------------enjoy.php ENDING--------------------------> And as I promised, I'd give you a link of something I've made with AJAX, here you go: http://feelay.syntaxwebb.se/syntaxwebb/chat/ Remember, if you find something wrong with this tutorial, tell me. If you have questions, don't be afraid to ask them, there are no stupid questions. If you find this tutorial too complicated, tell me what part you didn't quite understand, and I'll do my best to explain it =) Regards //Feelay | Nanashi
  11. Feelay

    Hey!

    Hey! Long time no see. I'm not really sure if you remember me, but it's me =DI've been inactive for a very long time, developing my knowledge, learning AJAX, JavaScript, and even more advanced PHP.Just wanted to say that I'm kind of back and I plan to stay here for a while, meaning if anyone needs help, just send a PM.I'm sorry for not replying on new questions asked in my tutorials, I just found out this site is still alive, even though it doesn't look populated!Regards/Feelay
  12. thanks for the replies :mellow:hmm, If I want the map to be 50*50 "boxes", and I want every box to have different backgrounds.. or I want some boxes to have a grass background, others to have sand, and some of them have water, etc. Now the hard thing isn't to make them have backgrounds.But anyone knows a fast and simple way to create 50*50 boxes (2500 I think that is) ._.?Or is the only way to code them in a CSS file, and then just use them as divs =S?heh, I know wutskes way should make my brain light up.. But I'm always slow when learning new things.. I just know basic CSS (A)
  13. Hi! I am working on a text-based RPG game. I'm coding it in PHP, XHTML and CSS. I was wondering. I want to make a map, and thought of making a X/Y cordination system work as that map. But I was wondering, do anyone of you know how I can make such a map? I want the player to stand in the middle. every cell should have a value, with a variable/ array. I want it to have about 100-500 cells. but not all visible at once. about 100 cells visible on the page. and every time I move to a square, the character will stay in the middle, and the map will update all cells.. I don't know if you understand, cus I've never been good at explaining things =/ The 2 main questions is, what is the easiest way to make such a cordination system? loops`? can anyone please show me an example? And, how do I assign a value to each cell, so that I can use it in an if-statement. Example: if($user['cord']==$cellX8Y3){blabla}And $cellX8Y3 is a variable holding the vale of a specific cell. Thanks //Feelay
  14. As far as I know, textbox is the type that right =S and I use it, and it works. And as far as I know, type="text" doesn't work =Sand when handeling database data, I do use mysql_real_escape_string ((=But when making.. for example a contact script, that doesn't have anything to do with a database, I don' think it works therefor, I use addslashes()But thanks for the warnings =) people not aware of it, may use your help ^^//Feelay
  15. Thanks for the warning =DAnd I didn't know input tags had to be closed ._. I thought it was enuogh just to close the form tag. Anyways, Thanks =D//Feelay
  16. heh.. Long time ago I made this, but I figured it out yesterday XD The easiset thing that you can do, is.. <form><?php echo "<input type=\"textbox\" name=\"text\" value=\"{$_POST['text']}>"; ?><input type="submit" name="submit"></form> if you make the script check on the same page, and something goes wrong, the input of the text area/ box will be saved in a vvariable, and the variable will be the value of the box
  17. I can't belive it.. 2 things..1. The picture on Wikipedia, looks exactly like Windows Vista.2. I am not sure that this will be any "success".The last things Microsoft have been releasing: Vista, IE 7, and some other softwares that I've tryed, havn't been good at all.. I have the feeling, that microsoft releases everything in version "alpha". Not "beta". I don't think that this will succeed.But that's just what I think. Because after Microsofts latest releases, I hate them (them = Microsoft).. In my opinion, XP was the last good thing Microsoft made.. and even XP isn't that good.. (Sometimes I wish I knew how to use Linux )Well.. I don't know. that was my opinion.. But still, no one knows what they are hiding.Wishes //Feelay
  18. The code is mine. I got some help from people here on Xisto, with some functions. But the whole script is made by me. You are allowed to use it. This is just a beginner script So it doesn't really matter hmm.. I don't understand =/ If you mean what you think you mean, try: A simple if statement should be able to do it. If the session user is set, show the welcome, else, show just the name of the user. If that is not what you mean, please reask the question, but try to explain more Wishes //Feelay
  19. hmm.. I've never really studdied file upload. But it shoudln't be hard to make. You just have to know how to do it. I havn't studdied these things, and therefor, I'm afraid I can't help you =/ sorry. But I am sure that someone else here can. EDIT: Try searching for UPLOAD PICTURES TO A MySQL DATABASE on Google you should find lots of things. Here is a good Link =) Inserting pictures to a mysql database Wishes //Feelay
  20. try to echo the $user = mysql_query("SELECT * FROM user WHERE username = '$username'"); add echo $user; under it.. like this. $user = mysql_query("SELECT * FROM user WHERE username = '$username'");echo $user; then write the output of the echo, here.
  21. add this, before the "?>". } else {echo "You are not logged in. Please log in to continue";} I think I was using a different database when I created that tutorial. just change the "user" to the column in your database that takes care of all usernames. and change characters, to the name of the table you are using to store all the data. Good luck with you site, and thanks for the comments
  22. WoW. many votes here O.OI think Xisto is the best.When I came here, I really hated free web hosts.. But I had no choice, and I thought Xisto would be like all the others..But I was wrong..The Hosting:Xisto have no ads. They offer free MySQL databases, and they have PHP installed.It's exactly like paid hosting. But you don't pay with real money. You pay by writing in the forums.. The uptimes are really great. They have free FTP, and alot of other functions. They have a nice CPanel, and everything else you wish to have.. 500 MB of webspace is more than enough. Much more.The only thing that isn't good, is the BW. You can't increase it, and if your site have about 10 000 views / day, 10 GB BW isn't enough. But trust me.. this is a really professional hosting.5 out of 5 stars ;)The Forums:OK.. not many people that's active at the same time.. but still.. The people here are nice, and helpfull. I learned alot thanks to them, and I am still learning.And the moderators and Admins are also nice to others, and not abusing their powers, like some other forums I've seen..Well.. I don't know what more to write. but my vote goes to Xisto
  23. actually, I never expected it to be this good. I've been using it for a week, and it only crashed once.. probably because my computer isn't the best.. I just love the simple design.. but I wish there was a way to change the colors And.. I was surprised, when I saw how fast it was. my computer isn't the best, but still it loads most pages faster than IE and sometimes faster than FireFox. I like it, because it don't take too much space on the screen. And because you can drag the tabs, and "make them into windows, instead of tabs". The only thing that I find "hard" is finding in the menus.. still don't know what I can find, and where I can find it I know there are some to the right.. but are those the only ones, or is there something else, that's hidden? Another thing.. this maybe isn't the worlds end.. But I don't like that there is no "stop" button.. and if there is.. I don't like that it is hidden.. if it have to.. It would be better if it could be replaced with the update button when a page is loading. And.. The spell correction thingy.. This whole page is red, because it corrects swedish.. not english.. no idea how to change it =/ haha that's good threads have been popping up all over the forums lately (a)
  24. You don't know. The thing happenes in schweiz.. (I think it's named in english ) I think it takes time for the effect (if there was any) to reach the other countries
×
×
  • 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.