-
Posts
227 -
Joined
-
Last visited
Everything posted by MoFish
-
Hi, I'm getting the following response using: $json_object = json_decode($unparsed_json, true); array(1) { ["google.com"]=> array(2) { ["status"]=> string(16) "regthroughothers" ["classkey"]=> string(6) "domcno" } } How do I echo the attribute of the ['status']? I have tried using: echo $json_object->['status']; Thanks, MoFish
-
Still cant figure this out. <?php $result = "<?xml version='1.0' encoding='UTF-8' standalone='no'?> <epp xmlns='urn:ietf:params:xml:ns:epp-1.0' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation=''> <response> <result code='1000'> <msg>Command completed successfully</msg> </result> <resData> <domain:chkData xmlns:domain='urn:ietf:params:xml:ns:domain-1.0' xsi:schemaLocation='urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd'> <domain:cd> <domain:name avail='0'>bob.co.uk</domain:name> </domain:cd> </domain:chkData> </resData> <extension> <domain-nom-ext:chkData abuse-limit='4990' xmlns:domain-nom-ext='' xsi:schemaLocation=''/> </extension> </response> </epp>"; $xml = simplexml_load_string($result); // this gets the domain name echo $xml->response->resData->children('domain', true)->chkData->children('domain', true)->cd->children('domain', true)->name; // now get the avail value? echo $xml->response->resData->children('domain', true)->chkData->children('domain', true)->cd->children('domain', true)->name->name['avail']; ?>
-
Hi, I'm trying to return the value of avail="0" from the following XML file using simplexml_load_string. <response> <result code="1000"> <msg>Command completed successfully</msg> </result> <resData> <domain:chkData xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd"> <domain:cd> <domain:name avail="0">www.testing.co.uk</domain:name> </domain:cd> </domain:chkData> </resData> I have it working where I can access the www.testing.co.uk value using the following: echo $xml->response->resData->children('domain', true)->chkData->children('domain', true)->cd->children('domain', true)->name; But am not sure how to access the avail value? I thought the following would have worked by adding ['avail'] onto the end, but appear to be missing something. echo $xml->response->resData->children('domain', true)->chkData->children('domain', true)->cd->children('domain', true)->name['avail']; Any help much appreciated. MoFish
-
Hi, I'm currently passing an array of values to be updated in my database, but am struggling on the best way to escape the quotation marks around the NOW statement below, as understand this will only work without them. This is what is being passed to the DB which does not currently work. I'm seeking some help to find the best way to remove the "" from around the NOW statement, but retain it in the array structure which i believe needs the '' to understand its a value. UPDATE staff SET staff_last_login="NOW()" WHERE staff_id="1" array('staff_last_login'=>'NOW()') My question is - whats the best way to escape this? I understand forward slashes can sometimes be used, and double quotes - but feel like i have exhausted all my known options. Any help much appreciated. MoFish
-
Notice/Warning Error When Trying To Get Value From XML.
MoFish replied to MoFish's topic in PHP Coding Help
What a numpty I am. Thank you. -
Hi, I'm trying to read the 'code' value "2303" from the following XML. This is currently held in a string called $result. <?xml version="1.0" encoding="UTF-8" standalone="no"?> <epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="x"> <response> <result code="2302"> <msg>Object exists</msg> <extValue> <value> <domain:name xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd"> google.co.uk </domain:name> </value> <reason>V094 Domain name exists already</reason> </extValue> </result> <trID> <clTRID>ABC-1234x5</clTRID> <svTRID>387210698x9</svTRID> </trID> </response> </epp> I have the following, but it is throwing me an error. I cant figure out what I'm doing wrong, as thought i had referenced it correctly. $xml = simplexml_load_file($result); $code = intval($xml->response->result['code']); //line 147 echo $code; Notice: Trying to get property of non-object in class.php on line 147 Warning: simplexml_load_file(): I/O warning : failed to load external entity Any help much appreciated. MoFish
-
Thank you, much appreciated.
-
Hi, I'm not sure if this is in the correct forum - hope so! I've been trying to re-direct all my website traffic to another website url (bbc.co.uk) apart from one particular folder (/install) which should be accessible. Can anyone help me with this? I think i'm close... RewriteEngine on RewriteRule !^install($|/) http://www.bbc.co.uk%{REQUEST_URI} [L,R=301] Thanks, MoFish
-
Hi, @Jazzman - Yes, its using Linux. The folder needs to be writeable via code, but running the deleteDirectory() function should NOT remove the /install folder or file configuration.php. I thought there would of been a simple way to exclude a folder name / file name in the function itself - but am happy to go down the permission route if its better. I'm just not sure what to set it too. @MECU - will chmod 000 allow me to still read/write to the folder?
-
Which permission level stops the deletion?
-
Hi, I'm using the following code to delete all directories in the root of my website which works well... however.. I'm wanting to amend the code so it does not delete a folder called "install" and also does not delete a file called "configuration.php" Could anyone please advise me on how i could exclude a folder and file? Thanks, MoFish function deleteDirectory($dirPath) { if (is_dir($dirPath)) { $objects = scandir($dirPath); foreach ($objects as $object) { if ($object != "." && $object !="..") { if (filetype($dirPath . DIRECTORY_SEPARATOR . $object) == "dir") { deleteDirectory($dirPath . DIRECTORY_SEPARATOR . $object); } else { unlink($dirPath . DIRECTORY_SEPARATOR . $object); } } } reset($objects); rmdir($dirPath); return true; } }
-
Hi, I have tested this and something doesn't seem right... The $secLastFridayThisMonth value is: 03-21-2014 The $lastWeekPrevMonth value is: 03-31-2014 I would have expected for these ranges for the month of March. 24/02/14 - 28/02/14 - Week 8 03/03/14 - 07/02/14 - Week 9 10/03/14 - 14/03/14 - Week 10 17/03/14 - 21/03/14 - Week 11
-
Hi, Thank you for your reply. The second last Friday of the current month logic sounds perfect... In order to get the logic correct I have demonstrated the start/end ranges below. If it was January the range would be.. Monday 6th January (first Monday of the year) to Friday 34th January (second last Friday of current month) - January - 06/01/14 - 10/01/14 - Week 1 13/01/14 - 17/01/14 - Week 2 20/01/14 - 24/01/14 - Week 3 If it was February the range would be.. Monday 27th January (include last week from previous month) to Friday 21st February (second last Friday of current month) - February - 27/01/14 - 31/01/14 - Week 4 03/02/14 - 07/02/14 - Week 5 10/02/14 - 14/02/14 - Week 6 17/02/14 - 21/02/14 - Week 7 If it was March the range would be.. Monday 24th February (include last week from previous month) to Friday 21st March (second last Friday of current month) - March - 24/02/14 - 28/02/14 - Week 8 03/03/14 - 07/02/14 - Week 9 10/03/14 - 14/03/14 - Week 10 17/03/14 - 21/03/14 - Week 11 And so on .. - April - 24/03/14 - 28/03/14 - Week 12 31/03/14 - 04/04/14 - Week 13 07/04/14 - 11/04/14 - Week 14 14/04/14 - 18/04/14 - Week 15 - May - 21/04/14 - 25/04/14 - Week 16 28/04/14 - 02/05/14 - Week 17 05/05/14 - 09/05/14 - Week 18 12/05/14 - 16/05/14 - Week 19 19/05/14 - 23/05/14 - Week 20 - June - 26/05/14 - 31/05/14 - Week 21 02/06/14 - 07/06/14 - Week 22 09/06/14 - 13/06/14 - Week 23 16/06/14 - 20/06/14 - Week 24 - July - 23/06/14 - 27/06/14 - Week 25 30/06/14 - 04/07/14 - Week 26 07/07/14 - 11/07/14 - Week 27 14/07/14 - 18/07/14 - Week 28 - August - 21/07/14 - 25/07/14 - Week 29 28/07/14 - 01/08/14 - Week 30 04/08/14 - 08/08/14 - Week 31 11/08/14 - 15/08/14 - Week 32 18/08/14 - 22/08/14 - Week 33 - September - 25/08/14 - 29/08/14 - Week 34 01/09/14 - 05/09/14 - Week 35 08/09/14 - 12/09/14 - Week 36 15/09/14 - 19/09/14 - Week 37 - October - 22/09/14 - 26/09/14 - Week 38 29/09/14 - 03/10/14 - Week 39 06/10/14 - 10/10/14 - Week 40 13/10/14 - 17/10/14 - Week 41 20/10/14 - 24/10/14 - Week 42 - November - 27/10/14 - 31/10/14 - Week 43 03/11/14 - 07/11/14 - Week 44 10/11/14 - 14/11/14 - Week 45 17/11/14 - 21/11/14 - Week 46 - December - 24/11/14 - 28/11/14 - Week 47 01/12/14 - 05/12/14 - Week 48 08/12/14 - 12/12/14 - Week 49 15/12/14 - 19/12/14 - Week 50 I hope this helps clarify - and I really do appreciate your help and guidance.
-
Hi, I have a MySQL query to gather information for a few date ranges. The following query works well for the current month, but things need to change a little, as it is not exactly what I require. SELECT * FROM TABLE WHERE YEAR(date_added) = YEAR(CURDATE()) AND MONTH(date_added) = MONTH(CURDATE()) Here is the scenario... Staff get paid on the last FRIDAY of every month. The commission cut off date is the FRIDAY before the last Friday. The week Staff get paid gets added onto the following months information. I need to somehow be able to select this information via the date_added field.... complex i know! So i think it needs to be something like... SELECT everything from the current year FIND values BETWEEN the PREVIOUS months last week AND SECOND last Friday of the CURRENT MONTH. Can anyone whom knows MYSQL help me figure this one out? Regards, MoFish
-
Hello, I have some ajax code to get the some progress indications from a json file. Everything is working well, however the setInterval never ends. I was hoping that once the $.post success event had been fired that it would of stop the setInterval part by setting varLoading to false. $.post('work.php', function(data){ alert("finished"); varLoading = false; }); if(varLoading) { setInterval(function() { $.getJSON('progress.json', function(data) { progress(data.progress, data.message); }); }, 2000); } I then tried adding it into a function, and calling that based on the status of the varLoading variable being true or false. However this seems to increment alot quicker than 2 seconds and caused by browser to crash. I think this is also going on into 'infinity and beyond' $.post('work.php', function(data){ alert("finished"); varLoading = false; }); if(varLoading){ checkStatus(); } function checkStatus() { if(varLoading) { setInterval(function() { $.getJSON('progress.json', function(data) { progress(data.progress, data.message); }); checkStatus(); }, 2000); } } Could anyone help point me in the right direction? Thanks MoFish
-
Sorry, I mean it actually prints out "url: $('#migrateURL').val() + ' /install/inc/migrate/migrate.process.php?action=extract'," in console. Should the following code work?
-
Hi, I'm trying to pass in a URL into AJAX from a form field. The following displays corrctly (http://www.google.co.uk) from the form field. var urlMigrate = $('#migrateURL').val(); alert (urlMigrate); However when i try to pass it into a line in my ajax code it doesnt write out the value, it writes out the the actual words. Can anyone help find what I done wrong? Below is my code i'm trying $.ajax({ url: $('#migrateURL').val() + ' bob.php', }); And im trying to get url: http://www.google.co.uk/bob.php Thank you. MoFish
-
Hi, I have some code which is pulling back the some database information. I would like the array to be structured slightly differently and wondered if anyone could help me in achieving this. I would like each game to be displayed with its attributes and players of each game to be inside. Something like the below: array ( [game] ( attributes ( [players] ) ) [game] ( attributes ( [players] ) ) } The structure I am currently getting is as follows. I am aware there are some duplicates of data (not sure why) Array ( [0] => Array ( [0] => 1 [id] => 1 [1] => 2014-02-11 [game_date] => 2014-02-11 [2] => 6:00 [game_time] => 6:00 [3] => DISC [game_location] => Japan [4] => As Many As Possible [type_title] => As Many As Possible [5] => Awaiting Players [status_title] => Awaiting Players ) [players] => Array ( [0] => Array ( [0] => 4 [id] => 4 [1] => 10029 [player_fb_id] => 10029 [2] => 2 [game_id] => 2 ) [1] => Array ( [0] => 3 [id] => 3 [1] => 1027 [player_fb_id] => 1027 [2] => 2 [game_id] => 2 ) ) [1] => Array ( [0] => 2 [id] => 2 [1] => 2014-02-18 [game_date] => 2014-02-18 [2] => 6:00 [game_time] => 6:00 [3] => DISC [game_location] => China [4] => 5v5 [type_title] => 5v5 [5] => Awaiting Players [status_title] => Awaiting Players ) ) The code I am using to create the array is as follows: public function get_games () { $db = new sql(); $sql = "SELECT games.`id` , games.`game_date` , games.`game_time` , games.`game_location` , games_types.`type_title`, games_status.`status_title` FROM games JOIN games_types ON games.`game_type_id` = games_types.`id` JOIN games_status ON games.`game_status_id` = games_status.`id` ORDER BY games.id ASC"; $db->query($sql); if($db->num_rows()){ while($k = $db->fetch_array($db)) { $result[] = $k; $pm = new playersManager(); $players=$pm->get_players($k['id']); $result['players'] = $players; } } echo "<pre>"; print_r($result); echo "</pre>"; return $result; }
-
I seem to have it working, but am constantly closing and opening sessions .. surely this can't the the normal way to so it? <?php session_start(); ?> <?php switch($_GET['action']) { case 'start'; $_SESSION['status'] = "Firing first event"; session_write_close(); session_start(); sleep(5); $_SESSION['status'] = "Firing second event"; session_write_close(); session_start(); sleep(5); $_SESSION['status'] = "Firing third event"; session_write_close(); session_start(); sleep(5); $_SESSION['status'] = "Complete"; session_write_close(); session_start(); break; case 'progress': echo "" . $_SESSION['status']; break; } ?>
-
I juggled some stuff around... I have managed to get my shorten my code in size and think I am on the correct lines with the ajax calls, but am still not getting the responses via the php. It just returns "checking every second..." without the value of $alert And completes in console at the end as expected. <script> /* set loading variable */ var varLoading = true; // fire the long process $.post('post.php?action=start', function(data){ // set loading to complete and send success message varLoading = false; console.log ("finished"); }); // call check status checkStatus(); function checkStatus() { // if we are still loading if(varLoading) { // check every second setTimeout(function(){ // get the returned contents of page $.get('post.php?action=progress', function(data){ // put them into the content div $('#content').html(data); // re-check status again checkStatus(); }) }, 1000); } } </script> <?php $alert = ""; switch($_GET['action']) { case 'start'; sleep(5); $alert = "first event"; sleep(5); $alert = "second event"; sleep(5); $alert = "third event"; break; case 'progress': echo "checking every second ..." . $alert; break; } ?>
-
Hi, Thanks, makes sense. I'm still not not 100% sure if I should be making two ajax calls seperately or if there is an easy way to merge it into one ajax call using the different states avaliable. Do I still require the flush? POST.PHP <?php switch($_GET['action']) { case 'start'; // start progress sleep(5); $alert = "First event firing..."; flush(); sleep(5); $alert = "First event firing..."; flush(); sleep(5); $alert = "First event firing..."; flush(); break; case 'progress': // echo during progress echo $alert; break; } ?> FORM.PHP <div id="content"></div> <script> $('#designForm').submit(function(event) { event.preventDefault(); $.ajax({ type: 'POST', url: 'post.php?action=start', data: $(this).serialize(), dataType: 'html', success: function (data) { // the processing is done so can alert user its complete..? } }); setInterval(function() { $.ajax({ type:"POST", url:"post.php?action=progress", datatype:"html", success:function(data) { // echo the current status? $('#content').html(data); } }); }, 10000); // time to check }); </script>
-
Getting Response In Firebug - But Not To Browser?
MoFish replied to MoFish's topic in Javascript Help
That was it - I changed that yesterday thinking it would help. Thank You -
Hi, I have a form posting to a php page which does some echo's. <div class="content"></div> <script> $('#designForm').submit(function(event) { event.preventDefault(); $.ajax({ type: 'POST', url: 'inc/design/design.process.php', data: $(this).serialize(), dataType: 'html', complete: function (data) { $('.content').html(data); } }); }); </script> I'm somehow getting responses in firebugs console, but nothing to in the webpage itself. Could anyone help shine some light onto why the messages would not be getting inserted into the .content div as i would have expected, but appear to be working in console? Thanks, MoFish
-
Oh... that sounds a little more complicated that I had anticipated... Using your proposed technique would require 3 php files? I thought it was going to be a little easyier