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

  • General Section
    • Announcements & News
    • Introduce Yourself
    • General Discussion
    • Recreational Activities
    • Entertainment
    • Private VIP Lounge
    • RPG Gaming Forums
    • Art / Screenshot / PhotoGallery / Signature
    • Suggestion
  • Gaming - Discussion
    • Enemy Territory
    • Call of Duty Series
    • Insurgency Series
    • Day Of Infamy
    • Team Fortress
    • Battlefield Series
    • Counter Strike Series
    • Other Games
    • Console & Mobile Gaming
    • Complaints
  • Help & Discussion Center
    • Tutorials
    • Q&A / Reports / Issues
    • Downloads
    • Software & PC Support
    • Hardware Hangout
    • Reviews by Members for Members
    • Language Learning & Translation
  • ETPRO's Topics
  • ET Trick Jump's Topics
  • Clash of Royal's Topics
  • Clash of Clans's Topics
  • Rocket League's Topics
  • Cards Against Humanity's Topics
  • Eastside Hockey Manager's Topics
  • Trading's Topics
  • Board Games's Topics

Calendars

  • Community Calendar
  • Gaming Events
  • ETPRO's Events
  • ET Trick Jump's Events
  • Trading's Events

Product Groups

  • Donation Packages
  • VIP Membership
  • Private Slot
  • ETPRO Events

Blogs

There are no results to display.

There are no results to display.

Categories

  • Fearless Assassins Software
  • Enemy Territory
    • Software
    • Maps
    • Map Scripts
    • Mods
    • Soundpacks
    • Skinpacks
    • LUA
    • Player Configs
    • Waypoints
    • Punkbuster
  • Call of Duty 4
    • Software
    • Mods
    • Maps
    • Player Configs
  • Other Games
    • Insurgency
    • Minecraft
    • Team Fortress 2
    • Counter Strike Series
  • Windows Software
  • Sounds

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Youtube


Steam


Xbox Live


PSN ID


Discord


Battlelog


Website URL


Skype


Occupation


Alias


Admin


Interests


SL


TB


Location


Steam ID


steamID64


T-M

