-
Posts
4,362 -
Joined
-
Last visited
-
Days Won
11
Everything posted by Zane
-
Yes, I was also pretty off-put by that wording. Unless you're traversing through the session files stored in your servers tmp directory, I only know of one $_SESSION to loop through, and that is the current one. I imagine about the same thing as requinix... $_SESSION['sessionOne'] = range (5,5000); $_SESSION['sessionTwo'] = range (5,6000); $_SESSION['sessionThree'] = range (5,7000); Provide code if you're asking questions about it. Seven tables full of nothing but traits? Like attributes? Key/Value pairs?I sense a non-normalized db structure, but that's a whole different can of worms.
-
Without any code, I would suggest that you order all your arrays descending and grab the first element in each array. Boom, max values collected!
-
PHP variables begin with a $ dollar sign.
-
If you have the signup_date column set to a DATE type, then there's no reason to use PHP. SELECT id, signup_date FROM pdata WHERE signup_date >= DATE_SUB(NOW(), INTERVAL 30 DAY)That way, ONLY the users whose signup_date is a month old will be returned.
-
Seriously? Three years later I get corrected.
-
Using this 5 year old example, http://us3.php.net/manual/en/function.array-diff-key.php#82257 should help. Using that array_unique_diff function, you should be able to have an array of all the unique and different keys. Then you can iterate through those with a loop and add them to each array.with a value of 0. If I understand you correctly. function array_unique_diff ($array1, $array2) { return array_merge(array_diff_key($array1, $array2), array_diff_key($array2, $array1)); } $a = array ( "one" => 1, "two" => 2, "three" => 3 ); $b = array ( "one" => 56, "two" => 2, "four" => 19 ); $missingKeys = array_unique_diff ( $a, $b ); foreach ( $missingKeys as $key=>$val ) { $a[$key] = 0; $b[$key] = 0; } That should change $a and $b to be $a = array ( "one" => 1, "two" => 2, "three" => 3, "four" => 0 ); $b = array ( "one" => 56, "two" => 2, "three" => 0, "four" => 19 );
-
need suggestion; for searching a word inside an html page
Zane replied to gghhh456's topic in PHP Coding Help
Firstly, the sole purpose of using PHP (or pretty much any programming language) is to create dynamic content. That being said, I still have no idea what you are asking. Where are you searching from? Where are these "words"? Are you talking about querying a database? Your question is very unclear. -
No need to pass by reference, because mainly, it will not solve your problem. Leave the ampersand (&) out of there and check this out. You're using the following foreach syntax foreach ( $r as $result ) Judging by what follows, $r is a multidimensional array, right,... meaning $result will be a sub array of $r..... right. You want to preserve the formatted data, from what I gather. Therefore, if you were to pass anything at all by reference, it would be the main array $r. But,... you are not within a function, so the scope of your variable has not changed. Therefore, you can edit $r within the foreach WITHOUT an ampersand (&), without any kind of referencing whatsoever! In order to preserve your data, you need to know exactly which item in the $r array to edit, ...and the easiest way to locate data in an array is with the key. Fortunately, foreach has slightly different syntax that allows you to retrieve the key as well. So now, you should understand why this way is much much better. foreach ($r as $key=>$result){ // format results if ((array_key_exists('sr_number', $result)) && ($result['sr_number'] == "")){ $r[$key]['sr_number'] = " "; } if ((array_key_exists('start_dt_tm', $result)) && ($result['start_dt_tm'] !="")){ $r[$key]['start_dt_tm'] = date("m-d-y h:i A", strtotime($result['start_dt_tm'])); } } Without knowing exactly what you array looks like, I can't guarantee that the above code will work. I merely wanted to point out that the key of the array IS accessible. Even if you were not using a foreach loop, rather a while loop or something else, you could use PHP's key function and store it into a variable.
-
Instead of concatenating several quoted and double quoted strings together, why not make things easier on yourself and use a HEREDOC?
-
I don't have a /etc/php.ini, is it a problem?
Zane replied to renatov's topic in PHP Installation and Configuration
"Apache's php.ini" otherwise known as a server side include allows Apache to use PHP whenever it needs it. The CGI way is quite old. When using this method of PHP installation, you must call the PHP interpreter when you want to use it. In other words, the CGI way would be for those who do not intend to use PHP much, if at all. FastCGI is a mix of the two, which I have yet to try. Most PHP-heavy websites should be using the Apache SSI installation of PHP. More information here http://blog.layershift.com/which-php-mode-apache-vs-cgi-vs-fastcgi/- 7 replies
-
- php.ini
- installation
-
(and 2 more)
Tagged with:
-
Do the following? ... what is following what?
-
I don't have a /etc/php.ini, is it a problem?
Zane replied to renatov's topic in PHP Installation and Configuration
Only in the file which phpinfo says is THE file. PHP.ini is nothing more than a text file with a list of settings, it doesn't matter whatsoever where the file is located on your server so long as: a ) PHP has permission to access it b ) Apache is pointing to the correct path of the file There's no "correct" place to keep your php.ini file to answer your question. Some people even have them in their webroot along with all of their other web-accessible files.- 7 replies
-
- php.ini
- installation
-
(and 2 more)
Tagged with:
-
Maybe I'm confused, but.. Chrome comes pre-equipped with a debugger..... https://developers.google.com/chrome-developer-tools/ Using the console tab, you can easily type alert(checkacct); and press enter, and it will work. You can even call your function.
-
While that could be possible, bluemonde. You would be the only one that can know. I didn't rewrite you entire script or anything. I simply made it more human readable. So any and all syntax errors, variable declarations, server settings, php version, apache version, operating system, etcetera... are on you. If you open the source, using view source (or Chrome's development pane), you should be able to see for sure whether or not $check went through.
-
MYSQL query, trim last character and group by similar items.
Zane replied to eternal_noob's topic in MySQL Help
Although I didn't test the query at all, I've came across headaches in the past where I would get an invalid field error. or something something is ambigous. We always had to use two dots in my DB Admin class... databaseName.tableName.fieldName -
Where are you planning to use the $country variable? From what I understand from your posts, you want to use it in your query, which have yet to see. In that case, country should be used in the WHERE clause of the SQL query.
-
We understand what you want; a multidimensional array. Provide all of your code, maybe that will help?
-
This went from being an array to being a JSON object, I'm just as confused now as I was to begin with.
-
I do not see anywhere in your code where you actually use the $_GET['country'] variable.
-
The plus sign (+) is used for arithmetic statements, not for concatenation like Javascript. array_slice is going to do exactly as it's name suggests.. Slice the array. If you simply want to add an array to an array, then this should work $equipo['Jugadores'] = $jugador; Still, you haven't provided enough code for an effective answer.
-
<?php $check = 1; echo <<<JSCRIIPT function checkB4SaveForm() { var checkacct={$check}; if (checkacct==1) { var show = confirm("This account exists! Would you like to view it?"); if (show) { searchAndDeleteForm(); return false; // show the record and cancel save transaction } else { return false;"; // cancel save transaction } } } // end function JSCRIPT; ?> Try this out, for the sake of syntax and good reabability
-
You haven't provided any code whatsoever for us to use to point out the error.
-
What do you mean it doesn't work?
-
MYSQL query, trim last character and group by similar items.
Zane replied to eternal_noob's topic in MySQL Help
SELECT substring(invW.StockCode, 1, (len(invW.StockCode) - 1)) as sStockCode , SUM(invW.QtyOnHand - invW.QtyAllocated) AS 'Value' FROM SysproCompanyJ.dbo.InvWarehouse as invW WHERE invW.QtyOnHand > '0' And Warehouse = 'SW' GROUP BY substring(invW.StockCode, 1, (len(invW.StockCode) - 1)) HAVING SUM(invW.QtyOnHand - invW.QtyAllocated) > 0 Untested.