-
Posts
4,704 -
Joined
-
Last visited
-
Days Won
179
Everything posted by kicken
-
When should I add $ infront of instance attributes?
kicken replied to eldan88's topic in PHP Coding Help
Because they did it wrong. That code is not correct and should yield some errors, namely undefined variable $_connection and trying to get property of non-object. -
var_dump($balanceQ->fetch_row()) before that line so you can see what value type it is returning.
-
If you want to prepend to the file (write new info to the top but keep the old info) then you need to first read-in the existing file content, blank the file, then write the new content followed by the old content. Using file_get_contents and file_put_contents makes this easier. $file = "/server/path/location/code/backup/sendstats.conf"; $oldData = file_get_contents($file); $newData = "MailTo = {$slEmail}\nMailFrom = {$slSender}\n#\n#\n#"; file_put_contents($file, $newData.$oldData);
-
Your page_enfant function is not designed properly. It always references the root using $pages[0][children] so it cannot go any deeper than one level. The way it should be designed is to just accept a $page argument. It would output the li tag for the $page argument then foreach() over the ['children'] sub array for that page, calling itself once for each child. function page_enfant($page){ echo $page['name']; foreach ($page['children'] as $child){ page_enfant($child); } }
-
There may be ways, depends on the data in question. For example my menu system has an added-on date attached to each node. Unless someone decided to go in an manually fiddle around in the DB vs using the menu management interface, the parent's will always have been added before their children so a simple ORDER BY addedOn works. If it's truly not possibly at the SQL level to do such ordering, you can extend the PHP processing to handle it. It's simply easier if you can assume parents always come first.
-
Building Tree Structures in PHP Using References - Read that. Basically you a) Select everything you need in just one query. Make sure parents come before any of their children b) As you loop the results you maintain two arrays. One containing the tree structure, and a second which is a simple ID => array map. These arrays are connected via a reference.
-
I do not see the problem you describe on my system. That would lead me to believe that you may have your IE configuration set to not cache files, causing it do re-download each time. You can use a HTTP sniffer such as Fiddler2 to check whether IE is actually re-requesting the file on each page load. The only thing you can really do though is to make sure that your image is served as cachable and hope the browser is allowed to cache it. Since your background image is dark, what you should do is also set your page's background-color: to a close match so that if your image does not load (or is delayed) the color is close to what it would be with the image and there is not a large color change once the image is loaded.
- 6 replies
-
- internet explorer
- background image
-
(and 2 more)
Tagged with:
-
No, you break in all three cases: Found, Email-mismatch, and password-mismatch. What you WANT is to break ONLY when the email and password BOTH match, ie the entry is found. For your not-found error messages, what you want to do is have a test AFTER the loop which checks to see if anything was found. You can do this by setting a $found variable to false before the loop, and setting it to true if a valid entry is found. Then after the loop check if $found is true or false. If false, print your error otherwise continue on. Do not bother with trying to print separate messages for email not found vs password doesn't match. A login system should only ever say either they login was successful, or it failed. It should not give any reason for why it failed.
-
Basically you're if condition is incorrect. What you wrote would technically be always true, and should echo out every number. The reason it doesn't is due to computer limitations when it comes to floating point values (rounding errors).
-
Functions. There are both built-in functions which are all documented in the php manual, and user-defined functions which would be defined in your codebase somewhere. Neither of the two examples you gave are built-in so they would be defined in your code somewhere.
-
DATEADD(HOUR, -1, GETDATE()) 'H' is not a valid date part identifier.See: http://technet.microsoft.com/en-us/library/ms186819.aspx
-
Rather than trying to convert 7pm-11pm, why not just leave it as is? Something like 7pm is a relative time, there is no need to be trying to do timezone calculations on it. Leave 7pm as it is and you can handle timezone differences when you generate an absolute date later on. What exactly are you attempting to do?
-
That depends on how exactly you run the cron job. If you just use wget/curl/lynx to fetch the URL, then no it won't be any different. If you run the script using the CLI version of PHP then yes, you'll need to handle the variables differently.
-
Mysql may be loading all the indexes and other data into memory caches (different from the query cache). Once loaded then queries can use those cache to search for data rather than accessing the disk for everything. PHPMyAdmin may be causing this to already happen by querying for all the table details and what not before you get to the screen where you finally run your query.
-
C++/delphi socket TCP/IP to PHP - memcpy/move function in php
kicken replied to rmartyn's topic in PHP Coding Help
I don't think that cdcdcd... vs 000000... will matter. The way C/C++ works with strings, once it sees the first NUL character (00) it ignores everything after it. So long as the bit upto and including the first NUL character are the same, you shouldn't have an issue. -
linux server tries to store session files on c:/wampserver
kicken replied to facarroll's topic in PHP Coding Help
Somewhere either in your code or in your php.ini file you have configured session.save_path to point to C:/wampserver/tmp. You need to change that configuration to point to an appropriate directory on your remote host. -
Just leave out the bit where you are telling it to do a POST instead: curl_setopt($ch, CURLOPT_POST, 1); If you don't tell it you want a POST done with that line, then it will do a GET request.
-
The || operator does not work like that. You have to use full conditions for each test: if ($mime == 'image/jpeg' || $mime == 'image/pjpeg' || $mime == 'image/gif' ...) An alternative is to use in_array with an array of possible mime types.
-
You can transfer your files using SFTP or SCP. On windows a good client to handle this is WinSCP. For other OS's, do some google searching and you'll find a solution. Beyond just uploading the files though, you need to learn how to actually configure apache so it knows where to find the files, how to process them, etc. This is not something to learn via a simple forum post, you need to google for some tutorials on how to manage a LAMP server. CPanel is a piece of software that you'd have to buy and install to manage your server. Unless you paid for it when you bought the VPS, it will not be available to you. You'll have to do everything manually via the command line.
-
It doesn't have anything to do with stuff accessing session variables, it has to do with the fact that session_start needs to send headers in order to assign the session cookie and cache restrictions. When you put your session_start after your HTML or other output like you did, whether it works or not is dependent on whether the server has been configured to use output buffering. If it has, things will appear to work fine. If it has not, you'll get a couple big fat WARNING errors and your session code will not work at all. By calling session_start before any output, you ensure that it will work properly without being dependent on the server's configuration.
-
C++/delphi socket TCP/IP to PHP - memcpy/move function in php
kicken replied to rmartyn's topic in PHP Coding Help
When you debug the c++ app and look at pbytesStore, try and get a hexdump of the value rather than the string representation. String representations can sometimes be inaccurate, a hexdump is much better when trying to compare data. You can tell that your string representation is inaccurate because the size of the data is 62-bytes, but your string view seems to only be showing what appears to be 10 bytes. Once you get a hexdump of pbytesStore, compare that to a hexdump of your PHP generated string, which you can get by running $message through bin2hex -
You can add some code to your scripts to check the value of $_SERVER['REQUEST_URI']. If it contains your model.php script name, then you can lookup what the proper static URL is and redirect them. $_SERVER['REQUEST_URI'] should reflect what the user typed into the browser for the URL, rather than the re-written URL. Alternativly you could add an extra _GET variable to your rewrite rule such as rewrite=1. In your script test if $_GET['rewrite'] is set, and if not, redirect. Either way, you need to make sure your site's existing navigation and other links are updated to the new static URLs. The search engines will get them indexed and start using them as time passes.
-
C++/delphi socket TCP/IP to PHP - memcpy/move function in php
kicken replied to rmartyn's topic in PHP Coding Help
I would be inclined to believe that you are not properly interpreting the debug data from your c++ program. What I have written is correct given the limited information in this thread. Your example output from the c++ code does not match what would be expected based on your responses. Your images of the debug window clearly show the string values "12345678" and "Test_Program", yet your "binary output" you claim to see does not include them anywhere, which it should I would guess. Unless those fields are being ignored in the binary output, in which case your PHP code should also ignore them. My best guess would be that your sample "binary output" from your c++ app is only for the SPMSifHdr structure, and not the entire SPMSifRegisterMsg structure. Your PHP code's output however is for the entire SPMSifRegisterMsg structure, which is why the two do not match, except for the first few bytes. Make sure you're comparing apples to apples, not apples to oranges. -
What does this statement means (<?=) in a tenary operator
kicken replied to asker54's topic in PHP Coding Help
It's in the manual: Language Reference: PHP Tags: Escaping HTML -
C++/delphi socket TCP/IP to PHP - memcpy/move function in php
kicken replied to rmartyn's topic in PHP Coding Help
That is not correct. You should not have the nested pack function. Just: . pack('a20', "44436412") //BODY - char szLisence[20] . pack('a20', "Test_Program") //BODY - char szApplName[20] Notice the difference in the output:$a = pack('a20', pack('c', '44436412')); echo bin2hex($a); -> bc00000000000000000000000000000000000000 $b = pack('a20', '44436412'); echo bin2hex($b); -> 3434343336343132000000000000000000000000