-
Posts
9,409 -
Joined
-
Last visited
-
Days Won
1
Everything posted by MadTechie
-
Logic seam fine here <?php $player = new test(); $_GET['id'] = 5; if (($player->city_id == 1 || $player->id == 2) && ($_GET['id'] != 1)){ echo "NOT EQUAL"; } class test{ public $id = 2; public $city_id = 100; }
-
I'm sorry but i am not sure of the actual question.. My last post gives an example of converting hour and minutes to PHP time and then to SQL time then back to hour and minutes
-
showing the code kinda helps a little!
-
The logic states that your get NOT EQUAL message (not sure if your expecting that) as ($player->city_id == 1 || $player->id == 2) $player->id = 2 AND ($_GET['id'] != 1) $_GET['id'] = 5 (not 1)
-
Yes, also you are aware that the join page is on a different domain
-
Your need to send your email as HTML,
-
Erm WTF!.. AlexWD is never rude however I have noticed a rudeness in your posts, but its normally by the thread creator! Would you like to post out a post!
-
First setup a field as a TIME field now PHP time to mysql <?php date_default_timezone_set('Etc/GMT'); $hour = 22; $minute = 33; $phptime = mktime($hour, $minute, 0); //create time $mysqltime = date("H:i:s", $phptime); //format as MySql //use $mysqltime to insert into database //lets assume $mysqltime has been pulled from the database $time = strtotime($mysqltime); //convert to unix $hour = date("H",$time); //get Hour $minute = date("i",$time); //Get Minues Hope that scared helped you
-
if your pulling from a date & timestamp then your probably have to update the code like so date_default_timezone_set('Etc/GMT'); //I'm in the UK but change to yours $time = strtotime($result_meeting['time']); $hour = date("H",$time); $minute = date("i",$time);
-
Okay it would seam that not all of the data the field time in the database has a colon (, a simple fix is in my last post
-
read file into array sort, then get the first 50 chunk and write them to a file reverse the sort and get the first 50 chunk and write them to a file
-
Basically $times doesn't have a second item in the array, so $minute can't be set, the code you posted will work but your get the error if $time was "20" So can you post the code where you set $time EDIT: oh a quick fix would be, to check it first then set a default of 00 ie $hour = (isset($times[0]))?$times[0]:"00";//line 53 $minute = (isset($times[1]))?$times[1]:"00";//line 54
-
in print.php your see a line like this imagejpeg($im); add this line above it (note you may need to change $im to whatever the variable name is if(!empty($_GET['file'])) imagejpeg($im, dirname(__FILE__)."/tmp/".basename($_GET['file']).".jpeg"); Now in the pie_charts folder create a folder called tmp and give it write privileges. now this <img src="includes/pie_charts/print.php?data=15*35*25*25&label=eggs*carrots*Milk*Bread&file=test" /> will display the image as normal but will also create test.jpg in the tmp folder, without seeing the code that about the best i can think of.
-
Views Counter only add this once each time not refresh.
MadTechie replied to Gayner's topic in PHP Coding Help
The debug, is for "debugging" to allow you force an update, your final code is basically the same as the first code I posted but works per 3 seconds not per session as requested! Pssst your missing a { -
changing the number of times to run foreach
MadTechie replied to Jnerocorp's topic in PHP Coding Help
Can you please click topic solved -
changing the number of times to run foreach
MadTechie replied to Jnerocorp's topic in PHP Coding Help
works fine if the URL was correct http://jnerocorp.com/for.php?url=http://google.com&number=2 -
I needed one to fail hence the code $ping_ex = exec("ping -c4 256.0.0.1", $ping_result, $pr);
-
That's be cause your clearing it out ie look at this and follow the logic $fraction02 = array(); $fraction02[0] = array(); $fraction02[0][1] = "hello"; $fraction02[0] = array(); $fraction02[0][2] = "world"; print_r($fraction02); So in your code $fraction02[$i] = array(); should be in the previous loop (move it up 2 lines) Ahhh @ wildteen88, I knew I shouldn't of typed an example!
-
Sounds like a permissions problem! I remember something about ICMP being a root only command, but I am not 100% sure about that! can you run this, <?php $ping_ex = exec("ping -c4 127.0.0.1", $ping_result, $pr); echo "<BR/>\nOK: $ping_ex - ".implode("<br>\n",$ping_result); $ping_ex = exec("ping -c4 256.0.0.1", $ping_result, $pr); echo "<BR/>\nBAD: $ping_ex - ".implode("<br>\n",$ping_result); $ping_ex = exec("ping -c4 google.com", $ping_result, $pr); echo "<BR/>\nOK: $ping_ex - ".implode("<br>\n",$ping_result); ?> and I'll create a simple script to check the what's valid, and what's not, (as it seams the external route will have less problems)
-
changing the number of times to run foreach
MadTechie replied to Jnerocorp's topic in PHP Coding Help
Should be a simple loop ie for($n=0;$n<$_GET['number'];$n++){ echo $_GET['url']."<BR />/n"; }[/Number ] -
Oh i should say, that if you want to check for the actual icmp then sockets would work better ie replace the ping function with function Ping($host, $timeout){ $port = 0; $datasize = 64; global $g_icmp_error; $g_icmp_error = "No Error"; $ident = array(ord('J'), ord('C')); $seq = array(rand(0, 255), rand(0, 255)); $packet = ''; $packet .= chr(; // type = 8 : request $packet .= chr(0); // code = 0 $packet .= chr(0); // checksum init $packet .= chr(0); // checksum init $packet .= chr($ident[0]); // identifier $packet .= chr($ident[1]); // identifier $packet .= chr($seq[0]); // seq $packet .= chr($seq[1]); // seq for ($i = 0; $i < $datasize; $i++) $packet .= chr(0); $chk = icmpChecksum($packet); $packet[2] = $chk[0]; // checksum init $packet[3] = $chk[1]; // checksum init $sock = socket_create(AF_INET, SOCK_RAW, getprotobyname('icmp')); $time_start = microtime(); if(!@socket_sendto($sock, $packet, strlen($packet), 0, $host, $port)) return -1; $read = array($sock); $write = NULL; $except = NULL; $select = socket_select($read, $write, $except, 0, $timeout * 1000); if ($select === NULL) { $g_icmp_error = "Select Error"; socket_close($sock); return -1; } elseif ($select === 0) { $g_icmp_error = "Timeout"; socket_close($sock); return -1; } $recv = ''; $time_stop = microtime(); socket_recvfrom($sock, $recv, 65535, 0, $host, $port); $recv = unpack('C*', $recv); if ($recv[10] !== 1) // ICMP proto = 1 { $g_icmp_error = "Not ICMP packet"; socket_close($sock); return -1; } if ($recv[21] !== 0) // ICMP response = 0 { $g_icmp_error = "Not ICMP response"; socket_close($sock); return -1; } if ($ident[0] !== $recv[25] || $ident[1] !== $recv[26]) { $g_icmp_error = "Bad identification number"; socket_close($sock); return -1; } if ($seq[0] !== $recv[27] || $seq[1] !== $recv[28]) { $g_icmp_error = "Bad sequence number"; socket_close($sock); return -1; } $ms = ($time_stop - $time_start) * 1000; if ($ms < 0) { $g_icmp_error = "Response too long"; $ms = -1; } socket_close($sock); return $ms; } function icmpChecksum($data) { $bit = unpack('n*', $data); $sum = array_sum($bit); if (strlen($data) % 2) { $temp = unpack('C*', $data[strlen($data) - 1]); $sum += $temp[1]; } $sum = ($sum >> 16) + ($sum & 0xffff); $sum += ($sum >> 16); return pack('n*', ~$sum); } function getLastIcmpError() { global $g_icmp_error; return $g_icmp_error; } and the if with if($X == -1){ EDIT: check php.ini ;extension=php_sockets.dll should be extension=php_sockets.dll
-
Am I missing something but surely this would work! <?php $sxml = new SimpleXMLElement('http://www.zideo.nl/media.php?playzideo=6b3447616f467478&zideo=6c49575a6e6c633d', NULL, TRUE); header("Location: {$sxml->trackList->track->location}"); ?>
-
Okay, this is how I would do it <?php $URLs = array( "Freaks" =>"www.phpfreaks.com", "Google" =>"www.google.com", "Dont exist" => "256.0.0.1", "Me" => "127.0.0.1", ); foreach($URLs as $Name => $URL){ echo $Name; $X = Ping($URL,300); //$X = ext_ping($URL); //untested if($X == 0){ echo ' offline'; }else{ echo ' online'; } echo "<br />\n"; } function ext_ping($URL){ $ping_ex = exec("ping -c4 $URL", $ping_result, $pr); $valid = false; foreach($ping_result as $R){ if(preg_match('/(\d+) packets transmitted, \1/i', $R)) $valid = true; } return $valid; } function Ping($WebServer,$timeout=10,$Port = 80){ Set_Time_Limit(0); //Time for script to run .. not sure how it works with 0 but you need it Ignore_User_Abort(True); //this will force the script running at the end $handle = @fsockopen($WebServer, $Port,$errno,$errstr,$timeout); if (!$handle){ //echo "Failed to open ProxyServer $WebServer errno=$errno,errstr=$errstr<br>"; return 0; } else { $status = socket_get_status($handle); //Time the responce $start= microtime(true); stream_set_timeout($handle,$timeout); //send somthing ini_set('display_errors','0'); $write=fwrite($handle,"echo this\n"); if(!$write){ return 0; } stream_set_blocking($handle,0); //Try to read. the server will most likely respond with a "ICMP Destination Unreachable" and end the read. But that is a responce! fread($handle,1024); fclose($handle); ini_set('display_errors','1'); //Work out if we got a responce and time it $laptime=microtime(true)-$start; if($laptime>$timeout) return 0; return $laptime; } } ?> My results
-
Okay.1 question what is $fraction02[$i] = $i + 1; used for ? as that sets $fraction02[$i] to a number BUT you want to use it as an array! So i assume you wanted this <?php $fraction02 = array(); $multiplier = 10; for($i = 0; $i < $multiplier; $i++){ //$fraction02[$i] = $i + 1; for($j = 0; $j < $multiplier; $j++){ $fraction02[$i][$j] = ($j + 1) * $i; } //echo ($i+1).'<br>'; } //output - whatever foreach($fraction02 as $K1 => $V1){ echo "<H1>$K1</H1>\n"; foreach($V1 as $K2 => $V2){ echo "$K2 => $V2<br>\n"; } } ?>
-
Can you post the code your using, also are the IP's local or external, if external I could try form here