Search the Community
Showing results for tags 'php'.
-
Hello, I couldent find anything on google on how to calculate 2 values that are in a array. This is what I'm trying to do. $matches[1] = ($matches[1] * 1000); $matches[2] = ($matches[2] * 1000);
-
Hello, I'm trying to update my tables when it finds a duplicate. Not quite sure how it works. $mysqli->prepare('INSERT INTO status_storage_pools (pname, totalspace, totalused) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE totalspace=VALUES(totalspace), totalused=VALUES(totalused)')) The value that will be duplicate is pname. This query just adds a new one.
-
Hi, I have a VPS server that I am trying to install a symfony project on. The Operating System is CentOS 6.9 (Final) I have Plesk Onyx 17.0.17 installed. The PHP version that I need for the project that I am installing is 7.1.4 but my PHP CLI version is 5.3.3. I have tried to use the # /opt/plesk/php/7.0/bin/php yourscript.php command like suggested from Plesk Forums but it doesn't work with commands such as composer install. Does anyone have the instructions on changing the default PHP Version for cli on my OS Thanks
-
Hello. So I got this json string that can be what ever big. {"profiles":[{"profileId":"9c1b46db-652f-4f4c-8879-0032dae374fe","userId":"9c1b46db-652f-4f4c-8879-0032dae374fe","platformType":"uplay","idOnPlatform":"9C1B46DB-652F-4F4C-8879-0032DAE374FE","nameOnPlatform":"Anfi."},{"profileId":"9c6c974b-3bf9-4424-b718-33787d5ea887","userId":"9c6c974b-3bf9-4424-b718-33787d5ea887","platformType":"uplay","idOnPlatform":"9C6C974B-3BF9-4424-B718-33787D5EA887","nameOnPlatform":"joveice"}]} Formated for easyer reading Object profiles:Array[2] 0:Object idOnPlatform:"9C1B46DB-652F-4F4C-8879-0032DAE374FE" nameOnPlatform:"Anfi." platformType:"uplay" profileId:"9c1b46db-652f-4f4c-8879-0032dae374fe" userId:"9c1b46db-652f-4f4c-8879-0032dae374fe" 1:Object idOnPlatform:"9C6C974B-3BF9-4424-B718-33787D5EA887" nameOnPlatform:"joveice" platformType:"uplay" profileId:"9c6c974b-3bf9-4424-b718-33787d5ea887" userId:"9c6c974b-3bf9-4424-b718-33787d5ea887" How do I get this into a database? so I know how the sql stuff works, but I need this thing "$obj->stuff->stuff->stuff" As I don't know how it will look for this and how to do a foreach or for with calculation
-
Hello! I'm trying to do a curl request. In my browser it says Request Payload, whats this and how do I do that? I'm used to do posts (it's a simple json string)
-
Hello, title says it all. I have 2 tables in the database that are for one "element" so first is just pool names and status on them, the other tables are drives and what pools they belong too. I have made a visual element for how I want it to be, I just don't know how I can display more on one page. So how does one do this?
-
Hello. So I'm trying to get my usernames from my database but this returns nothing. $data = $mysqli->prepare('SELECT username FROM game_profiles WHERE for_game=? AND platform=?'); /* bind parameters for markers */ $service = 'r6s'; $data->bind_param('ss', $service, $platform); $data->bind_result($users); $data->fetch(); /* execute query */ $data->execute(); and I tryed a while $row = $users and echo the names but it dident work. So what did I do wrong? I'm not quite sure this is the correct way to do the query as I'm new to prepered statment in oop php.
-
Hi, so for the last three hours I have been trawlling through youtube videos and forums trying to find out a way of reading a .txt file and storing it as a javascript variable. Initially I was hoping for something similar to pythons .open and .read procedure in javascript. However what I found out was that you have to do that in php then "send it" to the javascript so this is what I've come up with: <!DOCTYPE html> <html> <body> <script> function Number(){ var x = "<?php echo $myfile;?>"; alert(x); } window.addEventListener('load',Number); </script> <?php $rawfile = fopen("obstacles.txt", "r"); // obstacles contains 'I hate php' $myfile = fread($rawfile,filesize("obstacles.txt")); ?> </body> </html> The alert always just contains <?php echo $myfile;?> as text (I hesitate to say string). Would appreciate help with problem. PS. If theres anything about opening directly as an array that would be great.
-
Hello, I'm trying to add a birthday form to my register page and I want to do it in 3 parts (etc like facebook) So 1 select form for days, months and years. How do I get the data and store it as a normal date in the database?
-
So I'm working on a website and am trying to do something like a small CMS. I have set up an html form, which, when submitted, directs to another site with the following php: <?php $content = $_GET['content']; $newArticle = "//String to replace another string in another php-file"; $str = implode("", file("other-site.php")); $fp = fopen("other-site.php", "w"); $str = str_replace("<!--Comment to be replaced-->", $newArticle, $str); fwrite($fp, $str, strlen($str)); ?> other-site.php is in the same folder as this file. I want to replace a comment on other-site.php with $newArticle but, well, it doesn't do anything^^. Any help? (new to php)
-
Hello, I need to echo this out and I need them to say etc : Elver 6,500,000 28-03-2017 21:05:00 How do I do this? [0] => Array ( [0] => Elver wired 6,500,000 Dollar. 28-03-2017 21:05:00 [1] => Elver wired 6,500,000 Dollar. 28-03-2017 21:05:00 [2] => Elver wired 6,500,000 Dollar. 28-03-2017 21:05:00 ) [1] => Array ( [0] => Elver [1] => Elver [2] => Elver ) [2] => Array ( [0] => 6,500,000 [1] => 6,500,000 [2] => 6,500,000 ) [3] => Array ( [0] => 28-03-2017 21:05:00 [1] => 28-03-2017 21:05:00 [2] => 28-03-2017 21:05:00 )
-
Hi, I'm following that Rest api tut from phalcon. So I'm trying to get the POST data from the request. but it's empty. $postdata = $app->request->getJsonRawBody(); And if I do var_dump($postdata); It's always emtpy $app->post( "/api/test/account", function () use ($app) { thats the start, and the errors I get are only saying that $postdata->user is empty. How do I fix this? I'm soon going away from Phalcon since I do not understand anything and most of the tutorials are waaay above my learning level as they do not really explain much.
-
Hello. Trying to look for a scraper / script that is easy to understand and use. Currently I have looked at: http://simplehtmldom.sourceforge.net/ http://www.oooff.com/php-scripts/basic-php-scrape-tutorial/basic-php-scraping.php https://gist.github.com/anchetaWern/6150297 And right now I use $start_description1 = '<a href="secretlinko">'; $end_description1 = '</a>'; $description1_start_pos = strpos($link, $start_description1) + strlen($start_description1); $description1_end_pos = strpos($link, $end_description1) - $description1_start_pos; $description1 = substr($link, $description1_start_pos, $description1_end_pos); And it works, but it tend to break due to html code So could anyone explain quick how to use one of the ones I found or some better, because I'm having issues understanding the simple ones since they jump right into parts they think I would know.
-
Hello, I'm trying to match this line. ZMan will change, 6,500,000 will change and the date. <td style="height: 30px; text-align: left;"><b>ZMan</b> wired <b>6,500,000</b> Dollar.</td> <td>28-03-2017 21:10:00</td> This is what I use now and it doesent work. <b>(.*?)<\/b> wired <b>((\d*|\,*)*)<\/b> Dollar.<\/td><td>(\d{2}-\d{2}-\d{4} \d{2}:\d{2}:\d{2})<\/td><\/tr> So how can I detect the newline?
-
<?php include_once "removed.php"; $user = $conn -> real_escape_string($_SESSION['username']); $query = "SELECT * FROM REMOVED WHERE removed ='$user' AND removed='1'"; $result = $conn -> query($query); if(!$result){ die($conn -> error); } else { $row = $result -> num_rows; for ($i = 0; $i < $row; ++$i) { $result -> data_seek($i); $row = $result -> fetch_array(MYSQLI_ASSOC); ?> <h4><?= $row['Group_name'];?></h4> <?php } } mysqli_close($conn); ?> So this code that I have written has given me one issue it successfully creates the <h4> element with the $row data. However, it also creates an empty <h4> element as well. I only have one entry in the database for test purposes.
-
Good morning, afternoon, or evening, I have been teaching myself PHP for the last few years and have also delved into various other programming languages. Over the years I have seen a lot of people give PHP flack for various reasons. So I decided a few days ago to look into other languages that I can use to build backends and other services. I have considered Node and other JS frameworks but I also have heard about Python and specifically Django. I have used Python in the past for writing up quick scripts for little things because I thought that was what Python was best at, however, I realize now looking at Python again that it is actually a very strong language. Have any of you worked with Django and what are you thoughts on it? Alternatively, what other web languages have you looked at besides PHP and Django and what did you like or dislike about them? Thanks everyone for the input!
-
Okay so I am creating a video streaming website and I need the videos to have different resolutions. Now this would not be a problem if I didn't care about security/DRM and whatnot, however I am using Wowza on a Windows server (I know... but it is much easier to manage) and I also have a Ubuntu server running NGINX and PHP. I want to be able to upload videos through my Ubuntu web server (I don't care if I have to switch languages), transcode it through something like FFmpeg and then somehow get it to my Windows server. I do not want to use Wowza's transcoding because it slows the server down by a lot and I want a actual file in the format of VIDEOID_1080.mp4 or something.
-
does anyone know how to add texts to images through coding? it could be php, java, etc. im a noob in training something like this website http://www.online-image-editor.com/
-
I am creating a web interface for a programs web api. Basically, when you go to certain urls, it will cause certain things to happen within the program. One feature is to go to localhost:35747/currentsong and the webpage will show: <html class="gr__localhost"><head><link rel="alternate stylesheet" type="text/css" href="resource://gre-resources/plaintext.css" title="Wrap Long Lines"></head><body data-gr-c-s-loaded="true"><pre>{"Played":true,"Album":"This Town (Single)","Artist":"Niall Horan","AudioUrl":"http://mediaserver-sv5-rt-1-v4v6.pandora.com/access/5432348434435674266.mp4?version=5\u0026lid=1043894297\u0026token=HYP%2BTNubLzUPabITlCUwnDhIBiumWp88GR69hgfKEppuKTdi2DfbGtfRLai60zFqmWuxVnl%2FTKphteoCZ2YfPU6yO0jSFY%2F8SUwaPMWI1VDepyELxjOzceRHhj0WEbG3YDcNkcrQqa3wFuK%2Brrk4yix3gmYYF8MPLN2f62bYA2p%2FscYyA9dVf2jEGC3OC5fxRFRNzRXv9gcTUV%2BCXal8cJoBG3o2pyA4vTaqnn2n6z7Htt4XwPxBfPXNcHEbq3aFUomtMobL2vhhiOCHKL%2FbL6SFTqBZizoGX3fKOj9JQFtk4xlGyrZWJurXRWo8RLFVB3u8XxHWS2n6CLgYk6chZ9YwIRfelNpm0lPLbuSKT3eyXnjhIr4u66rG%2BJO8WrZMssdj%2FSJx%2BbmOjS3aYj68zyWLApyvTOJmD8QR2BS%2FpUsxABL5ohTe0T8UwSPGXaRveFLtXOFzjTMia0qumpV4QXtZzVrAbKBBYsgcmlySpu%2FoHOkH%2BvE6iCUkeuSfl79UgI9nomHkRfMcyMg9JgBJ4Mqc43jJGMN3eTMGECsXlS0oxhgP426Qtw%3D%3D","FileGain":-5.26,"Rating":2,"Loved":false,"Banned":false,"RatingString":"none","StationID":"2942869338374836249","TrackToken":"P5fbtkfFjlW9vrl8YUmd-G5rmpYHZEXMkjoo3nYr6CzWJvfB-wp244FYoYhcWtu5IyMLMxDrfQ8DFPfyAFcDu4Q","SongTitle":"This Town","SongDetailUrl":"http://www.pandora.com/niall-horan/this-town-single/this-town?dc=232\u0026ad=1:28:1:03811::0:0:0:0:506:247:NH:33015:0:0:0:0:0:1","ArtistDetailUrl":"http://www.pandora.com/niall-horan?dc=232\u0026ad=1:28:1:03811::0:0:0:0:506:247:NH:33015:0:0:0:0:0:1","AlbumDetailUrl":"http://www.pandora.com/niall-horan/this-town-single?dc=232\u0026ad=1:28:1:03811::0:0:0:0:506:247:NH:33015:0:0:0:0:0:1","AlbumArtUrl":"http://mediaserver-cont-sv5-3-v4v6.pandora.com/images/public/int/7/2/4/2/00602557202427_500W_500H.jpg","AmazonAlbumID":"B01M0X2A3D","AmazonTrackID":"B01LYB7M23","Tired":false,"StartTime":"\/Date(-62135578800000)\/","Finished":false,"PlaylistTime":1478107302,"Station":{"ID":"2942869338374836249","IdToken":"2942869338374836249","IsCreator":true,"IsQuickMix":false,"Name":"Nuzzle 2?","UseQuickMix":true,"ArtUrl":null,"InfoUrl":"https://www.pandora.com/login?target=%2Fstations%2F88381d024083c8417d0439a5c5229e9576c0cf7739194ea6","ThumbsUp":0,"ThumbsDown":0,"ArtCacheFile":"C:\\Users\\nuzzl\\AppData\\Roaming\\Elpis\\Cache\\Station_2942869338374836249","SkipLimitReached":false,"SkipLimitTime":"\/Date(-62135578800000)\/"},"IsStillValid":true}</pre></body></html> Anway, THis is the part that matters: <pre>{"Played":true,"Album":"This Town (Single)","Artist":"Niall Horan","AudioUrl":"http://mediaserver-sv5-rt-1-v4v6.pandora.com/access/5432348434435674266.mp4?version=5\u0026lid=1043894297\u0026token=HYP%2BTNubLzUPabITlCUwnDhIBiumWp88GR69hgfKEppuKTdi2DfbGtfRLai60zFqmWuxVnl%2FTKphteoCZ2YfPU6yO0jSFY%2F8SUwaPMWI1VDepyELxjOzceRHhj0WEbG3YDcNkcrQqa3wFuK%2Brrk4yix3gmYYF8MPLN2f62bYA2p%2FscYyA9dVf2jEGC3OC5fxRFRNzRXv9gcTUV%2BCXal8cJoBG3o2pyA4vTaqnn2n6z7Htt4XwPxBfPXNcHEbq3aFUomtMobL2vhhiOCHKL%2FbL6SFTqBZizoGX3fKOj9JQFtk4xlGyrZWJurXRWo8RLFVB3u8XxHWS2n6CLgYk6chZ9YwIRfelNpm0lPLbuSKT3eyXnjhIr4u66rG%2BJO8WrZMssdj%2FSJx%2BbmOjS3aYj68zyWLApyvTOJmD8QR2BS%2FpUsxABL5ohTe0T8UwSPGXaRveFLtXOFzjTMia0qumpV4QXtZzVrAbKBBYsgcmlySpu%2FoHOkH%2BvE6iCUkeuSfl79UgI9nomHkRfMcyMg9JgBJ4Mqc43jJGMN3eTMGECsXlS0oxhgP426Qtw%3D%3D","FileGain":-5.26,"Rating":2,"Loved":false,"Banned":false,"RatingString":"none","StationID":"2942869338374836249","TrackToken":"P5fbtkfFjlW9vrl8YUmd-G5rmpYHZEXMkjoo3nYr6CzWJvfB-wp244FYoYhcWtu5IyMLMxDrfQ8DFPfyAFcDu4Q","SongTitle":"This Town","SongDetailUrl":"http://www.pandora.com/niall-horan/this-town-single/this-town?dc=232\u0026ad=1:28:1:03811::0:0:0:0:506:247:NH:33015:0:0:0:0:0:1","ArtistDetailUrl":"http://www.pandora.com/niall-horan?dc=232\u0026ad=1:28:1:03811::0:0:0:0:506:247:NH:33015:0:0:0:0:0:1","AlbumDetailUrl":"http://www.pandora.com/niall-horan/this-town-single?dc=232\u0026ad=1:28:1:03811::0:0:0:0:506:247:NH:33015:0:0:0:0:0:1","AlbumArtUrl":"http://mediaserver-cont-sv5-3-v4v6.pandora.com/images/public/int/7/2/4/2/00602557202427_500W_500H.jpg","AmazonAlbumID":"B01M0X2A3D","AmazonTrackID":"B01LYB7M23","Tired":false,"StartTime":"\/Date(-62135578800000)\/","Finished":false,"PlaylistTime":1478107302,"Station":{"ID":"2942869338374836249","IdToken":"2942869338374836249","IsCreator":true,"IsQuickMix":false,"Name":"Nuzzle 2?","UseQuickMix":true,"ArtUrl":null,"InfoUrl":"https://www.pandora.com/login?target=%2Fstations%2F88381d024083c8417d0439a5c5229e9576c0cf7739194ea6","ThumbsUp":0,"ThumbsDown":0,"ArtCacheFile":"C:\\Users\\nuzzl\\AppData\\Roaming\\Elpis\\Cache\\Station_2942869338374836249","SkipLimitReached":false,"SkipLimitTime":"\/Date(-62135578800000)\/"},"IsStillValid":true}</pre> I want my webpage (Hosten on localhost:80) to be able to take the information above, and but it accordingly into titled sections, for example, in the above, it says "Loved":false. I wan't the html to say "False". And the same for everything else, the song tame, artist, ablum image, ect. If your wondering, this program is called ELPIS, a custom pandora client.
-
So this site http://www.3dkingdoms.com/chess/elo.htm has this elo change calculator which is this function CalculateRatingChange() { var Elo1 = document.rating.elo1.value * 1; var Elo2 = document.rating.elo2.value * 1; var K = document.rating.K.value * 1; var EloDifference = Elo2 - Elo1; var percentage = 1 / ( 1 + Math.pow( 10, EloDifference / 400 ) ); var win = Math.round( K * ( 1 - percentage ) ); var draw = Math.round( K * ( .5 - percentage ) ); if (win > 0 ) win = "+" + win; if (draw > 0 ) draw = "+" + draw; document.ratingchange.win.value = win; document.ratingchange.draw.value = draw; document.ratingchange.loss.value = Math.round( K * ( 0 - percentage ) ); document.ratingchange.percent.value = Math.round( percentage * 100 ) + "%"; } How can I create this in php? I don't need the form part of it, just the calulation part since it's gonna be used on the backend anyways, so just a simple php way to make this work where there is $elo1 $elo2 and $k
-
Okey so I have a search function (basic one) and I would like to be able to check of diffrent stuff etc their role, if they are premium, and search by name, all at the same time. so if I search for "test" it will select test, if I select role test it will find test and test2 since they are both in that role. All of the how to "select" and those functions I already know how, I just don't know how the mysql select query string should look like to be able to do this. the way the search function works is that it just creates a url parameter which the "search page" uses etc ?q=jove will find the user jove, and I would like a simple way of doing it this way (if there isent a better way ofc). Please let me know if I wasent clear enough, my english and explanation isent the best search is by name, the drop down has values it will search for and checkbox will see if it's true or false search looks in column uid, Dropdown in role, and checkbox in premium for a o or a 1. and I want this to be sent in a url parameter and then piced up and used where I have the other end.
-
Hi I want to remember my users by using the cookies (so they don't get logged out). I want it to expire after 7 days, and it will renew when they visit inside that time. how should I do this? the way I tought of it first I already see the security flaws of. etc keeping the user id in the cookie. edit the cookie and boom you can loggin as who ever you want. How is this done to keep it safe? I have never worked with cookies.
-
I need to create a JSON string from my database request do this code returns this : [{"id":"1","weight":"0"}][{"id":"2","weight":"7"}][{"id":"3","weight":"1.5"}] I need it to return [{"id":"1","weight":"0"},{"id":"2","weight":"7"},{"id":"3","weight":"1.5"}] (the commas instead of ][) How can I do this? <?php require 'dbConnect.script.php'; $query="SELECT * FROM `trash`"; if($is_query_run=mysql_query($query)){ while($query_execute=$query_execute=mysql_fetch_assoc($is_query_run)){ $rows = array(); $rows[] = $query_execute; print json_encode($rows); } } else{ echo "query notexecuted"; } ?>
-
So I'm trying to hash passwords since I know if it's decryptable its not really safe since if I can decrypt it they can too. This code is grabbed from php documentation. tho I don't find how this will work when i need to compare the password later on, if the hash is diffrent each time how does it know that the passwords are correct? //This returns Invalid password. <?php /** * Note that the salt here is randomly generated. * Never use a static salt or one that is not randomly generated. * * For the VAST majority of use-cases, let password_hash generate the salt randomly for you */ $options = [ 'cost' => 11, 'salt' => mcrypt_create_iv(22, MCRYPT_DEV_URANDOM), ]; $pswhash = password_hash("rasmuslerdorf", PASSWORD_BCRYPT, $options)."\n"; echo $pswhash; if (password_verify('rasmuslerdorf', $pswhash)) { echo 'Password is valid!'; } else { echo 'Invalid password.'; } ?> // This returns Password is valid! <?php /** * Note that the salt here is randomly generated. * Never use a static salt or one that is not randomly generated. * * For the VAST majority of use-cases, let password_hash generate the salt randomly for you */ $options = [ 'cost' => 11, 'salt' => mcrypt_create_iv(22, MCRYPT_DEV_URANDOM), ]; echo password_hash("rasmuslerdorf", PASSWORD_BCRYPT, $options)."\n"; if (password_verify('rasmuslerdorf', password_hash("rasmuslerdorf", PASSWORD_BCRYPT, $options))) { echo 'Password is valid!'; } else { echo 'Invalid password.'; } ?>
-
So I want to be able to store etc 1, 2, 3, 4 in the same column and then in php get it out like this $nr1 = mysql stuff // echo $nr1 will return "1" $nr2 = mysql stuff // echo $nr1 will return "2" $nr3 = mysql stuff // echo $nr1 will return "3" $nr4 = mysql stuff // echo $nr1 will return "4" how can this be done? I just need the basic way to do, the rest I'll do myself