-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Everything posted by PFMaBiSmAd
-
Data Collision when using Static Class Validation
PFMaBiSmAd replied to ponderous2k's topic in PHP Coding Help
All resources used on a page request are destroyed when the processing of that page request completes. Each visitor and each request for the same page by the same visitor is completely separate from all the other requests that the server gets. -
The current code being 'tested' did not come directly from the OP and since it does not have a WHERE clause to specify which data is retrieved, there is no chance of it working.
-
If you are including a file in the inc folder and that file then contains an include statement, the relative path used is that of the main file, because the first level included code just became part of the scope of the main file. You are not including a file that includes a file. You are including code that becomes part of the main file and if that code contains an include/require statement that eventually gets executed it is relative to the main file.
-
^^^ Also, that's syntactically incorrect and introduces a fatal parse error.
-
^^^ Also, there's nothing in the posted code that sets $_POST['submit'] so your form processing code is being skipped over. Did you do any basic debugging of this on your system while you were creating it and before you posted it here?
-
I don't see anywhere in this thread where you actually state what does happen when you submit the form? What do you see in front of you? You should be using both of the following settings so that all the php detected errors will be both reported and displayed (actually your development system should have these two settings in your master php.ini so you don't need to put them into your code or remember to remove them later) - ini_set("display_errors", "1"); error_reporting(E_ALL); I also don't see any actual AJAX code involved and you should get your application working first before you attempt to use AJAX with it.
-
Mmmm and the data I used to test the functioning of the code was just that, some expected data.
-
We only see the information you supply in your posts. It is kind of up to you to investigate what your code is doing on your server with your data.
-
The code you posted outputs data for each row the query returns (which I just tested.) If you are only getting one set of data, your query is only matching one row OR your actual code is doing something to prevent all the data from being iterated over.
-
You do realize that if you had continued with this problem in your first thread about it, you could probably have solved it by now. Your $_SERVER['DOCUMENT_ROOT'] is apparently empty. Your web host can probably fix it by correcting the vhosts definition. However, after your php script starts, $_SERVER['DOCUMENT_ROOT'] is just a variable that you could set yourself with the correct value for your actual document root and it would allow you to form absolute file system paths to where your include/require files are actually located.
-
If you are not posting (simple as copy/pasting) the actual code that exhibits the symptom, no one can help you with your actual problem. $_SERVER['HTTP_HOST'] has absolutely nothing to do with forming a file system path to where your file might be located on the server.
-
$_SERVER['SERVER_NAME'] and require function
PFMaBiSmAd replied to visualazza's topic in PHP Coding Help
$_SERVER['DOCUMENT_ROOT'] -
I finaly got it up (my site) need help with a hit counter
PFMaBiSmAd replied to nouse4one's topic in PHP Coding Help
Actually, I mean insert a row for each response, not add to a counter. -
I finaly got it up (my site) need help with a hit counter
PFMaBiSmAd replied to nouse4one's topic in PHP Coding Help
You would be better off just recording each set of submitted data in a database table. You can then access any of that information and get a count any time you want. -
If you don't post the actual code responsible for the symptom, no one can help you with your actual code. LOL - ^^^ Computer programs don't work that way. All that does is make it take longer for the code on the page to execute.
-
Memory Usage: Arrays initialized differently
PFMaBiSmAd replied to pigmonkey's topic in PHP Coding Help
LOL, values in variables/arrays aren't what you think they are unless you explicitly assign them... I suspected that if you altered the values that the memory would go up as expected because the reference to the common static/fixed value would get replaced with the actual unique data. -
Memory Usage: Arrays initialized differently
PFMaBiSmAd replied to pigmonkey's topic in PHP Coding Help
Even if you separate the code into two files, you will get similar results. If you use array_fill() you will get a similar value to the array_pad(). Best guess is that explicitly listing entries in an array results in a data structure that consumes more memory. Which gave me the following idea - Php could be using some short-circuit optimization where it is using a reference to the result of the array_pad() output (which is a constant/fixed value), which I just confirmed with the following code (the memory usage goes way down by defining the $ar filled array outside the loop and assigning it inside the loop) - <?php $string_parts = 4; $max = 10000; $arr = array(); $i = 0; $start = memory_get_usage(); $ar = array_pad(array(), 4, "A"); for(;$i<$max;$i++){ //$arr[] = array_pad(array(), 4, "A"); $arr[] = $ar; } $end = memory_get_usage(); printf("%d iterations, %d bytes in array\n", $max, $end-$start); $arr2 = array(); $i = 0; $start2 = memory_get_usage(); for(;$i<$max;$i++){ $arr2[] = array("A", "A", "A", "A"); //$arr2[] = array('A', 'A', 'A', 'A'); //$arr2[] = array_fill(0,4,'A'); } $end2 = memory_get_usage(); printf("%d iterations, %d bytes in array (%.2f%%)\n", $max, $end2-$start2, ($end2-$start2)/($end-$start)*100); ?> -
looping through multipul arrays and inserting into SQL
PFMaBiSmAd replied to Bifter's topic in PHP Coding Help
Your $name variable is actually the array key and it ties all the related values to each other. Inside your existing foreach(){} loop, you can reference the other values using - $_GET['linequantity'][$name] $_GET['lineprice'][$name] -
I've been following some of your threads while you attempt to create this application. Storing just an away/home indicator as the pick value makes it extra complicated to associate that back to the actual team. Is there some reason you did not store the team id that they picked as the pick value? You have added an extra level of abstraction by just using an away/home value.
-
otuatail, That has nothing to do with the question and since you cannot use functions as default values for datetime data types, it's invalid as well. If the column happened to be a TIMESTAMP data type, you could use default values that are a few of the mysql function names, but that is not what the OP is doing or asking about.
-
Array has contents, but won't echo...
PFMaBiSmAd replied to techiefreak05's topic in PHP Coding Help
I guess you didn't want to solve this anytime today or you would have actually posted the code responsible for the symptom and the values involved. We are not standing right next to you. It is simply not possible to help you with what you see in front of you (your code and the output) without seeing that same information. -
Array has contents, but won't echo...
PFMaBiSmAd replied to techiefreak05's topic in PHP Coding Help
Either your echo statement is in a program scope where the variables don't exists or the echo statement is inside of some conditional code that is false or the echo statement is inside of some HTML tag and the value is in the 'view source' of the page but does not display or the actual value IS some html tags that don't display when rendered in the browser. It is not possible to debug one line of code taken out of context of how and where it is being used at in the actual program or what values are actually in the data. If you want someone to tell you why your code is doing what it is, you must post all the relevant code and what the data values are that don't display. -
Just some notes - Since this seems to be related to the updatePassword() processing, best guess is that the code that gets the new password from the form contains an error and is actually passing the updatePassword() function something that is not the actual entered password (probably an empty string or perhaps the password already passed through the md5() function.) This would produce an md5() value, which gets stored in the database table, but it would not match what the login code is doing. The short script I posted above would have produced the md5() value that is stored in your database table. Too bad you could not have gotten to the point of executing that to see if what it produces is what is in your database table. You could also have copy/pasted the value that short code produces into your database table to reset your password to a known value.
-
Also, I don't specifically see anything in the code posted so far that would allow you to change someone else's password, so it may be that if you attempted to change someone else's that you in fact changed your own to whatever you entered and you should try that value as your password.