Found 5 results

  1. Hello everyone, mySQL is driving me mad for several days yet. I thought twice, trice, googled, googled and googled as hell and would not ask if I wouldn't be f*kd up like now... The starting situation is that I wanted to write a little blog system with PHP and SQL. Software-Info: * Windows 8.1 Professional Edition * Apache/2.4.23 (Win32); OpenSSL/1.0.2h; PHP Version 7.0.9; PHP-Extension: mysqli * phpMyAdmin 4.5.1; 10.1.16-MariaDB; DB-Client Version: libmysql - mysqlnd 5.0.12-dev - 20150407 - $Id: 241ae00989d1995ffcbbf63d579943635faf9972 $ To create an entry and connecting with the file system with a smooth handling I need two columns (id and order) that are "unique". In this system it's not possible to make two columns unique. So there must a way to make both columns unique "virtually". -------------------------------------------------------------------------------------- | id* | headline | word | unlocked | order* | timestamp | -------------------------------------------------------------------------------------- | 20180826235958 | Hello | How are you? | 0 | 1 | 2018-08-26 23:59:58 | | 20180826235959 | Hi | I'm fine | 0 | 2 | 2018-08-26 23:59:59 | id: int(255); datetime as only number - *must be unique as id headline: text word: text unlocked: tinyint(1); boolean to make in-/visible order: int(255); *must be unique, too; to reorder the entries without touching the id The main problem is to make the INSERT command proof for no double entries. In fact the id is not auto_increment but unique - it takes the datetime to be unique. This is important to the id-validation being 14 chars long. Anyway so you can do something like this: INSERT INTO `_myTable` (`id` ,`headline`,`word`, `unlocked`, `order`, `timestamp`) VALUES ('20180826235958' ,'','', 0, 1, '2018-08-26 23:59:58') But what is, when you *click*, *click*, *click* in one second? You can wait for returning false, when duplicate key(id) is fired and then re-ask again to: INSERT INTO `_myTable` (`id` ,`headline`,`word`, `unlocked`, `order`, `timestamp`) VALUES (LAST_INSERT_ID(id)+1 ,'','', 0, 1, '2018-08-26 23:59:58') This solution is a little ugly (because you can get an id like 20180826235960) but this seems be working. -------------------------------------------------------------------------------------------------------------------------------- The minor problem is to count up the `order` field. I tried sth: INSERT INTO `_myTable` (`id` ,`headline`,`word`, `unlocked`, `order`, `timestamp`) VALUES ('20180826' ,'','', 0, myorder, '2018-08-26 16:37:02') SELECT `id` AS tmpID, IFNULL(MAX(`order`), 0) + 1 AS myorder FROM `_myTable`; SELECT LAST_INSERT_ID(); Result: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT `id` AS tmpID, IFNULL(MAX(`order`), 0) + 1 AS myorder FROM `_myTable' at line 5 By researching I found some interesting things but nothing of this worked EVEN they have rated up posts: https://stackoverflow.com/questions/5360117/insert-and-set-value-with-max1-problems 1. -------------------------------------------------------------------------------------------------------------------------------- The best way is to use a transaction but if your not using innodb tables then next best is locking the tables and then performing your queries. So: Lock tables customers write; $max = SELECT MAX( customer_id ) FROM customers; Grab the max id and then perform the insert INSERT INTO customers( customer_id, firstname, surname ) VALUES ($max+1 , 'jim', 'sock') unlock tables; -------------------------------------------------------------------------------------------------------------------------------- This is this one most interesting but I don't know if i cant trust locking tables: 1. if I lock tables then writing PHP-Code to calculate some out then continuing but the request crashes - what's up with the locked table when it's not unlocked? 2. if the table is locked with "write" what will be if another request on the table appears being blocked? Would the other request wait until the lock is released OR will it cancel the request? 2. -------------------------------------------------------------------------------------------------------------------------------- INSERT INTO customers( customer_id, firstname, surname ) SELECT MAX( customer_id ) + 1, 'jim', 'sock' FROM customers; -------------------------------------------------------------------------------------------------------------------------------- This is the way i tryed out above and does not work. 3. -------------------------------------------------------------------------------------------------------------------------------- INSERT INTO customers ( customer_id, firstname, surname ) VALUES ((SELECT MAX( customer_id )+1 FROM customers cust), 'sharath', 'rock') -------------------------------------------------------------------------------------------------------------------------------- This one does not work anyway - see screenshot. Cannot imagine that post getting 9 points up without working on syntax. Either I do sth. wrong here or nobody tests the code before rating up. What do yu think is the best practice to write transaction proof table entries like this? my test-source: $multiSQL = " INSERT INTO `".secure_sql($tbl)."` (".$field_str.") VALUES (".$value_str.") SELECT MAX(`order`)+1 AS iORDER FROM `".secure_sql($tbl)."`; SELECT LAST_INSERT_ID(); "; $insert = mysqli_multi_query($token['connection'],$multiSQL); if($insert){ echo 1 . '<br />'; print_r(mysqli_fetch_assoc($insert)); }else{ echo $multiSQL; $multiSQL = " INSERT INTO `".secure_sql($tbl)."` (".$field_str.") VALUES (LAST_INSERT_ID(id)+1 , ".$value_strD.") SELECT MAX(`order`)+1 AS iORDER FROM `".secure_sql($tbl)."`; SELECT LAST_INSERT_ID(); "; $insert = mysqli_multi_query($token['connection'],$multiSQL); if($insert){ echo 2 . '<br />'; print_r(mysqli_fetch_assoc($insert)); }else{ echo $multiSQL; } }
  2. Working on adding another website to my Direct Image code.
  3. Firstly, a little introduction to these tutorials. I am currently working on a clients website, and when I want to take a break, I've decided I will be posting about techniques I've used to cater for different needs, which people may find interesting. Today, I'll be showing you how you can easily protect your downloadable media. Why would you want to do this? Well, often we want to hide the location of the downloads, to stop people leeching your content. And most measures can be easily swerved. Here is a method I quite like. I have annotated everything for your convenience. Filename: download.php <?php $filename = "downloaded.zip"; // this is the fake name you want the downloaded file to be called. $source = "/downloads/thefile.zip"; // this is the real name and location of the file. if(file_exists($source)) { // check that the real file exists, if so do the following.. header('Content-type: application/zip'); // set the content type of the current page to the type of file being downloaded header('Content-Disposition: attachment; filename="'.$filename.'"'); // Forge the download name by setting filename= readfile($source); // grab the real file to prompt download. } else { // if the file doesn't exist echo "Error: File not found!"; // display error message } ?> So how do we use this? going to the destination: mysite.com/download.php would grab the file 'thefile.zip' from the /downloads/ folder, and prompt you to download it, but with a new name of 'downloaded.zip' This is the simplest version of this method. Obviously with use of $_GET requests you can have download.php choose varying files from the /downloads/ folder. Example below: Filename: download.php <?php $id = $_GET['file']; $filename = "downloaded-".$id.".zip"; // will forge the name downloaded-5.zip (if download.php?file=5 is requested) $source = "/downloads/thefile-".$id.".zip"; // will pick the real file titled thefile-5.zip (if download.php?file=5 is requested) if(file_exists($source)) { // check that the real file exists, if so do the following.. header('Content-type: application/zip'); // set the content type of the current page to the type of file being downloaded header('Content-Disposition: attachment; filename="'.$filename.'"'); // Forge the download name by setting filename= readfile($source); // grab the real file to prompt download. } else { // if the file doesn't exist echo "Error: File not found!"; // display error message } ?> It gets even more advanced once you start playing with more and more security. When dealing with premium ($$$) content, it's good to use a database and give all your files a masked name, by MD5 encoding the names, storing them in a database with an assigned ID, and having download.php retreive the filename from the database to know which file to retreive. But that'd look a little messy for this tutorial I hope you learned something by reading this.. Thanks for reading! Chuckun
  4. Structure of PHP We have learned how we can parse some text to browser so far, the easiest thing in PHP. But wait, everything is easy, you only have to know how! PHP uses a if … else structure, similar like flash and Java. <?php if(1+2==3) { echo ‘Correct!’; } else { echo ‘Incorrect’; } ?>The example above shows a little math sum. I will explain every line.Line 1: We give the server the message that he is dealing with PHP code Line 2: We ask the question, if 1 + 2 = 3 execute the code surrounded by the first { }. Line 3: The code executed when the sum is correct. Line 4: End of the first block of code and then start a new one, a one which will be executed if the sum would be false. Line 5: The code executed when the sum is incorrect. Line 6: End of the second block of code. Line 7: End of the PHP code. In this example the browser always shows the text ”Correct!”, however, when we change the 3 into a 4, the browser will always give “Incorrect”.  Variables In PHP you also have variables, thiny pieces of memory where you can store information or execute functions. These variables are indicated with the prefix $ (dollar sign). For example: <?php $name = ‘mattle’; ?>Bear in mind that text always need to stand between quotes. This script won’t do anything. So variables won’t be echoed by standard. But I can: <?php $name = ‘mattle’; echo $name; ?>Because we want to echo a variable we don’t need to place it between quotes. The variable itself is not a string. But what if I want to add some more text, like “Welcome, Mattias, enjoy your stay!”We could do it like this: <?php $name = ‘mattle’; echo ‘Welcome ’; echo $name; echo ‘, enjoy your stay!’; ?>That’s long. PHP knows some tricks to make from these 3 echo’s one echo. <?php $name = ‘mattle’; Echo ‘Welcome ’. $name . ‘, enjoy your stay!’; ?>What did we do? We've put two strings around the variable with on both sides 2 dots. In other words, we putted the variable out of the text. But you don’t have to close the echo with quotes. We simply can do this: <?php $name = ‘mattle’; echo ‘Welcome ’. $name; ?>Or this: <?php $name = ‘mattle’; echo $name . ‘, hi!’; ?>Thanks again for reading the second part of the multipart tutorial “First steps into PHP”.If you have comments, suggestions, don’t be shy and send me those. Happy trying
  5. First steps into PHP What is PHP? PHP stands for Hypertext Preprocessor and is executed by a webserver instead of the browser, the program where are watching this page in. This means that the server executes all the pages who are containing actions, server-side and then passes the results to your browser. You think, well whats the advantage of that? Well by this way you can make the page dynamic. With a normal file the whole file is send to the browser and the browser executes it. The result will be always the same because the file on the server won’t be edited at all without changes from the webmaster. When you use PHP you can execute the scripts on the server and get information from databases which you add to the pages when you run. By keeping this in your mind, you can imagine that you could create complex dynamic webpages like this forum which is also build on PHP. What do I need? In this tutorial I assume you have some basic skills like using FTP and creating HTML pages. If you don’t understand these things I would recommend stop reading this tutorial and first get some more experience in those other subjects. Ofcourse you need a webhost who supports PHP. In these days almost all hosts offer this to their clients. If you are not sure, just ask them. You also need a program to create and edit PHP files. There are a bunch of programs for this, we are using however notepad as it is our beginning to PHP. You know now the requirements and what PHP is, let’s get to the exciting part. Creating a PHP file To let the server know that he has to deal with a PHP file, all files are usually ending with the extension .php, for example index.php. In this file again we have to let the server know that a part is PHP code we simple use the following: <?php ?>These tags will contain our PHP code. It’s similar to the <body> tag in PHP. The easiest way to really show some text is to use the echo, like following: <?php Echo ‘Hello world!’; ?>When you run this PHP code in your browser, you will only see the text Hello world and won’t see any PHP code. So, when you want to parse HTML code to the browser, you simply use the echo ‘’;Use always the hooks around your text. Also use after every echo line a ; (dot comma). The server then knows a piece of code is finished. Thanks for reading the first part of the multipart tutorial “First steps into PHP”. If you have comments, suggestions, don’t be shy and send me those. Thanks for reading

About Us

We are glad you decided to stop by our website and servers. At Fearless Assassins Gaming Community (=F|A=) we strive to bring you the best gaming experience possible. With helpful admins, custom maps and good server regulars your gaming experience should be grand! We love to have fun by playing online games especially W:ET, Call of Duty Series, Counter Strike: Series, Minecraft, Insurgency, DOI, TF2 & Battlefield Series and if you like to do same then join us! Here, you can make worldwide friends while enjoying the game. Anyone from any race and country speaking any language can join our Discord and gaming servers. We have clan members from US, Canada, Europe, Sri Lanka, India, Japan, Australia, Brazil, UK, Austria, Poland, Finland and many other countries. It doesn't matter how much good you are in the game or how much good English you speak. We believe in making new friends from all over the world. If you want to have fun and want to make new friends join up our gaming servers and our VoIP servers any day and at any time. .

×

Important Information

By using this site, you agree to our Terms of Use.