-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
hmm... see that suggests you are using an older version of php that doesn't support anonymous functions.. but it worked for you before, with the hardcoded 'test' element, right? So changing it to $key2 should have worked.. Are you testing this in a different environment?
-
Okay, so if that's the only stuff that will change in the JSON string you are receiving, you can do this: $data='{"success":1,"return":{"test":{"marketid":"32","label":"test\/TEST1","primaryname":"TestItem","primarycode":"ABC","secondaryname":"Tester","secondarycode":"TES","sellorders":[{"price":"0.00002894","quantity":"13.31323200","total":"0.00038528"},{"price":"0.00002895","quantity":"92.80350000","total":"0.00268666"},{"price":"0.00002897","quantity":"392.60350000","total":"0.01137372"},{"price":"0.00002900","quantity":"392.50350000","total":"0.01138260"},{"price":"0.00002902","quantity":"785.40700000","total":"0.02279251"}],"buyorders":[{"price":"0.00002734","quantity":"93.16130210","total":"0.00254703"},{"price":"0.00002733","quantity":"2.00000000","total":"0.00005466"},{"price":"0.00002731","quantity":"2.31057540","total":"0.00006310"},{"price":"0.00002599","quantity":"3.73174150","total":"0.00009699"}]}}}'; $data=json_decode(trim($data),true); $key2 = key($data['return']); usort( $data['return'][$key2]['sellorders'], function($a,$b) { if ($a == $b) return 0; return ($a['price'] < $b['price']) ? -1 : 1; } ); usort( $data['return'][$key2]['buyorders'], function($a,$b) { if ($a == $b) return 0; return ($a['price'] < $b['price']) ? 1 : -1; } ); $lowest_sellorder = $data['return'][$key2]['sellorders'][0]['price']; $highest_buyorder = $data['return'][$key2]['buyorders'][0]['price'];
-
@jazzman1: Sure, that's true, but the point made is that the specific ways ubuntu and debian do differ are relevant to whether or not ubuntu should be used as a server, which is what your caveat was about. It's basically the same principle as like.. picking Windows 8 (current "client" version, for home/personal use) vs. Windows Server 2012 (current "server" version, for using as a server). I mean sure, you can turn Windows 8 into a server. It does in fact have a lot of networking capabilities. After all, most people these days have multiple computers/devices throughout the house, so it makes sense that a certain level of that stuff is built in even to personal computers/devices. But Windows 8 just isn't designed with the same security/optimization as an OS dedicated to doing nothing but be a server. Both Windows 8 and Windows Server 2012 have a lot of the same core. But that doesn't mean both are equally as good for all purposes. Or like.. racing or trying to pick up the chicas with a Ford Pinto vs. a Ford Mustang.. even though they are both made by Ford, clearly one will be more successful in your endeavors than the other. So IOW, is it possible to use ubuntu as a server? Yes. Is it a good idea? No.
-
Perhaps I am mistaken, but I'm getting the impression you thought you mentioned this already. If you will refer to your original post, that requirement/limitation was never mentioned. Regardless, the point I'm making here is that I can only go off the info/code you show. On that note.. Is there only ever going to be one element in that 2nd level, or can that 2nd level have more than one element? If there can be more than one element in that 2nd level, will the one you need to pull data from always be in a certain position (i.e. the first one in the list)? Or, you said the element name can change.. will it only be a certain feasibly finite set of values? Basically, making that 2nd level reference dynamic can be really easy or it can be basically impossible, or somewhere in between. It depends on what the expected JSON structure/format is. You need some sort of way to uniquely target it.
-
well we can't really do anything about the ipb api pulling in avatars from joining via 3rd party social media shit. Well, I guess we can but.. too lazy.
-
Yes, it is because you are a newbie. Offhand, I think I recall that you have to have at least 10 posts to unlock it. Too lazy to go searching for perms atm.
-
['test'] is part of your JSON structure.. I used exactly what you posted, except for fixing the comma.
-
Your first problem is that this is an invalid JSON string so php (or js) won't parse it. There's a trailing comma in your array list (highlighted red). Until you fix that (make sure the JSON string you receive is valid), you aren't going to have much luck moving forward. As far as getting the data.. I fixed the json formatting issue in the example; you need to do that in your own code to make it work. This code sorts the sellorders array by price, lowest to highest, and then the buyorders array by price, highest to lowest. Then it's just a matter of assigning the first price in each array. $data='{"success":1,"return":{"test":{"marketid":"32","label":"test\/TEST1","primaryname":"TestItem","primarycode":"ABC","secondaryname":"Tester","secondarycode":"TES","sellorders":[{"price":"0.00002894","quantity":"13.31323200","total":"0.00038528"},{"price":"0.00002895","quantity":"92.80350000","total":"0.00268666"},{"price":"0.00002897","quantity":"392.60350000","total":"0.01137372"},{"price":"0.00002900","quantity":"392.50350000","total":"0.01138260"},{"price":"0.00002902","quantity":"785.40700000","total":"0.02279251"}],"buyorders":[{"price":"0.00002734","quantity":"93.16130210","total":"0.00254703"},{"price":"0.00002733","quantity":"2.00000000","total":"0.00005466"},{"price":"0.00002731","quantity":"2.31057540","total":"0.00006310"},{"price":"0.00002599","quantity":"3.73174150","total":"0.00009699"}]}}}'; $data=json_decode(trim($data),true); usort( $data['return']['test']['sellorders'], function($a,$b) { if ($a == $b) return 0; return ($a['price'] < $b['price']) ? -1 : 1; } ); usort( $data['return']['test']['buyorders'], function($a,$b) { if ($a == $b) return 0; return ($a['price'] < $b['price']) ? 1 : -1; } ); $lowest_sellorder = $data['return']['test']['sellorders'][0]['price']; $highest_buyorder = $data['return']['test']['buyorders'][0]['price'];
-
javascript has ability to redirect. If you are scraping content from a location that has javascript that redirects, and then output that scraped content on your page, and the javascript is executed, then yes, it's going to redirect. If you don't want that to happen, in principle, you're going to have to do what dalecosp said: find and strip it from the scraped content. Assuming you want to preserve everything else except the redirect, probably his suggestion of replacing opening script tag with something else is too broad a stroke. But we can't really give you a more definitive answer than this, without seeing the content ourselves.
-
Newby question - Copy row from one table to another
.josh replied to Red2034's topic in PHP Coding Help
well, you are assigning something to $classes with that. The problem is your classes() function doesn't know anything about it. So you have to expose it to your classes function. -
Newby question - Copy row from one table to another
.josh replied to Red2034's topic in PHP Coding Help
okay, somewhere in your code you are calling classes(). And inside classes() you have this: $data['title'] = $classes['title']; The problem is that your classes() function doesn't have access to $classes['title']. So you need to expose it to your function. Normally you do this by passing it as a parameter to the function, though there are other ways to do it, depending on when/where you are actually setting $classes['title'] vs. when/where you are calling classes(). For example: $foo = 'bar'; function something() { echo $foo; } something(); This won't echo anything, because something() doesn't have access to $foo. If your error reporting is turned on and set to appropriate levels, you will actually get a notice or warning saying that you are attempting to use a variable that doesn't exist. So instead, you would do something like this: $foo = 'bar'; function something($foo) { echo $foo; } something($foo); Now 'bar' will echo, because you are passing it to the function. Alternatively, you can do this: $foo = 'bar'; function something() { global $foo; echo $foo; } something(); That declares that you want the function to look for $foo in the global context. So it will find it there and reference that. However, it is a bad idea to do it this way. This is considered scope creep, and can lead to unexpected behavior. Another alternative is if everything including the function is actually within a class. Then you could do something like this: class something { var $foo; function doSomething() { echo $this->foo; } } $blah = new something(); $blah->foo = 'bar'; $blah->doSomething(); I show this example because this is essentially what you seem to be doing already with $this->db in your function. Though in practice, you should have getter and setter methods for it instead of directly accessing the value, something like this: class something { var $foo; function get_foo() { return $this->foo; } function set_foo($foo) { $this->foo = $foo; } function doSomething() { echo $this->get_foo(); } } $blah = new something(); $blah->set_foo('bar'); $blah->doSomething(); -
Newby question - Copy row from one table to another
.josh replied to Red2034's topic in PHP Coding Help
Your classes function doesn't know anything about $classes; it's not within its scope. You need to pass it as an argument to the function. -
You aren't supposed to "run the interface" directly. It's basically a blueprint. In practice, you'd do something like this: $foobar = new Programming(); $foobar->sayHello(); $foobar->sayBye(); The idea here is that if you did not define sayHello() and sayBye() in Programming, you'd get an error.
-
More specifically, imagecreatefromstring and imagepng Something along the lines of this: <?php $image = imagecreatefromstring($_POST['byte_array']); imagepng($image,'filename.png'); ?> Though FYI, simply using file_put_contents should have worked. If it didn't work, that means your data isn't right. Perhaps it needs to be base64_encoded or decoded? IOW I suspect you may run into issues even using these GD functions, because file_put_contents should have worked. But anyways, using the GD functions is safer since it offers a level of validation that it's actually real image data, before writing to your server..
-
Yes. Look into using the GD Library.
-
security code image is not showing in php website signup form
.josh replied to Abubakar's topic in PHP Coding Help
yes, you did indeed attach the signup.php file, and it's the same code you posted in-line. I understand your problem just fine. I think the issue here is that you don't understand what I'm telling you.- 9 replies
-
- php
- signup form
-
(and 1 more)
Tagged with:
-
You have your arguments in the wrong order in mysql_query but as requinix mentioned, you should use PDO or mysqli instead.
-
security code image is not showing in php website signup form
.josh replied to Abubakar's topic in PHP Coding Help
well yes, broken image is your issue, just like you stated. And I'm trying to tell you why it's broken, but you keep pointing me to urls that don't actually work. So I have found urls that DO work and have pointed out some reasons why you are getting a broken image.- 9 replies
-
- php
- signup form
-
(and 1 more)
Tagged with:
-
security code image is not showing in php website signup form
.josh replied to Abubakar's topic in PHP Coding Help
Are you actually going to the links you are posting? http://www.hosting.moviestvslinks.com/free-hosting-signup.php That link right there does not show me anything. I get a "website not available" message. This link: http://hosting.moviestvslinks.com/free-hosting-signup.php Shows me a form "Complete the registration form below to apply for free hosting, accounts are activated instantly" and a "Security Code" field with a broken image, which sounds like your issue.- 9 replies
-
- php
- signup form
-
(and 1 more)
Tagged with:
-
security code image is not showing in php website signup form
.josh replied to Abubakar's topic in PHP Coding Help
Okay, so those links you posted still don't work. It looks like this link has the form you are referring to: http://hosting.moviestvslinks.com/free-hosting-signup.php I see an invalid image in the form. The request url of the image is http://order.hosting.moviestvslinks.com/image.php?id=d045c59a90d7587d8d671b5f5aec4e7c And the response code is 200 and it's giving a text/html type response. If I go directly there, I just get some kind of ad page..looks like an automatic response by your host for a subdomain that doesn't actually exist. However, if I go here: http://hosting.moviestvslinks.com/image.php?id=d045c59a90d7587d8d671b5f5aec4e7c I get a text dump that looks like this: ‰PNG IHDRdƒ`ϹXIDATX…íYklTEþænKyTÄP1"P%ËcU¨H€¨<„VÐMI¨1¢ŒE1Dþ¢‘ÿ€(šB#–Ä*Z¨)j„Ôi(¢…b$¤jËÞ™9dz;½;û ¥ 1áËdwîÌwÎ7çܹçÞ»+˜×Ð9xÿõþOÈ1_5M-LàÖ”Oç†<©ÒÛ¿¿èfŸ6ÎDÈg"3Üýþ@Ñ@Ÿ5ý欇 I·—¡˜'b3G…Mˆ[ZU»¸(T‘§¡$‹iÜ·7€¹#Ø~ì4€“m™ÈÝÄ¿©•I1–HEŽžÐ|¾Í)|]¹_ˆÌd‘¢%šÏ·¡ã"²Wœ‘¬k¸E™8 ñdÚ•k¿ØÚ'/¿ÕoÍÍé©SvVQÿ¾Y6f€ê#'à¡é\kFéî!³%(Ήºy³Ê¢˜ççN"Y*$Ûàåä¶ý©¼=Û}áÙrf|ä«æ/°õீ×tö/$s,–—Dœ‘Wj£Yf6Õ @UÃ/V+H°ÓZ9r—Döèäuñ3?Ž)(’ð=òdn»'= ;ê¦ë‰éáâa>h8àèï.¹‚??h:+æŒ_^ šYS>^ž=nyI䥇Ìì–ï~`´„åÅCÍÔ˳ÇY+cbšO!„):ƹ¯dÚ%¥-Xá}èÏt\1Ì“q«øÖeb)eL*é+©•’$ߘϤ¯-š@m9§ÉP*~ýZÂÛ÷›0”R&˜¶ïWJù¾/¥4³R&£ĺ7RJ“)ceMVÌoä‚kp¤Å ÂùIŠDÑ–sn8NÍb&)5ä”V`á1€ÛõgÂ#‹¼ÿm€C§Î¦=i©R›ÎʲI–Uï³#¦cïMÁ©‡'Œ°Z–¼¬zßʲI¯Î½sYõ¾ C¥l K/äÀ¹Þ>¨?£ûþÔ¹T+"”,IúÄ$˜5‘)КL `óÞcš;›)»tƒ¥Ußø²#°@?~ÒŠ‡˜Žs¥XÃ¥U߬)Ÿb}:…¯ÍŸœ:žŠŒŽÈÙYD1_‘"ò”àIà HÓãw…¼óu#€o>“u.¿û¥é¬ìž5åSì!?¦(4‡ íFhø†iœØÁT‡vÖòÓÂQìdt¤ãÉ Ö,$bRKŸ&h ãkãžFñUãï1É1ɾ‚Ó̸m~bµ–°pcóVïúð¹YUKJ«³ëjÛ'éó%=e«j«Ÿ/Ùúì}f°lUôƒZF)¸7r‹”¼xÖ˜Ñe|¥M<!^ð6ÔE &T”ŽðVý!%v4œÈdßMÌ.`ÑÌ€ÊÝQŽVö×ÝYqú¸¢%%£Ñ±³+FEiÀÛ;£ðÄG '3½Ítsƹ¨±¤t,€µ5‡ñùÁ櫤uECœüº#¥X\°~W”¶ïk"/ÝÏ]¹Óbî„¡?SðfMTŸìïÖþ5rYÖÐ}Eäše2õúŽhnˆ«öÏ!Öé_¯ºƒy“G\Qr+€ µ?†>Ü{슫\qE‘xtöœlÚý}L‰‹v9ÂËþ|™xú¾Û¬ÛùÃÕp~õqíßÎãÚ¿;]À?ùèú óíIEND®B`‚ So a couple of things here: firstly is that it looks like you aren't pointing to the right (sub)domain for your image. 2nd, it looks like your image.php script is not properly outputting image content-type header before it outputs the image source code. At the end of your image.php, it should look something like this: header('Content-type: image/png'); // <-- my guess is this is missing imagepng($im);- 9 replies
-
- php
- signup form
-
(and 1 more)
Tagged with:
-
you need to attach a function call that makes an ajax request to the link's click event handler. Either by calling a function in the link's onclick attribute or attaching an event handler w/ javascript. Example of an ajax post request, using jQuery: <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> <a id='someLink' href=''>click me</a> <div id='responseDiv'></div> <script type='text/javascript'> $(document).ready(function() { $('#someLink').on('click',function(e) { e.preventDefault(); $.ajax({ type : 'post', url : 'script.php', data : { foo : 'bar' // data you want to send. This will give you $_POST['foo'] with value of 'bar' }, success : function(response) { // put response into the div $('#responseDiv').html(response); } }); }); }); </script>
-
security code image is not showing in php website signup form
.josh replied to Abubakar's topic in PHP Coding Help
your posted link doesn't work. where is $yourdomain defined? what is the generated url for the img src? what is the http response code are you getting from the image on the page?- 9 replies
-
- php
- signup form
-
(and 1 more)
Tagged with:
-
I know enough to get by as far as setting up ftp accounts, svn, irc, subdomains, pushing files around, little bit of shell scripting, etc.. so I am by no means an expert, especially concerning core stuff..but as far as doing day-to-day "user" stuff.. IMO there really isn't much of a difference between what you choose. For example, centOS vs. Debian.. true story.. we used Debian on one of our servers at work at one point in time, and when IT migrated to new servers, they moved to centOS. I didn't even notice until many months later. I guess my point is, don't get too hung up on all this stuff. It's like trying to pick the perfect car. Sure, one might be a gas guzzler and another may barely go above 50mph, but virtually any car you choose will get you from point A to point B. The rest is fluff and personal preference and dependent on personal needs. Unfortunately, you won't really get a feel for personal preference stuff unless you dive in and give it a try. So IMO I think the best practical advice that can be given for actually moving forward, is make sure whatever you pick has a well supported, robust community and development team. You don't want to pick something only 1 or 2 people are using, or that nobody has released updates on in years. From there.. aside from weeding out obvious stuff (e.g. avoid a distro (like Ubuntu) that focuses on desktop/gui shit if you're looking for a server).. just flip a coin, write them down on paper and pull one out of a hat, etc.
-
sendMail() isn't a built-in php function. It's a user-defined function. It might be helpful if you post the function, so we can see what it's doing.
-
It looks like your problem is scope. You have $BCKCGlobals that you attempt to set and reference in various functions, but that variable doesn't exist within the scope of the functions. You need to pass the variable by reference or value to your functions, or else declare that you want to reference the globally scoped variable, by putting this at the top of all your functions that set or reference it: global $BCKCGlobals; Note: the latter method is generally not a good idea.