Jump to content

Search the Community

Showing results for tags 'php'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • RuneLocus
    • News & Announcements
    • Information Booth
    • Website Support
    • Introductions
    • Chat
    • Forum Games
  • RuneScape Development
    • RSPS General
    • RuneScape Private Server (RS2)
    • RuneScape Private Server (503+)
    • RuneScape Private Server (EoC 742+)
  • Other
    • Digital Art
    • Gaming
    • Webdevelopment
    • Computers
  • Marketplace
    • RuneScape Market
    • RSPS Market
    • Others Market
    • Freelance Middleman Services
  • Super Secret Club's Topics

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Found 47 results

  1. Hello, As I didn't see anything like this in the section, I decided to make this guide. This guide will be designated towards an audience of people wanting to learn PHP. I will explain the fundamentals of this language, and I hope it's thorough enough for easy understanding. So, sit back, get your reading glasses on, and get ready! I give you a warm welcoming to: An Introduction to PHP Contents: [iurl=#section1]1 - What is PHP?[/iurl] [iurl=#section11]1.1 - What will we be learning?[/iurl] [iurl=#section12]1.2 - What's an IDE?[/iurl] [iurl=#section13]1.3 - Selecting an IDE[/iurl] [iurl=#section14]1.4 - When and when-not to use an IDE[/iurl] [iurl=#section2]2 - Variables[/iurl] [iurl=#section21]2.1 - Integers[/iurl] [iurl=#section22]2.2 - Strings[/iurl] [iurl=#section23]2.3 - Arithmetic[/iurl] [iurl=#section24]2.4 - Echo & Print[/iurl] [iurl=#section25]2.5 - Putting it all together![/iurl] [iurl=#section3]3 - Comparisons[/iurl] [iurl=#section31]3.1 - Comparison expressions[/iurl] [iurl=#section32]3.2 - The if statement[/iurl] [iurl=#section33]3.3 - What else!?[/iurl] [iurl=#section34]3.4 - Combine![/iurl] [iurl=#section4]4 - Let's switch it up![/iurl] [iurl=#section41]4.1 - Testing the waters[/iurl] [iurl=#section42]4.2 - Rack 'em and stack 'em[/iurl] [iurl=#section43]4.3 - Alternative syntax[/iurl] [iurl=#section44]4.4 - Put it together![/iurl] [iurl=#section5]5 - Arrays[/iurl] [iurl=#section51]5.1 - How does it all work?[/iurl] [iurl=#section52]5.2 - To access an array[/iurl] [iurl=#section53]5.3 - Modify, delete, sort, and push your array[/iurl] [iurl=#section54]5.4 - The associative array[/iurl] [iurl=#section55]5.5 - Using it as a map[/iurl] [iurl=#section56]5.6 - Multiple dimensions![/iurl] [iurl=#section57]5.7 - Mash it all together![/iurl] [iurl=#section6]6 - The loop[/iurl] [iurl=#section61]6.1 - The for loop[/iurl] [iurl=#section62]6.2 - Looping an array causes something new[/iurl] [iurl=#section63]6.3 - While this... Maybe this?[/iurl] [iurl=#section64]6.4 - How do you do?[/iurl] [iurl=#section7]7 - Onto functions![/iurl] [iurl=#section71]7.1 - Time to put arrays in them![/iurl] [iurl=#section72]7.2 - Calling these functions[/iurl] [iurl=#section73]7.3 - Messing with parameters[/iurl] [iurl=#section74]7.4 - Apply it![/iurl] [iurl=#section8]8 - PHP is also OO![/iurl] [iurl=#section81]8.1 - Time for class[/iurl] [iurl=#section82]8.2 - Use of properties[/iurl] [iurl=#section83]8.3 - Throw a method in the matter[/iurl] [iurl=#section84]8.4 - The final chapter[/iurl] [iurl=#section9]9 - Hope you liked it![/iurl] [anchor=section1]1 - What is PHP?[/anchor] PHP is a recursive acronym for; 'Hypertext Preprocessor'. It is an immensely popular open-source scripting language. It's designed to be especially beneficial to web development and it is able to be embedded into HTML. It can be extremely useful in the case of where making a specific webpage you'd like, HTML does not have the capabilities to perform certain actions or processes. You can also use it to simplify your time, as opposed to writing hundreds of lines of HTML. What makes PHP standout is that it's a server-based language. As opposed to JavaScript; which is client-sided. What this means is that the code you write is executed on the server, generating the HTML code which is then sent to the client for processing. The client, once received the results of your script, would not know what the underlying code was. You could even program your server to process all of your files with HTML, so your users couldn't exactly tell what you're really up to. One of the best things with PHP is that you can jump right in! It's easy to understand, so don't be afraid of it. You'll come in, start learning, and within just a few hours, start writing some simple scripts. [anchor=section11]1.1 - What will we be learning?[/anchor] In this guide, you will be learning all the basic necessities in PHP. From variables, to functions, to classes, and all sorts of great utilities that will help you in the everyday usage of PHP! This guide is designed for the audience of newcomers in the language. If you're intermediate, above average, or just profound with this language, then I don't think you will find much of this information useful - as you have probably already learned it. PHP is a bold and dynamic language, so I envy you for giving it a shot! Hopefully, you'll end up being a widely successful web developer. [anchor=section12]1.2 - What's an IDE?[/anchor] IDE is an acronym for; 'integrated development environment'. An IDE will help you a long ways in the development field! It will show where you have made a mistake, or what is being used and what's not. It will also compile your code and check it before you can! It's an amazing tool to use if you're a developer, and can make your projects that you construct much more at ease. They have unique tools such as syntax highlighters, code parsers, built-in compilation devices, and etc. If you're working on a large project and aren't using an IDE, then I don't know what you're doing! [anchor=section13]1.3 - Selecting an IDE[/anchor] Selecting an IDE is as simple as pie! There are a few popular IDE's out there, and they are popular for a reason. They have a wide variety of tools, UI's, and plugins that make your coding experience just that much better. There are two 'most-popular' IDE's available for free: Eclipse, and NetBeans. Go and check each one out, decide for your own, and download that one. They may be a little weird to use at first, as it's a strange environment to get used to, but once you get the hang of it - it's a cakewalk! You can find the Eclipse PHP IDE here! You can find the NetBeans PHP IDE here! [anchor=section14]1.4 - When and when-not to use an IDE[/anchor] IDE's are great and all, but there are times when you shouldn't use them. For example, IDE's typically have the capabilities of doing simple work for you. It may sound nice, yes; however, you should be concerned on what you've actually learned. When learning the basics, I recommend to use a simple syntax highlighter, or code editor. Code editors, such as Vim and Notepad++, are great ways to still understand what exactly you're writing, and learn in the process. As they have syntax highlighters and code parsers typically build within them, you needn't worry about your code looking too ugly to work on. In this tutorial, I recommend you use one of the code editors as previously stated in this section. Code editors are especially beneficial to the learning process. [anchor=section2]2 - Variables[/anchor] Now that we're getting into variables, we can finally start getting into programming! Variables are little bits of code to store data. These types of data can be a range of things! Such as integers, strings, arrays, functions, or even instances of a class! Alas, for now, we must stick with the basics. In this section, we'll be introducing you to integers, strings, basic mathematics, and how to call these things. To get things started, I would like to point out that variables are represented by a dollar sign, followed by the title of said variable. For an example of this, you would use: <?php //Your first variable! $exampleVariable; ?> This would indicate that you have set a variable, and might call on it later. [anchor=section21]2.1 - Integers[/anchor] Now that we have a variable set, we can apply a value to this. For starters, let's go ahead and use an integer! An integer is, to put it simply, just a number. It tells the server that there is a variable there, that is a number, and the amount of this number. So, if you wanted this variable to just be the number 10, you would use: <?php //This variable is now an integer! $exampleVariable = 10; ?> That would tell the server that variable 'exampleVariable' is the number 10. [anchor=section22]2.2 - Strings[/anchor] However, not all variables are going to be numbers! You can also turn this into a string as well. Eh... You can turn a variable into lots of things, but these are just the basics of variables for now! Strings are just bits of text. You can make it one word, or even an essay if you so choose! So, if you'd prefer to have exampleVariable as a text instead, you can do that with this example: <?php //This variable is now a string! $exampleVariable = "I'm a string!"; ?> Now remember, strings always have to be in quotes, or single-quotes. I use the term 'single-quotes' as opposed to apostrophes because you are still quoting the string with it. If your text is not inside quotations, then you will receive an error! [anchor=section23]2.3 - Arithmetic[/anchor] Variables may also be used in arithmetic sequences. It's just like punching it into your calculator, it's so simple! You have assignments that you would need to apply to make it an arithmetic sequence. You would use + for addition, - for subtraction, / for division, * for multiplication, and % for modulo. In the example below, you will see a list of variables with their names corresponding to their actions. Read the names of these variables, or the comments above them, to see exactly what each variable is doing: <?php //This variable is adding two numbers $additionVariable = 1 + 2; //value would be 3 //This variable is subtracting two numbers $subtractionVariable = 2 - 1; //value would be 1 //This variable is multiplying two numbers $multiplicationVariable = 1 * 2; //value would be 2 //This variable is dividing two numbers $divisionVariable = 2 / 1; //value would be 2 //This variable is a simple mathematic sequence $mathematicVariable = 2 * 4 / (1+1) - 4; //value would be 0 ?> Now, if you're reading this and understand PHP to an extent, you may ask, "why is the echo part in the variables section?" Well, my friend, I have to have some place to put it! I didn't want it to have it's own section, so I figured after teaching people variables, I can show them how to call them. So, to start off, the echo statement is what outputs data onto the user's screen. So, if you were to put: echo 'Hello!'; all you would see on the screen was "Hello!". Print, however, is virtually the exact same. The only difference is, print has a return value of 1, whereas echo has no return value. Allowing you to use the print statement in expressions. If you wanted to call one of the arithmetic variables in the example above, all you would have to do is add a simple echo statement in the line below. Like so: [anchor=section24]2.4 - Echo & Print[/anchor] <?php //This variable is adding two numbers $additionVariable = 1 + 2; //value would be 3 //This variable is subtracting two numbers $subtractionVariable = 2 - 1; //value would be 1 //This variable is multiplying two numbers $multiplicationVariable = 1 * 2; //value would be 2 //This variable is dividing two numbers $divisionVariable = 2 / 1; //value would be 2 //This variable is a simple mathematic sequence $mathematicVariable = 2 * 4 / (1+1) - 4; //value would be 0 echo $subtractionVariable; //this would print the value of your variable 'subtractionVariable' ?> Though, you do not have to echo or print variables if you don't want to. You can easily just write a string of text onto the screen without calling it from anywhere using something like this: <?php //Time to print our first line! echo 'Hello world!'; ?> From this, all that would display onto the screen would be: Hello world! [anchor=section25]2.5 - Putting it all together![/anchor] Now that we've learned the basics of variables and how to call them - let's write some basic code that will mix all of this together! It may sound challenging, but fret not! What you've just learned is some of the most basics that will be used everyday in PHP. You'll remember these little things quite easily, and once you take a look at the code example below, you will see exactly why: <?php //Indicate your variable(s) $myName = "Example"; $myAge = 23; $sequence = 4 * 12 / 2; //Call your variable(s) via echo echo "Hello! My name is $myName, I am $myAge years old.<br />I've been asked to find out the value of 4 * 12 / 2 which would equal to: $sequence"; ?> This would output to: Hello! My name is Example, and I am 23 years old. I've been asked to find out the value of 4 * 12 / 2 which would equal to: 24 As you can see, in your echo you can apply variables to it without breaking the line of text you are outputting. Also, you are able to add HTML code within your echo statements, providing more organization to your outputs. However, in a case where you would need to have a break in your quotes, you would simply use periods to inform the server that you are making additions into this quote from elsewhere. For an example of this: <?php //Indicate your variable $exampleVariable = "Example"; //Call your variable(s) via echo echo "This is my example text: " . $exampleVariable . "!"; ?> This would print: This is my example text: Example! [anchor=section3]3 - Comparisons[/anchor] In this section, you will learn how to compare two things in PHP. This is an absolute essential for everyday programming. If you don't know how to compare, you won't make it very far. Here, you will learn how to compare integers, strings, and even learn new statements! Hopefully you'll be in for it, because now we're getting into elements just a little more advanced. For an example of this: <?php $name = "John"; if ($name == "Jasmine") { echo "Hey, how's it going!?"; } else { echo "Who are you?"; } ?> But for now, let's get back to the basics! Now, in order to compare, you will need to know the expressions to do so. These expressions will always evaluate out to 'true' or 'false'. These are some of the most commonly used expressions in the programming world, and here's what they are: [anchor=section31]3.1 - Comparison expressions[/anchor] You may wonder, 'what do those last two in the list mean?' Well, quite simply, it's to find out if a certain variable is equal to the same type of something else. However, these are commonly used in if statements, which have not yet been explained. Regardless, I will teach you these now. So, for example, if you want to make sure that a variable is equal to 30 and is an integer at the same time, you would use the === expression. Here's a code snippet example: == / is equal to >= / is greater-than or equal to <= / is less-than or equal to > / is greater-than < / is less-than != / not equal to === / is equal to and same type !== / is not equal to or same time <?php //Setting the variable $myVar = 30; //Calling your if statement if ($myVar === 30) { echo "Yep, that's an int that equals 30!"; } else { echo "Incorrect."; } ?> The result of this would be: Yep, that's an int that equals 30! Now that you've learned what each expression means, how do we apply them? If you hadn't figured it out based on my two if statement examples above: with if statements! Let's continue onto the next section. [anchor=section32]3.2 - The if statement[/anchor] If you're following this guide to the dot, then you've already seen me use an example of an if/else statement. In here, we're going to discuss exactly what "if" does. The if statement sends information to the server regarding whether a current state is true, or false; depending on your comparison expressions you set. If the statement is receiving the value it's looking for, then it will proceed with an action. If not, then it will return nothing. For example: <?php //Two basic variables $a; $b; //These two equal one another $a = $b; //'If' these two variables equal each other, it will return a bit of text if ($a == $b) { echo "That's true!"; } ?> This would print: That's true! However, if you wanted to ensure that this if statement happens only if the two variables did not equal each other, you would instead use this: <?php //Two basic variables $a; $b; //These two equal one another $a = $b; //'If' these two variables do not equal each other, it will return a bit of text if ($a != $b) { echo "That's true!"; } ?> As you can see, our comparison expression changed from example 1, to example 2. In example one, the if statement was checking to see is $a was equal to $b (==); and with our variable statement we made beforehand - that made it true! So, it printed the line. However, in this example, the if statement was checking to see if $a did not equal $b. And because variable $a was equal to $b, then the statement was false; thus no line was printed. [anchor=section33]3.3 - What else!?[/anchor] What if you wanted to have some sort of output if the conditions are not met in your if statement? Well, that's where the else statement comes in handy. As you've seen in my first example on if statements, you may have seen that line of code that says, '} else {'. What this means is - if these conditions are met, an action will be performed. However, when the conditions are not met - this is where the else statement applies it's action. For example, let's make an else action display on screen: <?php //Simple boolean variable $a = true; //If this variable is false, perform an action, 'else' perform a different action if ($a === false) { echo '$a is false'; } else { echo '$a is true'; } ?> The output on screen would be: $a is true. However, this is not the end of the else statement! You can prolong checkups by searching for another condition if the criteria of the first condition is not met using elseif. This statement allows another if statement to be performed if the predecessor statement's conditions were not met. For an example of this: <?php //Simple int variable $a = 46; //If this variable is false, perform an action, 'else' perform a different action if ($a == 50) { echo '$a is 50'; } elseif ($a != 45) { $a = 45; echo '$a is now 45'; } ?> The ladder of checks this does is; first, it checks to see if variable $a is equal to 50. If not, it goes onto the next statement, which is our elseif statement. This then checks to see if variable $a does not equal to 45, and currently - $a is 46. So, this statement sees that $a does indeed not equal 45, so it then changes it to 45, and prints the line, "$a is now 45"; making $a equal to 45. [anchor=section34]3.4 - Combine![/anchor] Now that you know all the basics, it should be known that you can also compare strings! It's just as easy as comparing integers or boolean values. Just remember, strings are always in quotes. So, now let's combine all we've learned here. If you take a look at the very beginning of section 3, you will see my first example. This is almost a combination of everything we've learned so far, all we need to do is just add one thing, and we will be in the go: <?php $name = "John"; if ($name == "Jasmine") { echo "Hey, how's it going!?"; } elseif ($name == "John") { echo "Hey, John! I haven't seen you in ages!"; } ?> This would print: Hey, John! I haven't seen you in ages! Now that we've covered if/else statements; what if there's something you want to add that would go through a large amount of checks depending on the same value? As opposed to writing a mass amount of if/else statements, you could simply run it through a switch statement! Here's an example of what you're going to be building: [anchor=section4]4 - Let's switch it up![/anchor] <?php switch (2) { case 0: echo 'The value is 0'; break; case 1: echo 'The value is 1'; break; case 2: echo 'The value is 2'; break; default: echo "The value isn't 0, 1 or 2"; } ?> This would print, The value is 2 As you can see in the parameters of the switch statement, you see that it's simply "2". This would mean it would go through the cases until it reaches case 2, then output the action it underlies. [anchor=section41]4.1 - Testing the waters[/anchor] As always, we're not going to rush anything here. Nice and easy, slow and steady. We need you to learn, not quickly "get this over with". Each switch statement will be made up of cases. Each case will represent, basically, an if statement. Once you end your case, you will need to (break;) it, showing the server that the case has ended. Once you complete all your cases, you will still need to add your default case. This is there for when every output of your switch would be false, it displays your default case's action. As it is your default case, breaking this will not be necessary. You can also choose what you're switching through, and the properties of the case. If you want to switch through a series of strings, you can do that, if you want to switch through even an array, you can do that! It's very helpful for when you have a lot of things you're checking for. Here's an example of a basic switch statement through strings: <?php $fruit = "Apple"; switch ($fruit) { case 'Apple': echo "Yummy."; break; default: echo "None of the above!"; } ?> As you can see, the switch statement is switching through the cases until it finds the value of variable $fruit. Obviously, the first case is equal to the variable's value of "Apple", therefor, it would print: Yummy. [anchor=section42]4.2 - Rack 'em and stack 'em[/anchor] Another great thing about switch statements is that multiple cases can be applied to the same task! This make things much easier if you want to have the same output for multiple values. Consider the following if statement: if ($n == 0 || $n == 1 || n == 2) { echo '$n is between 0 and 2!'; } else { echo '$n is not found yet'; }[/code] This would check and see if variable $n is equivalent to either 0, 1, or 2. If it is, it would print the string shown in the echo statement. However, there is a much simpler way of doing this, with your switch statement: [code=php] switch($n) { case 0: case 1: case 2: echo '$n is between 0 and 2!'; break; default: echo '$n is not found yet'; }[/code] This would do the same exact thing the if statement provided above does. This could also be applied with strings, and other variables, as I had previously stated. It's quite a nice feature, and is used very commonly! [center][size=6][anchor=section43]4.3 - Alternative syntax[/anchor] [/size][/center] Here, we will kick it back to an earlier section of the tutorial as well. We will learn the alternative syntax for both switch statements, and if statements. "Alternative syntax? What do you mean?" Well, the examples I provided are the most common ways of enacting these statements. However, there's an alternative route you can go for applying these statements. As opposed to the normal braces, perhaps you can use colons? Take a look at the following: [code=php] $fruit = "Apple"; switch ($fruit): case 'Apple': echo "Yummy."; break; default: echo "None of the above!"; endswitch; As you can see, instead of using { } braces as we normally do, we used a colon and ended it with the 'endswitch;' statement. You are able to do this for if statements as well: if ($a == 5): echo "a equals 5"; elseif ($a == 6): echo "a equals 6"; else: echo "a is neither 5 nor 6"; endif;[/code] The same applies. [center][size=6][anchor=section44]4.4 - Put it together![/anchor] [/size][/center] Now that we've learned the basics of a numerous amount of things, perhaps we can put them [b]all[/b] together and see what we've learned so far! Here's what I got: [code=php]<?php //Our variables; check! $myName = "Example"; $myAge = 30; $isAlive = true; //Our arithmetic & echo statement; check! echo 6 * 22 . "<br />"; //if and switch statements; check! if ($isAlive === true) { switch($myName) { case 'Example': echo "Your name is $myName and you are $myAge years old!"; break; default: echo "Cannot locate 'Example'."; } } else { echo "We can't search you up if you aren't alive!"; } ?> The output of this would be: 132 Your name is Example and you are 30 years old! Congratulations! You've finished roughly half of An Introduction to PHP! Keep moving on, you're learning a lot! We're going to keep slowly advancing, but I'll make sure that you have the utilities here in this thread to have a successful start. [anchor=section5]5 - Arrays[/anchor] An array can help with your organization when you have long lists. An array is actually an object, so there is a little object-orientation with PHP; but we'll get to that later! As opposed to generating hundreds to thousands of variables - simply store it in one array! Think about it this way; an array is like a list of items (for example; a shopping list). You don't want to put each item on it's own page (a variable), that's a huge waste of paper! However, if you put your entire list onto one page (the array), then things will be a lot more organized and more efficient. [anchor=section51]5.1 - How does it all work?[/anchor] Well, if you're following this guide all the way through, you would probably remember me telling you that you can apply your variables to be arrays. Yes, I'm finally explaining it to you! You know how variables can become integers, strings, mathematical sequences, and etc. You know how to apply them in if and switch statements. However, this is where things get a little trickier. An array is, as briefly explained in the previous section, is a list of items. Whereas you could write hundreds of lines of variables and call upon those - or you could simply make an array. Take a look at the following: <?php //Your very first array! Congratulations! $myArray = array("Chips", "Salsa", "Rice", "Corn" ); ?> As you can see - the array starts exactly as a variable. You start it with your dollar sign, followed by the name of your variable, then the equal sign. That's because... You guessed it! It is a variable! You're just designating it to be an array. To declare it as an array, you need to first act as if you're just making a regular ol' variable. Once you've gotten passed the '$myVariable = ' part, this is when it gets different! Once you've done this, you'll want to designate the array. To do this, it's simple as, "array( <insert list> );" Each item in your list will be separated by quotations and commas. So, from my example, you can see exactly this for each list. [anchor=section52]5.2 - To access an array[/anchor] Now that you understand how these arrays work - it's time to find out how you call on these arrays! To do this, it's quite simple. You can either access them by Offset with braces, or brackets! Simply call your variable followed by either your brackets or braces. For an example of this: <?php $myArray = array("Chips", "Salsa", "Rice", "Corn" ); echo $myArray[0]; ?> This would simply print: Chips. Now, you can replace the brackets in the echo statement calling the variable with braces, and it would perform the same action. You may wonder, however, what that number means inside the brackets. Well, this number represents which item(s) that I want to call from the array! By default, the first item's identification number will always be 0, and you would increase it from then on for further items. So, if you were wanting to call the "Rice" item, you would use $myArray[2]; - and this would print that item. [anchor=section53]5.3 - Modify, delete, sort, and push your array[/anchor] Well, you know how to create and call on a simple array. How about when you need to modify your array further down the road? Well, to do this; all you would need to do is declare the variable, the item's number, and simply make it equal to a different result. Just like changing an integer variable! Take a look at the code below: <?php $myArray = array(10, 20, 30, 40, 50, 60, 70, 80, 90, 100 ); echo $myArray[3]; $myArray[3] = 15; echo "<br />" . $myArray[3]; ?> This would output: 40 15 Simple as that! These features for arrays are always beneficial in a case where it's dependent on a user's input. Though, what if you need to delete a section, or item, of an array? Well, honestly; that's easier than modifying an element of one! All you need to do is use the 'unset' statement, declaring your variable and the identification number of the item you want deleted. So, for example: <?php $myArray = array(10, 20, 30, 40, 50, 60, 70, 80, 90, 100 ); echo $myArray[3]; unset($myArray[3]); echo "<br />" . $myArray[3]; ?> This would print: 40 50 So, as you could see in that example, deleting the element of the array causes the next element in your array to take the place of it's predecessor. Pretty neat, huh? Though, in a scenario where you want to sort your array by numerical or alphabetical order... How would one do this? Well - with 'sort'ing it! Just one simple statement, and it is then placed in numerical or alphabetical order! It depends on what you choose your array to be! Take a gander down below, and see an example of this: <?php $myArray = array("Z", "B", "Y", "A" ); echo $myArray[0]; sort($myArray); echo "<br />" . $myArray[0]; ?> This would print: Z A As you can see, Z was the first option in the array. Though, when the second echo was called, why was A the first? Well, you see, we sorted the array! This detects whether it is alphabetical or numerical, then sorts it regarding the first number(s) or letter(s) in this array. However, there is also a reverse order to this sorting method - 'rsort'. Very cleverly named, yes? Take a look at the example below! <?php $myArray = array("Z", "B", "Y", "A" ); echo $myArray[1]; rsort($myArray); echo "<br />" . $myArray[1]; ?> This would print: B Y Now, just like the sorting method, you see that B is the second item in the array. So, we called that - as you can tell! Though, in the second echo, Y was instead printed. This is because we reverse sorted it. This is a neat feature you can use if you ever want to reverse alphabetically/numerically sort an array. Instead of sorting it dominantly, it takes the last letter(s) or number(s) in cycle and sorts it last-to-first. What if later down the road you'd like to add something to your array? For this, you would use your 'array_push' method. This allows you to add elements to your array with ease! So, for example, if you're working on, let's say, a turn-based game providential to array-based saving, then array_push could come in handy! Observe the following: <?php $stack = array("grape", "cherry"); array_push($stack, "orange", "coconut"); print_r($stack); ?> The output would print: Array ( [0] = grape [1] = cherry [2] = orange [3] = coconut ) Nifty, right? This could come in all sorts of handiness when necessary. I promise, you'll be glad that you remember how to do this! [anchor=section54]5.4 - The associative array[/anchor] So thus far, you've learned to construct an array, sort it, push it, delete items in it, and call it via integer. However, in the case of you wanting to be more descriptive of your data, you could use something called an 'associative array'. Some languages, such as Java, do not view associative arrays to be arrays - and separate them away from any correspondence. For example; Java calls these and utilizes them as 'maps'. However, PHP treats them as the same as an array. It makes use of key => item pairs which make organization much more simple. For example of a difference between the two arrays: <?php //First, the normal array $myArray = array( "Item1", "Item2", "Item3" ); //Now we call it echo $myArray[1]; //Time for our associative array $myAssocArray = array( 'Item1' => 'Value of item1', 'Item2' => 'Value of item2', 'Item3' => 'Value of item3' ); //Now we call it echo "<br />" . $myAssocArray['Item2']; ?> This would print: Item2 Value of item2 So, as you can see in this example - we give each item in our list an identification title, as opposed to it having a number. It can be used for readability and organization. Which would be easier to read; a normal array, or an associative array? The answer is obvious! [anchor=section55]5.5 - Using it as a map[/anchor] Associative arrays, just like Java, are often called maps. These are because as opposed to a specific number relation, it uses a defined key. How much tougher would it be to travel from a map, whether it be an online map, an app, or just a standard paper-map, if it was numerically coordinated? So, in a sense, if you're using an associative array - then you're already using a map! Congratulations! So, for an example, have a look below: <?php $myAssocArray = array('year' => 2015, 'color' => 'red', 'doors' => 4, 'make' => 'Nissan'); echo "My car is a, " . $myAssocArray['make'] . " and was made in " . $myAssocArray['year']; ?> This would print: My car is a Nissan and was made in 2015 As you can see, this form of array is very beneficial for mapping your code and making it more readable. [anchor=section56]5.6 - Multiple dimensions![/anchor] What you may have not knows was: Arrays can store multiple arrays, causing them to become multidimensional arrays. These are especially useful for, say, designating a deck of cards to an array. This way, you could have each card in coordination to their face. Whether it be a 2 of diamonds, or a 9 of spades - this can be done with a multidimensional array. Take a look: <?php $deck = array(array('2 of Diamonds', 2), array('8 of Spades', 8), array('4 of Hearts', 4), array('5 of Diamonds', 5), array('7 of Diamonds', 7), array('2 of Spades', 2)); //Pretend the first card drawn was the 4 of Hearts: echo 'You have the ' . $deck[2][0] . '!'; ?> Now, this is only a two-dimensional array. There can be as many dimensions as you want, but if you exceed five dimensions in your array, it might get a little tough to manage. However, as you can see from the example, we call this in 'rows' and 'columns'. The first bracket defines your row, the second would define your column. If you were to add more dimensions to this, you would add more brackets. [anchor=section57]5.7 - Mash it all together![/anchor] Now that you understand your arrays, I want to know if you can put it all together! Learning interactively is statistically the best way of learning, so hopefully, if you're following this tutorial to the dot, you are doing just that! I know it may be boring, but it's worth it in the long run, I can assure you. So, if you put everything you've learned in this section together, then you should come up with something like this: <?php //A standard array $myArray = array( "Example A", "Example B", "Example C" ); //Calling it echo $myArray[1] . "<br />"; //Then - associative array $myAssocArray = array( 'fruit' => 'Apple', 'veggy' => 'Carrot', 'candy' => 'Chocolate' ); //Now we call it echo $myAssocArray['candy'] . "<br />"; //Finally, our multidimensional array $deck = array(array('2 of Diamonds', 2), array('8 of Spades', 8), array('4 of Hearts', 4), array('5 of Diamonds', 5), array('7 of Diamonds', 7), array('2 of Spades', 2)); //Calling an array yet again echo 'You have the ' . $deck[2][0] . '!'; ?> This would output: Example B Carrot You have the 4 of Hearts! So, as you can tell, arrays are a huge part of PHP and any sort of development in general. If you can't use an array, then you likely won't make it very far. Now, don't get anything distorted - there are times to use arrays, and times to avoid them. However, there tends to be more times to use them, than avoidance. [anchor=section6]6 - The loop[/anchor] Sometimes, you'll encounter a tough time when developing. Especially when you are designated a task that requires the same task to be ran over and over. Let's say we want to print a list containing all the months of the year; I, for example, would use something like this to do so: <?php $months = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "November", "October", "December" ); foreach ($months as $month) { echo "<li>$month</li>"; } ?> This would print: That, my friends, would be looping an array. We'll get to that in the meantime. For now, let's focus on the for loop: January February March April May June July August September November October December [anchor=section61]6.1 - The for loop[/anchor] So, as you've seen me provide an example of a for loop already (well, you saw me use the foreach loop, but it's deprived off of the norm - for loop), you can see that you are able to loop through arrays. Great for a list, am I right? Well, before we get into that, let's just start with the basics. Say you want to print the numbers 1 through 20 on separate lines: Instead of writing twenty echo statements, or just one with twenty <br /> tags, you could write a simple three-liner - like so: <?php // Echoes twenty numbers for ($i = 1; $i <= 20; $i = $i++) { echo $i . "<br />"; } ?> This would print: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 So, as opposed to writing twenty lines of echoes to do this - you could simply write just one easy for loop. This can make things much easier when you have a large loop to go through; or even if you just have a small loop to go through. It's more efficient to use than to write, say, three echo lines. [anchor=section62]6.2 - Looping an array causes something new[/anchor] As you have seen in an earlier example, looping an array causes you to use the foreach element. This means - for each item in your variable; this happens. This makes it much easier for you to print a list of items. Just like in my earlier example: <?php $months = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "November", "October", "December" ); foreach ($months as $month) { echo "<li>$month</li>"; } ?>[/code] And just like before, this will output: [list][*]January [*]February [*]March [*]April [*]May [*]June [*]July [*]August [*]September [*]November [*]October [*]December [/list] As you can see in the example above - this [i]foreach[/i] loop sets it's own parameters. It first generates it's own parameters [i]as[/i] (using the built in method that the language provides) a custom parameter the statement makes. So, as you can see, you use array $months [i]as[/i] new variable $month - indicating each individual item the array provides. You can also loop associative arrays, check down below: [code=php]<?php $cake = array( 'large cake' => 'I do ', 'medium cake' => 'I do ', 'small cake' => 'I do not ' ); foreach ($cake as $size=>$decision) { echo $decision . 'want a ' . $size . '<br />'; } ?> This would print: I do want a large cake I do want a medium cake I do not want a small cake Looping is so cool, right? It makes things so much easier to perform than a whole bunch of unnecessary code you could use for just this! Man-o-man, could you just imagine all the if/else statements that would be required for all of that? Would rather just loop it! [anchor=section63]6.3 - While this... Maybe this?[/anchor] Maybe you want to loop until a certain condition is equal to a certain value? While this condition is false, it will continue looping until it is true. Hence, for this, you'd need to use your 'while' loop. I know, they are so creative in naming their methods! Either way, it's still the same, if not wildly similar, as in other programming languages such as Java, Python, or the C-languages. Take a look down below: <?php $headCount = 0; $flipCount = 0; while ($headCount < 3) { $flip = rand(0,1); $flipCount ++; if ($flip) { $headCount++; echo "H"; } else { $headCount = 0; echo "T"; } } echo "<p>It took {$flipCount} flips!</p>"; ?> This would display the amount of times it would take to reach three consecutive 'head flips' in a row. As long as there aren't three "H['s]" displaying on screen, it would keep looping until it reaches three H's in a row. While this condition is false, it will continue looping until it reaches proper standards. So, while loops are great for loops that you don't know when will end. Hence the example above. If we were to flip a coin until we received three head placements in a consecutive sequence, we wouldn't necessarily know when to stop this loop. That's basically why the while loop was created. [anchor=section64]6.4 - How do you do?[/anchor] Now that you understand while loops, it's time to learn - how do you do this while this statement remains false? This is where the 'do' part of the while loop comes in handy. You may have noticed that the while loop checks the condition before each individual iteration. What if you wanted to check this after each iteration? Well, that's exactly what the do statement can do for you. If you look at the following: <?php $flipCount = 0; do { $flip = rand(0,1); $flipCount ++; if ($flip) { echo "H"; } else { echo "T"; } } while ($flip); $verb = "were"; $last = "flips"; if ($flipCount == 1) { $verb = "was"; $last = "flip"; } echo "<p>There {$verb} {$flipCount} {$last}!</p>"; ?> This code will keep flipping as long as the result is heads. As long as the result is heads, it flips until there is tails. So, you shouldn't expect more than just two to four outputs on this loop. [anchor=section7]7 - Onto functions![/anchor] Functions are reusable bits of code, saving you much copying and pasting. Yes, one thing to know as a developer, copying and pasting may be a common part of your career. Why would you write out a whole block of code that's just as efficient as the one you've seen online - that you could copy and paste? Why rewrite the same code that you've already written, as opposed to simply copying that function? PHP has a wide variety of built-in functions that we'll be learning. You've already learned some of them, most of which being in your arrays section. That matters nay, however! I will teach you these functions and how to apply them, even in OOP! But, we'll get to OOP in section 8, which is our final section. Take a look below: <?php //An example variable we will be using in this subsection $myName = "Example"; //The substr function allows you to receive a snippet of your string variable $partial = substr($myName, 0, 4); print $partial; echo "<br />"; //The strtoupper simply makes your whole string uppercase $upper = strtoupper($myName); print $upper; echo "<br />"; //The strtolower function does the exact opposite of strtoupper $lower = strtolower($myName); print $lower; ?> This would print: Exam EXAMPLE example Now, as you can see, these built in functions can help with your - eh; functionality. You'll always want your website to be functional to the best of it's abilities. And the best of it's abilities can be basically the best of PHP's abilities. I know that there are other languages that enhance the scripting language of PHP such as JavaScript and MySQL - but that's beside the point! Alternatively, functions can have parameters. These tell the function if there is data that it needs to check over. This can come in handy if one is trying to call an instance of this method more smoothly, calling in the arguments required for the given function. Functions can also return statements as their actions. You can make these return statements variables that you've already set, or that you plan to change in the future. Below, see the following example: <?php $name; function returnName() { return $name = "Example"; } ?> Now, perhaps if you were to call this method via echo statement, it would return an "Example" value. [anchor=section71]7.1 - Time to put arrays in them![/anchor] Putting arrays in functions is as easy as ever. Basically, you just make an array. It's virtually it's own function as is! Just join the array with a print statement, and that's an official function. If you'll take a gander on the example below, you'll know exactly what I mean: <?php //Name your function function arrayFunction() { //Create an array with several elements in it, //then sort it and print the joined elements to the screen $the_array = array("Banana", "Peach", "Mango", "Apple", "Cherry"); sort($the_array); print join(", ", $the_array); } arrayFunction(); ?> So, as you can see in the example above, joining the array with the statement 'print join', you can join these arrays by separation based on whatever you decide to separate it with. Whether it be by slashes, periods, commas, or anything! The output of this would be: Apple, Banana, Cherry, Mango, Peach And as you already know the rsort method, then you shan't worry about all the little nicknacks! [anchor=section72]7.2 - Calling these functions[/anchor] If you're coming from an OOP language, then these parts of the tutorial should be nothing more than a cakewalk. Calling these functions is the easy part. Making them - now that's the real challenge. However, I'll let you figure out the more advanced functions that you're able to construct. In this tutorial - we'll only cover the basics. So, to call these functions, all you'll need to do is list the function followed by the parameters if necessary. Take a look at the example below: <?php $name = "Example"; function greetings($name) { echo "Greetings, " . $name . "!"; } greetings($name); ?> This would print: Greetings, Example! As you can see, if you parameters are set to an existing variable, it would draw the data from said variable and print it onto the screen via echo statement. However, you can make functions into object-orientation; they are mainly designed as scripts via PHP. There are many wonders you can do with this language, just keep researching beyond this tutorial, and you'll surely find out! [anchor=section73]7.3 - Messing with parameters[/anchor] Now that you know how to build and call these functions, but they definitely need to be able to take in some input. If they couldn't, that would just be fairly redundant. This is when parameters come in handy. Take a look below: <?php $name = "Example"; function greet($input) { echo "Greetings, " . $input . "!"; } greet($name); ?> This would print: Greetings, Example! See how in the parenthesis you are naming a new variable $input? Well, this is telling the function that it needs to collect some sort of data in order to process. By calling your method with the variable $name within the parenthesis is just how it's done. It could be very useful for, say, you want to save an array publicly, but need to call it for the given function. [anchor=section74]7.4 - Apply it![/anchor] Now that we've gotten functions down, we need to recap over what we've learned. Apply everything you've learned - try to shoot for something fancy! Don't be dull and boring like I am below: <?php function arrayFunction() { //Create an array with several elements in it, //then sort it and print the joined elements to the screen $the_array = array("Banana", "Peach", "Mango", "Apple", "Cherry"); sort($the_array); print join(", ", $the_array); } ?> [anchor=section8]8 - PHP is also OO![/anchor] A wonderful thing about PHP is that it is, too, OOP. Before we start: What is OOP? Well, object-oriented programming (OOP) is a language that bases it's concept on "object", which is data, typically in the form of fields, built in structures and contain code in procedures; known as methods. Distinguishably, OOP languages have a feature where an object's procedure can access and often alter the data within correspondence. This can be very useful for when you need to access an object with ease. You would have to construct your properties and set your parameters, however, but that's easy! However, most OOP languages are class-based, meaning objects are instances of the given class. Don't let that fool you! There is much diversity in OO languages. Take a look at an example of OO programming in PHP below: <?php //Creating the class class Person { //Creating the properties public $firstName; public $lastName; public $age; //Assigning the values public function __construct($firstName, $lastName, $age) { $this->firstName = $firstName; $this->lastName = $lastName; $this->age = $age; } //Creating a method public function greet() { return "Hello, my name is " . $this->firstName . " " . $this->lastName . ". I am " . $this->age . " years old!"; } } //Create a new Person $newPerson = new Person('Example', 'Last Name', 22); //Greeting the newPerson echo $newPerson->greet(); ?> This would print: Hello, my name is Example Last Name. I am 22 years old! Pretty neat, right? Review the code and try to see how it's doing this. If you figure it out, you'll probably think that it's pretty cool. OO is a very functional style of programming. If you can't figure it out, don't worry and just read the text explaining it below. This calls your object, or instance from the properties designated in the function you're calling from class Person. In the __construct function, you would declare your parameters to set the variables that are associated with the constructor. [anchor=section81]8.1 - Time for class[/anchor] Classes are an absolute essential for OOP. It is your foundation to your data structure. So, I suppose it really is the 'structure' part. You will declare your variables here publicly and call them in your instance after constructing them - making them your properties. When you want to utilize these properties, you will need to add a function to the class and call it with your instance. However, for now, take a look at the following: <?php //Your first class! class Person { } //Your first instance! $newPerson = new Person(); ?> You have now generated an empty class and a blank slate of an instance. To make use of these, you will need to assign properties. [anchor=section82]8.2 - Use of properties[/anchor] To make your properties, it's as easy as declaring a public variable. This would be useful for when you need not any parameters for your instance to utilize it. For example, an if statement would be a great time to use this. Take a look at the following: <?php class Person { public $isAlive = true; } $newPerson = new Person(); if ($newPerson->isAlive) { echo "It's alive!"; } ?> This would print: It's alive! As you can see, once you declare your boolean variable, you can call on it. It makes use of instance->property to check these. If you look closely, you'll see that you in fact do not use a dollar sign to call your property values. Now, if you wanted your instance to have specific properties for each object, then you would need to set your parameters. To do this, you would need to use your __construct method. This declares variables as specific properties for it's instant. Perfect, right? Have a look down below: <?php class Person { public $firstName; public $lastName; public $age; public function __construct($firstName, $lastName, $age) { $this->firstName = $firstName; $this->lastName = $lastName; $this->age = $age; } } $newPerson = new Person('Example', 'Last Name', 22); ?> Now, this makes it to where your instant $newPerson is now under the parameters 'Example', 'Last Name', and 22. This is due to the function in the class. This __construct function follows with parameters for the class, and to declare them; it uses $this->variable = $parameter. Now, what if you wanted to make a custom action in your class for a specific instant? Well, you can do it just as easy as making a simple function! However, this function would typically receive the data based on the properties of the given class. Look below: [anchor=section83]8.3 - Throw a method in the matter[/anchor] <?php class Person { public $firstName; public $lastName; public $age; public function __construct($firstName, $lastName, $age) { $this->firstName = $firstName; $this->lastName = $lastName; $this->age = $age; } public function greet() { return "Hello, my name is " . $this->firstName . " " . $this->lastName . ". I am " . $this->age . " years old!"; } } $newPerson = new Person('Example', 'Last Name', 22); echo $newPerson->greet(); ?> This would print: Hello, my name is Example Last Name. I am 22 years old! As you can see, the function declares the input of the properties the construct method set. Making use of the very same $this->variable. Then, since it's drawing the properties, it reads the properties set in the instance calling it. And to call the method, you use, $instant->method(). [anchor=section84]8.4 - The final chapter[/anchor] Now that you've learned the basics of OOP, let's see what you've learned! Try to be innovative and venture down from everything you've learned in this tutorial. You'll be amazed at some of the things you can accomplish! However, for a review of this section, take a look at my following example: <?php class Person { public $isAlive = true; public $firstName; public $lastName; public $age; public function __construct($firstName, $lastName, $age) { $this->firstName = $firstName; $this->lastName = $lastName; $this->age = $age; } public function greet() { return "Hello, my name is " . $this->firstName . " " . $this->lastName . ". I am " . $this->age . " years old!"; } } $newPerson = new Person('Example', 'Last Name', 22); if($newPerson->isAlive) { echo "It's alive!"; } echo "<br />"; echo $newPerson->greet(); ?> This would print: It's alive! Hello, my name is Example Last Name. I am 22 years old! I hope that everything was all clear in this section. I know that it can sometimes be confusing, but once you get the hang of it, you'll be on the fly! Though, as you can see, object-orientation is very effective for data. [anchor=section9]9 - Hope you liked it![/anchor] I hope that you've learned a lot from this guide. It has been my sole pleasure in bringing this to you. A lot of hard work and dedication was put into this! Nonetheless, if you've made it this far, from head to toe, then wow! Congratulations! I honestly was not expecting many, if any, to read this guide all the way through. As long as someone's learned from this guide, it was an accomplishment for me. If you have any questions regarding something in the guide, please post below and I'll do my best in assisting you. Hopefully, most of the sections here were explained thoroughly and to the point. I've done my best in trying to get a detailed description, however, I can understand if things may get a bit blurry. Thank you for reading, and I hope you've learned something today!
  2. Googlez

    Rsps php + sql

    I want to have the RSPS Server send a request to my http server that has a php script that will tell it ti or not to shutdown, depending on a db query. I need this for a hosting site i am creating, thanks for the help! This can just be a tutorial, actually i would prefer it to be!
  3. This tutorial covers the basics of creating your own toplist from scratch, only utilizing PHP and HTML. You may add to this and obviously make it much better. I created this code off the top of my head from 12:00AM to now (12:48AM). What this does [b]NOT[/b] include: [LIST] [*] User Registration [*] Advanced styling [*] Individual page per server/item submitted [*] Complete security [/LIST] What this [b]DOES[/b] include: [LIST] [*] Only one submission by user [*] Only can vote every 24 hours (86400 ticks) [*] Saved variables in user sessions - secure (better than cookies!) [*] Considerations for advances in design [/LIST] [LIST=1] [*]Databases [LIST] [*] Create a database named [b]test[/b] [*] Create a table called [b]toplist[/b] [LIST] [*] 5 Columns [*] ID, user_id, title, description, votes [*] INT AI, INT, VAR_CHAR(60), VAR_CHAR(500), INT [/LIST] Too lazy? Here is the SQL: [CODE] CREATE TABLE IF NOT EXISTS `toplist` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL, `title` varchar(50) NOT NULL, `description` varchar(500) NOT NULL, `votes` int(11) NOT NULL, PRIMARY KEY (`ID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; [/CODE] [*] Create a table called [b]users[/b] [*] 3 Columns [*] ID, username, password [*] INT AI, VARCHAR(50), VARCHAR(32) [*] Utilizing MD5 encryption on passwords (reasoning for 32 length) Too lazy? Here is the SQL: [CODE] CREATE TABLE IF NOT EXISTS `users` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(50) NOT NULL, `password` varchar(32) NOT NULL, PRIMARY KEY (`ID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; [/CODE] [/LIST] [*] PHP Files [LIST] [*] We will need a file for connecting remotely to our database. We will call this file [B]connect.php[/B]. Use this code within that file: [CODE] <?php function connect() { $db = new PDO('mysql:host=localhost;dbname=test;charset=utf8', 'root', 'password'); return $db; } function query($sql) { $result = mysql_query($sql); return mysql_fetch_array($result); } function getCount($sql) { $result = mysql_query($sql); return mysql_num_rows($result); }return $toArray; } ?> [/CODE] Change [b]dbname=[/b] to your database name, [b]root[/b] to your username, [b]password[/b] to your password and finally [b]host=[/b] to your remote host (if you are not using localhost). [*]Create a file called [b]index.php[/b]. This will be the main file to display our results. Paste this code within the file: [CODE] <html> <head> <title>Toplist</title> <link rel="stylesheet" href="assets/css/foundation.css"> <script src="assets/js/vendor/custom.modernizr.js"></script> </head> <body> <div class="row"> <div class="large-12 columns"> <h1>My Top List</h1> <h5>Want to post your own? Click <a href="submit.php">here</a>!</h5> <table> <?php include('connect.php'); try { $db = connect(); $stmt = $db->query("SELECT * FROM toplist ORDER BY votes DESC LIMIT 10"); $index = 1; while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { echo '<tr><td>' .$index . ' </td><td>' . $row['title'] . '</td><td>' . $row['description'] . '</td><td>' . $row['votes'] . '</td><td><a href="vote.php?ID=' . $row['ID'] . '">Vote</a></tr>'; $index++; } } catch(PDOException $ERROR_MESSAGE) { echo 'ERROR: ' . $ERROR_MESSAGE->getMessage(); } ?> </table> </div> </div> </body> </html>[/CODE] I used foundation as a basic CSS framework, you can download that [URL="http://foundation.zurb.com/"]here[/URL]. To explain briefly. We are creating a table, reading the database and dynamically creating each table row based on our database table. Our query: [CODE] SELECT * FROM toplist ORDER BY votes DESC LIMIT 10 [/CODE] Says "Select all columns from table 'toplist', then order the results by greatest to least by the columns votes. Finally return the top 10 results". We are fetching all the rows and displaying accordingly. [*] Create a file called [b]vote.php[/b]. Paste this code within the file. [CODE] <?php include('connect.php'); if (session_status() == PHP_SESSION_NONE) { session_start(); } if(isset($_SESSION['voted']) || time() - $_SESSION['vote_time'] > 86400) { try { $db = connect(); $ID = $_GET['ID']; $stmt = $db->query("SELECT * FROM toplist WHERE ID = $ID"); $row = $stmt->fetch(PDO::FETCH_ASSOC); $votes = $row['votes'] + 1; $stmt = $db->prepare("UPDATE toplist SET votes=$votes WHERE ID = ?"); $stmt->execute(array($ID)); $_SESSION['voted'] = true; $_SESSION['vote_time'] = time(); header("Location: index.php"); } catch(PDOException $ERROR_MESSAGE) { echo 'ERROR: ' . $ERROR_MESSAGE->getMessage(); } } else { echo 'ALREADY VOTED'; header("Location: index.php"); } ?> [/CODE] [*]Create a file called [b]post.php[/b] Paste this code within the file. [CODE] <?php include('connect.php'); if (session_status() == PHP_SESSION_NONE) { session_start(); } try { if(isset($_SESSION['user_id'])) { $db = connect(); $user_id = $_SESSION['user_id']; $stmt = $db->query("SELECT * FROM toplist WHERE user_id = $user_id"); $row = $stmt->fetch(PDO::FETCH_ASSOC); $row_count = $stmt->rowCount(); if($row_count == 0) { $stmt = $db->prepare("INSERT INTO toplist (title, description, user_id) VALUES(:title, :description, :user_id)"); $stmt->execute(array(':title' => $_REQUEST['title'], ':description' => $_REQUEST['description'], ':user_id' => $user_id)); echo 'Submitted'; header("Location: index.php"); } else { echo 'You already have a page submitted.'; } } else { echo 'You must login to post. '; echo '<a href="login.php">Click Here to login</a>'; } } catch(PDOException $ERROR_MESSAGE) { echo 'ERROR: ' . $ERROR_MESSAGE->getMessage(); } ?> [/CODE] [*]Create a file called [b]login.php[/b] Paste this code within the file. [CODE] <?php $error = ''; if (session_status() == PHP_SESSION_NONE) { session_start(); } if(isset($_POST['submit'])) { include 'connect.php'; try { $db = connect(); $username = stripslashes($_REQUEST['username']); $password = md5(stripslashes($_REQUEST['password'])); $stmt = $db->query("SELECT * FROM users WHERE username='$username' and password='$password'"); $row = $stmt->fetch(PDO::FETCH_ASSOC); $row_count = $stmt->rowCount(); if($row_count == 1) { $_SESSION['user_id'] = $row['ID']; header("Location: index.php"); } else { $error = 'Invalid Username/Password combination or account does not exist.'; } } catch(PDOException $ERROR_MESSAGE) { echo 'ERROR: ' . $ERROR_MESSAGE->getMessage(); } } ?> <html> <body> <span><?php echo $error; ?> <form method="POST" action=""> <label>Username:</label> <input type="text" name="username" /> <label>Password:</label> <input type="password" name="password" /> <input type="submit" name="submit" value="submit" /> </form> </body> </html> [/CODE] [*] Create a file called [b]submit.php[/b] Paste this code within that file. [CODE] <html> <form action="post.php" method="POST"> <label>Title:</label> <input name="title" type="text" /> <label>Description:</label> <input name="description" type="text" /> <input name="submit" type="submit" /> </form> </html> [/CODE] [/LIST] [/LIST] Your end result: [IMG]http://i.imgur.com/H2OsCuo.png[/IMG] [IMG]http://i.imgur.com/ozueXTm.png[/IMG] If people find this useful please let me know. If people actually take interest and utilize knowledge and show effort, I will post a more advanced and completed version of a fully functional toplist.
  4. JJE

    PHP - Hashtags

    This is a very simple, and effective way to create a hashtag system for your website, whether it be a social network, or whatever. [PHP] <?php function hashtag($input) { $output = preg_replace("/#([a-zA-Z\w]+)/", "<a href=\"hashtag.php?hash=$1\">#$1</a>", $input); return $output; } # Usage $string = "This is a cool #php tutorial by #Ddnhf"; echo hashtag($string); ?>[/PHP] [B]The code explained:[/B] Basically what we are doing, is creating a function named "hashtag" that takes the value of the variable "$input". We're using the preg_replace() function to replace the plain text hashtag with a link while setting the string into the variable "$output", now we just simply, return $output, [b]Explaining the pattern:[/b] [Copy & Pasted from Noupe.com] [quote]^ The circumflex symbol marks the beginning of a pattern, although in some cases it can be omitted $ Same as with the circumflex symbol, the dollar sign marks the end of a search pattern . The period matches any single character ? It will match the preceding pattern zero or one times + It will match the preceding pattern one or more times * It will match the preceding pattern zero or more times | Boolean OR - Matches a range of elements () Groups a different pattern elements together [] Matches any single character between the square brackets {min, max} It is used to match exact character counts \d Matches any single digit \D Matches any single non digit caharcter \w Matches any alpha numeric character including underscore (_) \W Matches any non alpha numeric character excluding the underscore character \s Matches whitespace character[/quote] Enjoy, hope this helped. Sorry for the poor explanation, I don't do it often.
  5. Hey i need one proffesional web developer (php & mysql ) for my rs2-toplist project .I need help to fix some bugs on biddig system and more. Fixes: -Auto start and end bidding date. -When bidding end top 10 ranks will see pay now button and they will be redirected to my paypal to pay the bid amount -Update old bidds when someone want to raise it (right now when someone want to raise the bid my system add a new row with a new bid) How you will do it? FTP acces or tv. Price 40$ skype dani_gonzales [url=http://prntscr.com/2yiqb6]Screenshot by Lightshot[/url]
  6. Odd enough I've been using the same auto donation that Hope released ages ago. I've used it for my old 562, and my 667 to 718. Recently someone came to me with an issue saying they didn't receive the donation they paid for. This ended up happening MULTIPLE TIMES, although not every single time. After quite a few tests, I've come to the conclusion that the error is website sided, and whenever the person donates for some reason its not adding the person to the donation database. Which then allows the server to connect and see all the details. Two files you'd need website sided. [CODE]<?php /******************************************************************************* * PHP Paypal IPN Integration Class ******************************************************************************* * Author: Micah Carrick * Email: [email protected] * Website: http://www.micahcarrick.com * * File: paypal.class.php * Version: 1.3.0 * Copyright: (c) 2005 - Micah Carrick * You are free to use, distribute, and modify this software * under the terms of the GNU General Public License. See the * included license.txt file. * ******************************************************************************* * VERION HISTORY: * v1.3.0 [10.10.2005] - Fixed it so that single quotes are handled the * right way rather than simple stripping them. This * was needed because the user could still put in * quotes. * * v1.2.1 [06.05.2005] - Fixed typo from previous fix :) * * v1.2.0 [05.31.2005] - Added the optional ability to remove all quotes * from the paypal posts. The IPN will come back * invalid sometimes when quotes are used in certian * fields. * * v1.1.0 [05.15.2005] - Revised the form output in the submit_paypal_post * method to allow non-javascript capable browsers * to provide a means of manual form submission. * * v1.0.0 [04.16.2005] - Initial Version * ******************************************************************************* * DESCRIPTION: * * NOTE: See www.micahcarrick.com for the most recent version of this class * along with any applicable sample files and other documentaion. * * This file provides a neat and simple method to interface with paypal and * The paypal Instant Payment Notification (IPN) interface. This file is * NOT intended to make the paypal integration "plug 'n' play". It still * requires the developer (that should be you) to understand the paypal * process and know the variables you want/need to pass to paypal to * achieve what you want. * * This class handles the submission of an order to paypal aswell as the * processing an Instant Payment Notification. * * This code is based on that of the php-toolkit from paypal. I've taken * the basic principals and put it in to a class so that it is a little * easier--at least for me--to use. The php-toolkit can be downloaded from * http://sourceforge.net/projects/paypal. * * To submit an order to paypal, have your order form POST to a file with: * * $p = new paypal_class; * $p->add_field('business', '[email protected]'); * $p->add_field('first_name', $_POST['first_name']); * ... (add all your fields in the same manor) * $p->submit_paypal_post(); * * To process an IPN, have your IPN processing file contain: * * $p = new paypal_class; * if ($p->validate_ipn()) { * ... (IPN is verified. Details are in the ipn_data() array) * } * * * In case you are new to paypal, here is some information to help you: * * 1. Download and read the Merchant User Manual and Integration Guide from * http://www.paypal.com/en_US/pdf/integration_guide.pdf. This gives * you all the information you need including the fields you can pass to * paypal (using add_field() with this class) aswell as all the fields * that are returned in an IPN post (stored in the ipn_data() array in * this class). It also diagrams the entire transaction process. * * 2. Create a "sandbox" account for a buyer and a seller. This is just * a test account(s) that allow you to test your site from both the * seller and buyer perspective. The instructions for this is available * at https://developer.paypal.com/ as well as a great forum where you * can ask all your paypal integration questions. Make sure you follow * all the directions in setting up a sandbox test environment, including * the addition of fake bank accounts and credit cards. * ******************************************************************************* */ class paypal_class { var $last_error; // holds the last error encountered var $ipn_log; // bool: log IPN results to text file? var $ipn_log_file; // filename of the IPN log var $ipn_response; // holds the IPN response from paypal var $ipn_data = array(); // array contains the POST values for IPN var $fields = array(); // array holds the fields to submit to paypal function paypal_class() { // initialization constructor. Called when class is created. $this->paypal_url = 'https://www.paypal.com/cgi-bin/webscr'; $this->last_error = ''; $this->ipn_log_file = '.ipn_results.log'; $this->ipn_log = true; $this->ipn_response = ''; // populate $fields array with a few default values. See the paypal // documentation for a list of fields and their data types. These defaul // values can be overwritten by the calling script. $this->add_field('rm','2'); // Return method = POST $this->add_field('cmd','_xclick'); } function add_field($field, $value) { // adds a key=>value pair to the fields array, which is what will be // sent to paypal as POST variables. If the value is already in the // array, it will be overwritten. $this->fields["$field"] = $value; } function submit_paypal_post() { // this function actually generates an entire HTML page consisting of // a form with hidden elements which is submitted to paypal via the // BODY element's onLoad attribute. We do this so that you can validate // any POST vars from you custom form before submitting to paypal. So // basically, you'll have your own form which is submitted to your script // to validate the data, which in turn calls this function to create // another hidden form and submit to paypal. // The user will briefly see a message on the screen that reads: // "Please wait, your order is being processed..." and then immediately // is redirected to paypal. echo "<html>\n"; echo "<head><title>Processing Payment...</title></head>\n"; echo "<body onLoad=\"document.forms['paypal_form'].submit();\">\n"; echo "<center><h2>Please wait, your order is being processed and you"; echo " will be redirected to the paypal website.</h2></center>\n"; echo "<form method=\"post\" name=\"paypal_form\" "; echo "action=\"".$this->paypal_url."\">\n"; foreach ($this->fields as $name => $value) { echo "<input type=\"hidden\" name=\"$name\" value=\"$value\"/>\n"; } echo "<center><br/><br/>If you are not automatically redirected to "; echo "paypal within 5 seconds...<br/><br/>\n"; echo "<input type=\"submit\" value=\"Click Here\"></center>\n"; echo ""; echo ""; echo "<center><h2>IP address "; echo "(";print ($_SERVER['REMOTE_ADDR']); echo ")</h2></center>"; echo "<center> Your IP address has been recorded with your most recent order for fraud prevention,"; echo " and to prove the transaction was completed on this computer.<br/><br/>\n"; echo "<center><h2>Have an issue? Contact us!</h2></center>"; echo " If you are not happy with the product you have purchased, post your issue on the forums.<br/><br/>\n"; echo "<center><h2>Credit Card Fraud.</h2></center>"; echo " Credit card fraud is a serious issue. If a member dishonestly disputes a charge, it may result in an investigation where details such as your ip will be<br/>\n"; echo " forwarded to your bank and credit to your bank can credit reporting agencies. Any person(s) who make a false claim to try and steal services will be held<br/>\n"; echo " responsible to the full extent of the law, also your account will be terminated and removed from the database of RuneRebellion.<br/>\n"; echo " For More information about this please read our terms of service <a href='http://www.runerebellion.com/donate/terms.html'><b>here</a>.<br>\n"; echo "<center><h2> Thanks for choosing RuneRebellion!</h2></center>"; echo "</form>\n"; echo "</body></html>\n"; } function validate_ipn() { // parse the paypal URL $url_parsed=parse_url($this->paypal_url); // generate the post string from the _POST vars aswell as load the // _POST vars into an arry so we can play with them from the calling // script. $post_string = ''; foreach ($_POST as $field=>$value) { $this->ipn_data["$field"] = $value; $post_string .= $field.'='.urlencode(stripslashes($value)).'&'; } $post_string.="cmd=_notify-validate"; // append ipn command // open the connection to paypal $fp = fsockopen($url_parsed[host],"80",$err_num,$err_str,30); if(!$fp) { // could not open the connection. If loggin is on, the error message // will be in the log. $this->last_error = "fsockopen error no. $errnum: $errstr"; $this->log_ipn_results(false); return false; } else { // Post the data back to paypal fputs($fp, "POST $url_parsed[path] HTTP/1.1\r\n"); fputs($fp, "Host: $url_parsed[host]\r\n"); fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n"); fputs($fp, "Content-length: ".strlen($post_string)."\r\n"); fputs($fp, "Connection: close\r\n\r\n"); fputs($fp, $post_string . "\r\n\r\n"); // loop through the response from the server and append to variable while(!feof($fp)) { $this->ipn_response .= fgets($fp, 1024); } fclose($fp); // close connection } if (eregi("VERIFIED",$this->ipn_response)) { // Valid IPN transaction. $this->log_ipn_results(true); return true; } else { // Invalid IPN transaction. Check the log for details. $this->last_error = 'IPN Validation Failed.'; $this->log_ipn_results(false); return false; } } function log_ipn_results($success) { if (!$this->ipn_log) return; // is logging turned off? // Timestamp $text = '['.date('m/d/Y g:i A').'] - '; // Success or failure being logged? if ($success) $text .= "SUCCESS!\n"; else $text .= 'FAIL: '.$this->last_error."\n"; // Log the POST variables $text .= "IPN POST Vars from Paypal:\n"; foreach ($this->ipn_data as $key=>$value) { $text .= "$key=$value, "; } // Log the response from the paypal server $text .= "\nIPN Response from Paypal Server:\n ".$this->ipn_response; // Write to log $fp=fopen($this->ipn_log_file,'a'); fwrite($fp, $text . "\n\n"); fclose($fp); // close file } function dump_fields() { // Used for debugging, this function will output all the field/value pairs // that are currently defined in the instance of the class using the // add_field() function. echo "<h3>paypal_class->dump_fields() Output:</h3>"; echo "<table width=\"95%\" border=\"1\" cellpadding=\"2\" cellspacing=\"0\"> <tr> <td bgcolor=\"black\"><b><font color=\"white\">Field Name</font></b></td> <td bgcolor=\"black\"><b><font color=\"white\">Value</font></b></td> </tr>"; ksort($this->fields); foreach ($this->fields as $key => $value) { echo "<tr><td>$key</td><td>".urldecode($value)." </td></tr>"; } echo "</table><br>"; } }[/CODE] The above code is labeled paypal.class.php [CODE]<?php /* PHP Paypal IPN Integration Class Demonstration File * 4.16.2005 - Micah Carrick, [email protected] * * This file demonstrates the usage of paypal.class.php, a class designed * to aid in the interfacing between your website, paypal, and the instant * payment notification (IPN) interface. This single file serves as 4 * virtual pages depending on the "action" varialble passed in the URL. It's * the processing page which processes form data being submitted to paypal, it * is the page paypal returns a user to upon success, it's the page paypal * returns a user to upon canceling an order, and finally, it's the page that * handles the IPN request from Paypal. * * I tried to comment this file, aswell as the acutall class file, as well as * I possibly could. Please email me with questions, comments, and suggestions. * See the header of paypal.class.php for additional resources and information. */ session_start(); $base = "/var/www/html/"; include("db.php"); require_once('paypal.class.php'); // include the class file $p = new paypal_class; // initiate an instance of the class //$p->paypal_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; // testing paypal url $p->paypal_url = 'https://www.paypal.com/cgi-bin/webscr'; // paypal url // setup a variable for this script (ie: 'http://www.micahcarrick.com/paypal.php') $this_script = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']; // if there is not action variable, set the default action of 'process' if (empty($_GET['action'])) $_GET['action'] = 'process'; if (empty($_GET['amm'])) $_GET['amm'] = '1'; switch ($_GET['action']) { case 'process': // Process and order... if (empty($_GET['prod'])){ header("Location: http://www.runerebellion.com/donate.html"); exit; } if (empty($_GET['username'])){ if($_GET['action'] = 'process'){ header("Location: http://www.runerebellion.com/donate.html"); exit; } } //if(!isset($_SESSION["username"])) { // header("Location: login.php"); // exit; //} // include("include.php"); //die("donation is temporarily disabled!"); // There should be no output at this point. To process the POST data, // the submit_paypal_post() function will output all the HTML tags which // contains a FORM which is submited instantaneously using the BODY onload // attribute. In other words, don't echo or printf anything when you're // going to be calling the submit_paypal_post() function. // This is where you would have your form validation and all that jazz. // You would take your POST vars and load them into the class like below, // only using the POST values instead of constant string expressions. // For example, after ensureing all the POST variables from your custom // order form are valid, you might have: // // $p->add_field('first_name', $_POST['first_name']); // $p->add_field('last_name', $_POST['last_name']); if($_GET['prod'] == 1) { $p->add_field('item_name', '10 Donator Points'); $price = '10'; } else if($_GET['prod'] == 2) { $price = '25'; $p->add_field('item_name', '25 Donator Points'); } // you can add as many as you want, these two corralate with the two options insides index.php $p->add_field('custom', $_GET['username']); $p->add_field('business', 'yeh ima hide dis'); //edit to your email $p->add_field('return', $this_script.'?action=success'); $p->add_field('cancel_return', $this_script.'?action=cancel'); $p->add_field('notify_url', $this_script.'?action=ipn'); //$p->add_field('item_name', 'Product Number: '.$_GET['prod']); $p->add_field('item_number', $_GET['prod']); $p->add_field('currency_code', 'USD'); $p->add_field('amount', $price); //$p->add_field('quantity', $_GET['amm']); $p->add_field('lc', 'GB'); $p->submit_paypal_post(); // submit the fields to paypal //$p->dump_fields(); // for debugging, output a table of all the fields break; case 'success': // Order was successful... // This is where you would probably want to thank the user for their order // or what have you. The order information at this point is in POST // variables. However, you don't want to "process" the order until you // get validation from the IPN. That's where you would have the code to // email an admin, update the database with payment status, activate a // membership, etc. //include("include.php"); echo "<h2>Donation Successful</h2><p>Your donation has been completed. To receive your items, log in to the Server. If you are already logged in, your must logout and then log back in.</p>"; // You could also simply re-direct them to another page, or your own // order status page which presents the user with the status of their // order based on a database (which can be modified with the IPN code // below). break; case 'cancel': // Order was canceled... // The order was canceled before being completed. //include("include.php"); echo "<h2>Donation Cancelled</h2><p>Your donation was cancelled.</p>"; break; case 'ipn': // Paypal is calling page for IPN validation... // It's important to remember that paypal calling this script. There // is no output here. This is where you validate the IPN data and if it's // valid, update your database to signify that the user has payed. If // you try and use an echo or printf function here it's not going to do you // a bit of good. This is on the "backend". That is why, by default, the // class logs all IPN data to a text file. if ($p->validate_ipn()) { // Payment has been recieved and IPN is verified. This is where you // update your database to activate or process the order, or setup // the database with the user's order details, email an administrator, // etc. You can access a slew of information via the ipn_data() array. // ANTI LEECH! // in the ipn_data() array. //$fh = fopen(".ipn", "a"); //fwrite($fh, print_r($p->ipn_data, true)); //fclose($fh); //ANTI LEECH! // For this example, we'll just email ourselves ALL the data. if($p->ipn_data["payment_status"] != "Completed") die(); if($p->ipn_data["mc_gross"] > 0) { $user = $p->ipn_data["custom"]; $date = $p->ipn_data["payment_date"]; $prodid = $p->ipn_data["item_number"]; $amount = $p->ipn_data["mc_gross"]; $amountTickets = 1; //$user = str_replace("-", "_", $user); //$user = str_replace(" ", "_", $user); $user = str_replace("-", " ", $user); $user = str_replace("_", " ", $user); $user = mysql_real_escape_string($user); mysql_query("INSERT INTO donation (username, time, productid, price, tickets) VALUES ('" . $user . "', '" . $date . "', '" . $prodid . "', " . $amount . ", " . $amountTickets . ");"); $fh = fopen("donationlog.txt", "a"); fwrite($fh, $user.' '.$date.' '.$prodid.' '.$amount.' '.$amountTickets); fclose($fh); } else if($p->ipn_data["mc_gross"] < 0) { /* $user = $p->ipn_data["custom"]; $user = str_replace("-", "_", $user); $user = str_replace(" ", "_", $user); $user = mysql_real_escape_string($user); $res = mysql_query("SELECT * FROM bans WHERE username = '" . $user . "');"); if(mysql_num_rows($res) == 0) { mysql_query("INSERT INTO bans (username, bannedBy, unbanDate, reason) VALUES ('" . mysql_real_escape_string($user) . "', 'Emps-Scape Server', 0, 'automated ban: ipn refund issued');"); }*/ } } break; } ?>[/CODE] This above class is Paypal.php I'm not very skilled with php, or html, so I can't read through that and see any errors like some. Also here is a error log, I've noticed two different warnings in total, but it may be of some use. [CODE][27-Jan-2014 01:37:20 America/Chicago] PHP Warning: fsockopen(): unable to connect to www.paypal.com:80 (Connection timed out) in /home/runerebe/public_html/donate/paypal.class.php on line 202 [27-Jan-2014 01:38:24 America/Chicago] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20100525/suhosin.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20100525/suhosin.so: cannot open shared object file: No such file or directory in Unknown on line 0 [/CODE] I included [I]paypal.class.php[/I] file, feel free to view line 202. As for the senond warning, I'm not aware on how important it is to have the missing file, or its effects on the script. Thanks in advance for any assistance given.
  7. Hi guys. I have a website that i'm working on and I need GOOD php developer to work with me on some of the stuff on it. I will be paying for each task that's completed. Requirements: - GOOD PHP experience - Codeigniter (Not required but it would help a lot) - Experience with Twitter-Bootstrap framework is a plus. I need someone who write english very well. Please send me a PM if you might be interested in this project. *THIS IS NOT A RSPS*
  8. Hey i was wondering if anybody could make a PHP page for me so i can hook it up to my application Form and receive feedback and things from other people.
  9. This is another version of the 'creating your own toplist'. This one I made today while I was bored at work. It includes: [LIST] [*]Login System - SHA1 Hashing for passwords [*]Registering System (simple) [*]Server & Top List [*]Control Panel [*]Stored values through session [*]Individual pages for submitted accounts [*]Voting (24 hour based) [/LIST] This is not a completed project, but a base for others to start on. I used the classes provide from this [URL="https://github.com/indieteq/PHP-MySQL-PDO-Database-Class"]Github [/URL]to help assist me and save time. This project was built using the Gumby CSS framework, you can check that out in more detail [U][URL="http://gumbyframework.com/"]here[/URL][/U]. You can download this project here: [url]http://www.mediafire.com/?vyecf1n7cee1ftp[/url] Please remember to update your information in [b]settings.ini.php[/b]. [IMG]http://i.imgur.com/b4hB26E.png[/IMG] [IMG]http://i.imgur.com/fm8POmG.png[/IMG] [IMG]http://i.imgur.com/WJw9XdZ.png[/IMG] [IMG]http://i.imgur.com/o7XMwxv.png[/IMG]
  10. To whom it may concern, Its been nearly 5 years since ive even looked at an rsps and I am currently having a bit of a play around with a 562 server on my vps and website. The help i need, which I will pay for if required: Webclient. Ive got as far as having a working signed jar but i get on my desktop but i get an error when i post it to my website with it not being able to find client.class I think its something to do with the HTML code i am using to embed it, although I am not positive. [CODE] <html> <title> Webclient </title> <body onbeforeunload="javascript:alert('Be sure your account is logged out before closing this page!');"> <applet name="Dynastyscape Webclient" width="100%" height="100%" archive="working.jar" code="client.class" mayscript> <param name="worldid" value="2" /> <param name="members" value="1" /> <param name="modewhat" value="2" /> <param name="modewhere" value="2" /> <param name="safemode" value="1" /> <param name="lang" value="0" /> <param name="affid" value="0" /> <param name="settings" value="ROEqp2kbj*NX9PSCbdgpOvokkMwrCkXjg3c6KXgaLZY" /> <param name="cookieprefix" value="" /> <param name="cookiehost" value=".google.com" /> <param name="plug" value="0" /> <param name="js" value="1" /> <param name="game" value="0" /> <param name="colourid" value="0" /> </applet> </body> </html> [/CODE] Would also like someone with a bit of knowledge on PHP to eventually help me implement PHP highscores and the like. Also just some general knowledge on the RS2HD framework would come in handy. I understand this is my first post and I may come across as a noob, but I cant remember any of my old account details. I also have my own website as well as a dedicated server. Will pay anyone for their help in either cash or return favours. Contact via PM would be preferred. Regards, Liam EDIT UPDATE: Now have it directing me to mywebsiteurl/error_game_invalidhost.ws which does not exist
  11. So when I post, it comes up like this. [IMG]http://puu.sh/39EJn.png[/IMG] I've tried looking at the code, changing styles, replacing the css.php with older version. I can't fix it, please help! Here's the code for the post also. [CODE]<li class="postbitlegacy postbitim postcontainer old" id="post_1"> <!-- see bottom of postbit.css for .userinfo .popupmenu styles --> <div class="posthead"> <span class="postdate old"> <span class="date">Today, <span class="time">03:06 PM</span></span> </span> <span class="nodecontrols"> <a name="post1" href="showthread.php?1-Testing&p=1&viewfull=1#post1" class="iepostcounter">#1</a><a id="postcount1" name="1"></a> <label for="post_imod_checkbox_1"><input class="postimod" type="checkbox" id="post_imod_checkbox_1" name="plist[1]" value="0" /></label> </span> </div> <div class="postdetails"> <div class="userinfo"> <div class="username_container"> <div class="popupmenu memberaction"> <a class="username online popupctrl" href="member.php?1-Plasma" title="Plasma is online now"><strong><font color="red>Plasma</font></strong></a> <ul class="popupbody popuphover memberaction_body"> <li class="left"> <a href="member.php?1-Plasma" class="siteicon_profile"> View Profile </a> </li> <li class="right"> <a href="search.php?do=finduser&userid=1&contenttype=vBForum_Post&showposts=1" class="siteicon_forum" rel="nofollow"> View Forum Posts </a> </li> <li class="left"> <a href="private.php?do=newpm&u=1" class="siteicon_message" rel="nofollow"> Private Message </a> </li> <li class="right"> <a href="blog.php?u=1" class="siteicon_blog" rel="nofollow"> View Blog Entries </a> </li> <li class="right"> <a href="http://www.deucallion.com/forums/list.php?author/1-Plasma" class="siteicon_article" rel="nofollow"> View Articles </a> </li> </ul> </div> <img class="inlineimg onlinestatus" src="images/ReptileGreen/statusicon/user-online.png" alt="Plasma is online now" border="0" /> </div> <span class="usertitle"> Administrator </span> <hr /> <dl class="userinfo_extra"> <dt>Join Date</dt> <dd>Jun 2013</dd> <dt>Posts</dt> <dd>1</dd> </dl> <div class="imlinks"> </div> </div> <div class="postbody"> <div class="postrow"> <h2 class="title icon"> Testing </h2> <div class="content"> <div id="post_message_1"> <blockquote class="postcontent restore "> Test Test Test </blockquote> </div> </div> </div> <div class="cleardiv"></div> </div> </div> <div class="postfoot"> <!-- <div class="postfoot_container"> --> <div class="textcontrols floatcontainer"> <span class="postcontrols"> <img style="display:none" id="progress_1" src="images/ReptileGreen/misc/progress.gif" alt="" /> <a class="editpost" href="editpost.php?p=1&do=editpost" name="vB::QuickEdit::1" title="Edit / Delete"><img src="clear.gif" id="editimg_1" alt="Edit / Delete" /> Edit Post</a> <span class="seperator"> </span> <a id="qr_1" class='quickreply' href="newreply.php?do=newreply&p=1&noquote=1" rel="nofollow" title="Quick reply to this message"><img id="replyimg_1" src="clear.gif" alt="Quick reply to this message" /> Reply</a> <span class="seperator"> </span> <a id="qrwq_1" class="newreply" href="newreply.php?do=newreply&p=1" rel="nofollow" title="Reply With Quote"><img id="quoteimg_1" src="clear.gif" alt="Reply With Quote" /> Reply With Quote</a> <span class="seperator"> </span> <a class="multiquote" href="newreply.php?do=newreply&p=1" rel="nofollow" onclick="return false;" id="mq_1" title="Multi-Quote This Message"><img id="mq_image_1" src="clear.gif" alt="Multi-Quote This Message" /> </a> </span> <span class="postlinking"> <a href="http://www.deucallion.com/forums/content.php?1/addcontent&contenttypeid=24&postid=1&parentid=1" class="promotecms">Promote to Article</a> <span class="seperator"> </span> <a class="blog" href="blog_post.php?do=newblog&p=1"><!-- <img src="images/ReptileGreen/misc/blog/blogpost_40b.png" alt="Blog this Post" />--> Blog this Post</a> <span class="seperator"> </span> <a class="ip" href="postings.php?do=getip&p=1" title="IP: 101.103.54.77">  <!-- <img class="inlineimg" src="images/ReptileGreen/buttons/ip-40b.png" alt="IP" title="IP: 101.103.54.77" /> --></a>  <a class="report" href="report.php?p=1" rel="nofollow" title="Report Post"><!-- <img src="images/ReptileGreen/buttons/report-40b.png" alt="Report Post" /> --> </a>   </span> <!-- </div> --> </div> </div> <hr /> </li> [/CODE] I think that's the part that's needed. The other part is just meta data. That doesn't matter. *EDIT* Note some of the buttons are missing too. Add me on skype - Kempy1996 or just reply here. Please help!
  12. Hello, I am just wondering how I can make it so, instead of me doing the "/prune" command or something for a user, I can press a "button," PHP/AJAX button(s) next to their name that executes the given command. For example, buttons that could look like this next to their name: [code][COLOR="#FF0000"]HTML CODE (for "base" of what I would like to do):[/COLOR] <button type="button"> <b>P</b></button> <button type="button"> <b>S</b></button> <button type="button"> <b>B</b></button> [/code] So, when I press the "P" button next to the user's name for example, it would prune their post(s). When I would press the "S" button next to their name, it would silence them. And lastly, when I press the "B" button next to the user's name, it would ban them. I am just curious how I would do this and where I would put all of the given commands and stuff. Also, for security of course, if I get this far with help, how would I make it so only administrators could only see/use the button? I have seen this before in an infernoshout pro shoutbox before, I am just wondering because it has so many unique purposes. Thanks a lot! ~Derek
  13. Hi everyone i made something with php. and idk how to host it. i tried downloading php.net but wouldnt work can someone please help me :P
  14. I am working on a toplist with a friend of mine, and we are having some issues with the voting system. There are many issues with the voting script, and I need someone to come and help fix it. Sadly, I cannot do a cash reward. Sorry about that. But if someone could fix this for me, that'd be amazing.
  15. Hey Guys, today i'm going to be telling you about a brilliant program that you can use to get started off with PHP! This wonderful program is called Xampp and has many wonderful features. It has everything and anything you need to create a website; the limits to which are only limited by your abilitie. :) Here is the download link for Xampp: [url]http://sourceforge.net/projects/xampp/files/XAMPP%20Windows/1.8.0/xampp-win32-1.8.0-VC9-installer.exe/download?use_mirror=nchc&download=[/url] And here is a great tutorial series for learning PHP: [url]http://www.youtube.com/watch?v=iCUV3iv9xOs[/url] Please watch the continuing videos in the series. :) Hope this helps you guys. Kind Regards, Wyatt.
  16. [CENTER][B][U]MySQL with PHP - The Introduction[/U][/B][/CENTER] This is the start of a many (or a few) tutorials for using MySQLi with PHP. My most recent projects I've been involved with I've been using a MySQL "class" that I have from an old tutorial over at TutsPlus so it's what we'll be using throughout these small tutorials/guides. [B][U]What can be done with MySQL?[/U][/B] Simply put, MySQL is a Database Management System that runs partly as a server. Almost all dynamic websites you see these days use MySQL to complete many primary tasks. RuneLocus, for an example has databases for pretty much all their features: Toplist, Server Status, Item Database, Forums and pretty much anything else that "remembers" something. MySQL works well with PHP GET and POST. For an example when you visit the page of a server on the toplist there's a lot that goes on behind the scenes. Normally you'll see the "pretty" URL's. [B][I]Example 1:[/I][/B] We'll use the Fatality614 server which at this time has the ID "277" which is unique to only that server. The pretty URL (that you'll see) is like this - [url]http://www.runelocus.com/toplist/details-277-Fatality614_CHRISTMAS_EVENT.html[/url] however we can also view this server a different way. As we, RuneLocus has made it show the action first, then the ID and then finally the name of that server. We can also view this server by specifying the action and ID like this. [url]http://www.runelocus.com/toplist/index.php?action=details&id=277[/url]. By each and every server having its own, unique ID the system that RuneLocus use can then easily use a MySQL Query that looks for something in the database. The SQL would look something like this: [CODE]SELECT * FROM `servers` WHERE `id` = 277 LIMIT 1[/CODE] This SQL query is saying to SELECT * (all data) from the table named 'servers' and where the ID is equal to 277 (Fatality614's unique ID). After running this query we can then also run others which can return an array of the all the data about id 277 such as the votes, name, status and more. [B][I]Example 2:[/I][/B] Use it with your own RSPS! A common function with MySQL in RSPS are things such as website hiscores, auto-donate or vote4cash scripts. Java is easily implemented into Java but we won't be going over that just yet. Maybe in a later tutorial? An auto-donate script can be used by storing data from a transaction (learn about the PayPal IPN) such as the item they donated for and then in-game the character can type something such as ::donate which checks the database to see if they've ordered anything and if yes, give it to their character. [B][U]I hear MySQL has lots of vulnerabilities?[/U][/B] Whoever says this generally has no idea what they're talking about. MySQL or databases in general are only as safe as you make them. This can include by stripping out tags/sanitizing variables or using a pre-made MySQL class for which we'll be using in for these tutorials. [B][U]What's this class you speak of?[/U][/B] It's a highly secure class that has been proven to myself multiple times. It can help cut back on code and best of all, you don't have to worry about SQL Injections. It's close to 300 lines so I have put it on Pastebin, which can be viewed [URL="http://pastebin.com/XWatcB4B"]here[/URL]. [B][U]OMG, it looks so confusing![/U][/B] Don't worry, you'll learn everything that you'll need to know about this class in these tutorials. It will become like a second language to you! [B][U]For the next step:[/U][/B] To be prepared for the next step, ensure that you have a webserver that has PHP and MySQL installed. I recommend using [URL="http://www.wampserver.com/en/"]Wamp.[/URL] Make the following path by creating new folders. "location_to_wamp/www/tutorials/mysql/includes". Add the MysqlDB.php class to the includes folder. [B][U]To sum it up:[/U][/B] So in this first, relatively short tutorial you've learnt what MySQL Databases are and how it can be used for website based applications and how you can implement it with your very own RSPS.
  17. There isn't alot of practical use to this topic's subject, but I figure it is cool to know what happens under the hood in PHP. :) You can find PHP and the Zend Engine's source code here: [URL="http://lxr.php.net/xref/"]Cross Reference:[/URL] [B]zend value/zval[/B] - A struct ([I]_zval_struct[/I]) containing information about a variable. A zval is essentially a variable in PHP. [B]zval value[/B] - A union ([I]zvalue_value[/I]) which holds the value of a zval (according to its value's type). These values include: a double, long, zend object, HashTable, and string. This proves types such as resources, integers, nulls, and booleans are all represented as longs. A union holds the data of one value at a time. Types in PHP are defined in the Zend Engine in the [B]Zend/zend.h[/B] header file. The header file contains the zval struct, which within that contains the [I]zvalue_value[/I] union which holds the actual [I]variable data[/I] and a [I]type identifier[/I]. [code]typedef union _zvalue_value { long lval; /* long value */ double dval; /* double value */ struct { char *val; int len; } str; HashTable *ht; /* hash table value */ zend_object_value obj; } zvalue_value; struct _zval_struct { /* Variable information */ zvalue_value value; /* value */ zend_uint refcount__gc; zend_uchar type; /* active type */ zend_uchar is_ref__gc; };[/code] The [I]zvalue_value[/I] union defines PHP's [B]internal[/B] variable data types. Although integers and floats exist as types in PHP, they aren't actually stored as these types in variables. Instead, values are stored as: [LIST] [*]Booleans, bytes, shorts, and integers are stored as longs. [*]Floats are stored as doubles. [*]Chars (including a single char) are stored as Strings. [*]Resources have a long identifier which is used to identify the resource type. [*]Arrays are actually HashTables. [*]A null is well... a null. [/LIST] The [I]zend_object_value[/I] is a special struct specifically for objects which will (hopefully) be covered in later posts. The [I]type[/I] field stores a numeric representation of the type of the data which is stored. These types are defined in the same file: [code]/* data types */ /* All data types <= IS_BOOL have their constructor/destructors skipped */ #define IS_NULL 0 #define IS_LONG 1 #define IS_DOUBLE 2 #define IS_BOOL 3 #define IS_ARRAY 4 #define IS_OBJECT 5 #define IS_STRING 6 #define IS_RESOURCE 7 #define IS_CONSTANT 8 #define IS_CONSTANT_ARRAY 9 #define IS_CALLABLE 10[/code] You can look deeper into PHP's types by exploring functions such as gettype() or settype() and the various value functions (intval(), strval(), etc.) in the [B]ext/standard/type.c[/B] and [B]Zend/zend_operators.c[/B] files. The [I]refcount__gc[/I] and [I]is_ref__gc[/I] are used for garbage collection, and they are just used to store a count of references to this variable.
  18. [CENTER][B][U]MySQL with PHP - The Basics[/U][/B][/CENTER] Incase you missed it, here's the introduction/part 1 for these tutorials that includes the class. [url]http://www.runelocus.com/forums/showthread.php?84642-MySQL-with-PHP-Introduction&p=699529#post699529[/url] In part 2 we are going to cover: [LIST] [*]How to include the MySQL Class [*]How to connect to a database [*]Use the select query/function to retrieve data from the database [/LIST] [B][U]Including the class:[/U][/B] For these tutorials the location to our files will be "tutorials/mysql". In that main folder I'm going to have an index.php page and a folder named "includes" which will have the MySQL class (MySQL.php). Open index.php and modify it so it looks like: [PHP]<?php require_once("includes/MysqlDB.php"); ?>[/PHP] Note: You may want to use an IDE such as Netbeans. It will help you a lot. [U][B]Making the Database:[/B][/U] Now that you have your web server installed and running go to [url]http://localhost/phpmyadmin[/url]. You'll either be logged in automatically or use the credentials you used when setting up Wamp to login. Try the user "root" and leave the password empty. Click the button "Databases" up in the top menu and create a new database called tutorial_mysql [B]Username:[/B] root [B]Host:[/B] localhost (leave blank when in "Add user") [B]Database Name:[/B] tutorial_mysql [B]Password:[/B] Also check the box that says "Create database with same name and grant all privileges". This will just create the database and name it the same as the username (tutorial_mysql). Navigate to your tutorial_mysql database (should be in the left hand, side menu), click on "SQL" and execute the following script: [CODE]CREATE TABLE IF NOT EXISTS `users` ( `id` int(4) NOT NULL AUTO_INCREMENT, `username` varchar(24) NOT NULL, `password` varchar(48) NOT NULL, `email` varchar(100) NOT NULL, `age` int(3) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; -- -- Dumping data for table `users` -- INSERT INTO `users` (`id`, `username`, `password`, `email`, `age`) VALUES (1, 'Surreal', 'password', '[email protected]', 20);[/CODE] This script will create a table named "users" with a structure including a unique ID, username, password, email and age. I've made an example user already and this should already be in your database. [B][U]Initialize the connection/class:[/U][/B] Now we want to open or initialize the MySQL class and construct it. To do this we will add the following line under require_once...... [PHP]$Db = new MySqlDb('localhost', 'root', '', 'tutorial_mysql');[/PHP] Navigate to the page [url]http://localhost/tutorials/mysql/index.php[/url] and you should have a blank page. If it says "There was a problem connecting to the database" then you've done one of the steps wrong and it can't connect to the database we just made. [B][U]The Select Query:[/U][/B] This function can be used to select and export/get data from a database. This can be used to get all details about someone with the username "Surreal" such as their age and password. Here's an example of what it would look like using our MysqlDB Class. [PHP]$Db->where('id', 1); $results = $Db->get('users');[/PHP] You can add this code under the $Db = .... line. Refresh the index.php page and what do we have..? Nothing! Why? These two lines basically mean to look where the id is equal to 1 in the table called users. The $results variable is now an array that has all the data about the user where id = 1. [I][B]How do I show the data?[/B][/I] Under the $results = .... line add the following code: [PHP]?> <pre> <?php print_r($results); ?></pre><?php[/PHP] But what does it mean? The pre tags are html (they keep the array in a state where white space isn't removed. In other words, it looks nicer.) so we keep them out of the PHP hence the reason we close and open the tags. print_r is a PHP function which, for an array will present the values in a format that shows keys and elements. Refresh your index.php page now. Fancy, eh? Your page should look something like this: [CODE] Array ( [0] => Array ( [id] => 1 [username] => Surreal [password] => password [email] => [email protected] [age] => 20 ) ) [/CODE] This is much easier to read now but not very helpful for a functional site, right? Let's display the username, email and age only on the page. We can use a foreach loop to display only the data we want. We only have one result (unique IDs) so it'll only loop once. If we didn't specify the ID or had multiple users with the same ID, it would display the information for each row/user. [PHP]foreach($results as $row): echo "<h2>Username: ".$row['username']."</h2>"; echo "<div>Email: ".$row['email']."</div>"; echo "<div>Age: ".$row['age']."</div>"; endforeach; [/PHP] You can use this code where the previous code was (this one): [PHP]?> <pre> <?php print_r($results); ?></pre><?php[/PHP] Ahh.... much nicer now: [CODE]Username: Surreal Email: [email protected] Age: 20[/CODE] So, that's about all for the select query/function. If you want to fetch all users all you have to do is remove the $Db->where.... line and the foreach loop will just repeat itself for each user. Handy, right? [B][U]For the next step:[/U][/B] You have to do nothing! Next time we'll be looking at the delete and insert functions. [B][U]To sum up:[/U][/B] We can now manually "insert" data via PHPMyAdmin and display it on our site with just a few lines! Pretty cool, right? This script can be used to build a user login system by making a form in HTML and then using the post variables and seeing if the username exists, if yes, check if the password is correct where username = $_POST['username']. Remember to encrypt your passwords! After following the next tutorial you'll be able to add a registration form and have a complete system in place!
  19. Hey Runelocus Members, In this tutorial, I will teach you how to successfully secure your password using the MD5() without it being de-crypted (Depends on Password). Though there are much better ways like sanitizing, using salt, SHA-256 and so on, but because this isn't really a PHP forum, I wont go in depth. However, this is a very much good way of securing your password. [B]Requirements: [/B] 1- Web-host with PHP installed. (Latest version would be nice) 2- Perhaps a small understanding of PHP, more or less, copy and paste. Alright, if you meet the requirements, then please open your file manager in your web-host CPanel. Create a new directory called [b]md5[/b] or you can use your current directory or create another directory of your choice. Anyway, create a new file called [B]md5.php[/B]. Open it and add the following code. [php] <? $password = $_POST['password']; if(isset($_POST['submit'])) { $newpass = md5($password); echo 'Your encrypted password is now: ' . $newpass; } ?> <html> <form method="POST"> <input type="text" name="password" placeholder="type a password" /> <input type="submit" name="submit" value="MD5 Password!" /> </form> </hmtl> [/php] [B]Code explanation:[/B] To encrypt a password we want, we are going to have to send it to PHP so it can be processed. We can use the [b]$_POST[/b] method. As you can see, on the input field, there is a name called [b]password[/b], and a PHP code $_POST['[b]password[/b]'];. Because of this, the form will be able to communicate with PHP and will be able to process what ever the code provided is below. In this case, it'l be encrypting any text submitted from the form. The [B]isset()[/B] function is used to check whether the variable [b]$_POST['submit'][/b] is set and not null. Else, nothing would happen on the page after clicking submit. The [b]$newpass[/b] variable takes the password sent from the form and encrypts it using the MD5(). As the code shown: [code] $newpass = md5($password); [/code] Md5($password), everything that the $password variable has taken from the form, will be encrypted as it's being wrapped around the MD5(); function. Lastly, echoing the results. As you can see, [code] echo 'Your encrypted password is now: ' . $newpass; [/code] After the encryption has completed, it will then echo your new password! The [b]$newpass[/b] simply gets the MD5 version of your password and prints it onto the page. [B]The Results:[/B] Here is how the form would look like: [img]http://i.imgur.com/HQL3G.png[/img] And now, here is what it would look like after I have encrypted my password: [img]http://img252.imageshack.us/img252/8904/6ce49140d4d14b928965380.png[/img] Now as you can see, my password has turned into a 128-bit 32-character hexadecimal value. And there you have it! Your password has been encrypted. [b]Why can't I just encrypt my password on those free MD5 sites?[/b] The reason is quite obvious, for every encryption you do, they will store in their database. And then, if you wanted to decrypt it, you would find your origional password as they will find a matching hash on their database. Here's proof that they cannot decrypt a MD5 that I've created using the code above: [spoiler=proof] Here a hash that I've just got after encrypting my password on my host: [img]http://i.imgur.com/LCVPn.png[/img] Now, using the hash provided, I will attempt to decrrypt it using the top 3 MD5 decryptor websites using the google search: Result1: - [url]http://www.md5decrypter.co.uk/[/url] [img]http://img41.imageshack.us/img41/7708/afc02d56c33443a6a738a8a.png[/img] Result2: - [url]http://www.md5decrypter.com/[/url] [img]http://i.imgur.com/juGub.png[/img] Restul3: - [url]http://www.md5online.org/[/url] [img]http://i.imgur.com/xoqLV.png[/img] And there you have it. As you can see, even the top 3 MD5 decrypter sites failed to get my password. Obviously, if you're going to use a password like "john" or "123456", then it will be decrypted easily as MD5() does not randomize the password. [/spoiler] I hope my tutorial have given you a brief understanding on how to use MD5(), I couldn't think of a better tutorial, and I really had MD5() in my head. I don't mind what feedback I get, but if I helped you, please thank this thread! I'm also good with Jquery, I could perhaps make a tutorial with Jquery too? Thanks, Nick Magic23.
  20. I have made this because I know that it can be messy and frustrating to perform sql querys. It is easy to use and it should work. Any questions? Pm me about them or post them here. Latest version: [ATTACH]6740[/ATTACH] I did not test all functions as I have made this in like 10 minutes. It's a VERY little and simple tool but really useful to keep your code clean. You can do: [LIST] [*]insert queries [*]update queries [*]get queries [*]custom sql queries (with possible return value) [/LIST] == CHANGELOG == V2: added the condition object (WHERE clause, thanks to [MENTION=11]Daedalus[/MENTION])
  21. im getting these 2 errors: Deprecated: Function mysql_list_tables() is deprecated in /home/content/88/9892588/html/vote.php on line 38 Deprecated: Function sql_regcase() is deprecated in /home/content/88/9892588/html/vote.php on line 65 [code] { if ( [MENTION=103481]Mysql[/MENTION]_connect(MYSQL_HOST, MYSQL_USERNAME, MYSQL_PASSWORD)) die("Could not connect to mysql database: " . mysql_error()); if ( [MENTION=103481]Mysql[/MENTION]_select_db(MYSQL_DATABASE)) die("Could not select mysql database: " . mysql_error()); $tables = mysql_list_tables(MYSQL_DATABASE);//-------------------line 38 while (list($temp) = mysql_fetch_array($tables)) { if ($temp == "votes") { return; } } query("CREATE TABLE `votes` ( `playerName` VARCHAR( 255 ) NOT NULL , `ip` VARCHAR( 255 ) NOT NULL, `time` BIGINT NOT NULL , `recieved` INT( 1 ) NOT NULL DEFAULT '0')"); } /** * query(string query) this function is used to query the mysql database server. */ function query($s) { $query = [MENTION=103481]Mysql[/MENTION]_query($s); if (!$query) die("Error running query('" . $s . "'): " . mysql_error()); return $query; } /** * anti_inject(string text) this function is used to make sure no injections can be made. */ function anti_inject($sql) { $sql = preg_replace(sql_regcase("/(from|select|insert|delete|where|drop table|show tables|#|\*|--|\\\\)/"),//---------------------->(line65) "", $sql); $sql = trim($sql); $sql = strip_tags($sql); $sql = addslashes($sql); $sql = strtolower($sql); return $sql; } [/code]
  22. Hello, So I am trying to display something from a database but instead of plaintext make it so it actually does what it is in the column for example; If in the column it says [code] rand(1, 100) [/code] Instead of showing on the page [code] rand(1, 100) [/code] It actually randomizes a number in between 1,100 just like the PHP function. Is there anyway to do this? ~ Thanks in advance
  23. Okay so I am using a vote system I found on R-S. But one of the functions was stopped at PHP 4.7. Now I am hosting with GoDaddy and they have PHP 5 which means that it is not working "/ I know there are a lot of decent web developers on this forum so could someone have a look at how I would solve this: Current code - None functional with PHP 5 [CODE] function connect() { if ([email protected]_connect(MYSQL_HOST, MYSQL_USERNAME, MYSQL_PASSWORD)) die("Could not connect to mysql database: " . mysql_error()); if ([email protected]_select_db(MYSQL_DATABASE)) die("Could not select mysql database: " . mysql_error()); $tables = mysql_list_tables(MYSQL_DATABASE); while (list($temp) = mysql_fetch_array($tables)) { if ($temp == "votes") { return; } } } [/CODE] Error: [CODE] Deprecated: Function mysql_list_tables() is deprecated in /home/vote.php on line 38 [/CODE] Thanks in advance Auto
  24. It is really simple actually, You can make music, art, applications (in java) and put them up as your own in the library, either paid or free. Everyone can add the things to their account and those things will be available ANYWHERE on EVERY computer (with internet). There are no limits on the java programs, pictures, music. You're totally free and using it costs no money :D Check it out! [url]http://codiction.com/ads[/url]
  25. I need a better vote website thing for my vote4auth, you can sit there refreshing and getting new auths, if anyone can fix this ill pay.
×