bsmither
Members-
Posts
213 -
Joined
-
Last visited
-
Days Won
3
Everything posted by bsmither
-
Do you have control over the web server's (Apache?) configuration file? If so, study the LimitRequestBody parameter. Be aware that too many players in this process hold filesizes and limits in an integer field. So some of these (ridiculously large) limuts will be ignored because they are greater than what a 32-bit integer can hold.
-
Eliminating duplicate array values with array_unique in shopping cart
bsmither replied to terungwa's topic in PHP Coding Help
According to the manual, array_unique returns a new array. So you will to assign the results of array_unique to a new or the same array. And array_unique is not meant to work on multi-dimensional arrays. So, because $_SESSION["cart_array"] is an array of arrays, I think array_unique is not the most appropriate choice to accomplish this step of your process. -
I'm not familiar with PDO, so please verify if: $result = $stmt->fetch(PDO::FETCH_ASSOC); returns the entire recordset, or just one record (where the database recordset pointer is currently pointing).
-
The first step to doing this is to ask the Moderator to move this thread to: http://forums.phpfreaks.com/forum/19-php-installation-configuration/ The second step is to read: http://forums.phpfreaks.com/topic/2470-easy-installation/
-
No, but if you google for "free web hosting php", I am sure there will be dozens of ads in the results... oops!
-
There are hundreds of companies that will sell you a hosting account that supports PHP. There is an advertisement in the bottom left corner of this page for hosting.
-
With a virtual private server or a dedicated private server, you can install (or get installed) whatever you want. Do you just need a sandbox to play in?
-
What I notice in the code posted in #8, is: foreach ( $alertValue as $alert ) { if ( in_array($alert, $event) ) { echo $radiowarning; } } This is a loop (13 iterations), and depending on the if/then expression, $radiowarning will be echoed -- as many as zero times to as many as 13 times.
-
"I am interested to learn how to write the necessary HTML and javascript that, when I click on a <div> containing data from a record of a recordset, that <div> will be visible." Commonly referred to as a "tabbed" display, one would: * Loop through the recordset. * Each iteration will build a <div id="id#"> block with id# being a reference to the record, such as $record['id'] and, * Each iteration add a tab (using css) to build up a series of tabs. That will result in a row of tabs followed by a series of <div> blocks of code, each with a unique id. In javascript, you will initially set all divs to have a visibility attribute of hidden, then make visible the first div. The javascript will be triggered on a click event from a tab, which will make visible the resective div.
-
We have placed the highest priority alert in $message. $message is the only variable that needs to be used in the remainder of the code. The remainder of the code builds $bannerStyle, and $radiowarning incorporates $bannerStyle and $message. So, echo $radiowarning just once.
-
So lets look at the loop. foreach ($result as $entry): $event = $entry->children("cap", true)->event; endforeach; I would like to build $event as an array holding each value of the 'event' XML node. So; $event[] = $entry->children("cap", true)->event; This change will append a new element to the $event array containing the phrase extracted for this iteration of the loop. Then, $intersect = array_intersect($alertValue, $event);
-
This statement: $result = $entries->xpath("//prefix:entry"); seems to be pulling the values of all targeted nodes into the variable $result. Let's use $result assuming it holds all the alerts from the parsed XML. Edit: On second look, maybe $result does not hold the alert phrases. I see that you are still iterating through $results to get at a deeper node of the XML. The result of array_intersect($alertValue, $result) needs to be assigned to a variable. So, for example: $intersect = array_intersect($alertValue, $result); $intersect is an array that will contain only those elements from $alertValue that were also found in $result, in the same order that $alertValue has them in. Finally, $message = array_shift($intersect); to get the first element (which is the highest priority).
-
Working again with: array_intersect($alertValue, $events); $alertValue contains the user-prioritized events: for example, 'Tornado Warning' is the highest priority. The elements in $events will keep the matching elements in $alertValue, that is: $intersect = array_intersect( array('Tornado Warning','Severe Thunderstorm Warning','Tornado Watch'), array('Tornado Watch','Severe Thunderstorm Warning') ); $intersect will have an array of: [1] => 'Severe Thunderstorm Warning' [2] => 'Tornado Watch' because those were the only matching elements -- and that is the order of $alertValue. Then you array_shift($intersect) to get the highest priority event according to your user-prioritized $alertValue array.
-
I don't like this: <a href="#" class="button1">Send</a> <a href="#" class="button1">Clear</a> There is nothing to differentiate the two links. I would expect some javascript to actually submit the form, looking at these <a> tags for a click event.
-
How to get this script in a lower version of PHP
bsmither replied to alpha_01's topic in PHP Coding Help
Let's assume filter_var() works.That means the script is running on PHP 5.2 or greater. And since the script is referencing a class by a variable, the PHP must be 5.3 or greater. But probably not PHP 5.4 as the dereferencing was implemented in this version. This was also said: I got this info from latest version of phpMyAdmin. I cannot dispute that phpMyAdmin may indicate the version of PHP of which this application is running under (the demo of the latest version requires you to click a link to see the phpinfo), but since phpMyAdmin is actually a web-based database GUI, I am more inclined that: I am using PHP 5.5.9. My host is using PHP 4.1.8 is a misreading of the indicators and that phpMyAdmin is reporting that this is its own version (latest being 4.1.13). -
How to get this script in a lower version of PHP
bsmither replied to alpha_01's topic in PHP Coding Help
"I tried post#7 but still a blank screen." Sorry. I did not mean to imply this was the only statement that needed to be examined. Line 181: $page = $pages->getPages()[0]; Same thing. Please try this equivalent: $pagesPages = (array)$pages->getPages(); $page = $pagesPages[0]; -
I am confused about the XML source. Are you saying that after having parsed the XML source, the results of that parsing could contain more than one 'event'? So, after parsing, you end up with an array of found 'events': print_r($events): $events: Array( [0] => "Flood Watch" [1] => "Severe Thunderstorm Watch" [2] => "Tornado Watch" ) Now, you need to compare the $events array against the $warnings array. If any element in $events can be matched to any element in $warnings, then return those matches. If this is the case, please read array_intersect.
-
How to get this script in a lower version of PHP
bsmither replied to alpha_01's topic in PHP Coding Help
Line 4: $sitename = $settings->getVal('site_name')[0]['setting_val']; PHP 5.latest allows for (something like) the 'dereferencing' of objects, which allows indexing into the array of a object. Please try this equivalent: $settingsVal = (array)$settings->getVal('site_name'); $sitename = $settingsVal[0]['setting_val']; -
Let's try finding the problem by removing some things and testing. Then add them back one at a time: Test, and if it works, do the next: $result = mysql_query("SELECT * FROM friendlist"); Test, and if it works, do the next: $result = mysql_query("SELECT * FROM friendlist ORDER BY firstname ASC"); Test, and if it works, do the next: $result = mysql_query("SELECT * FROM friendlist WHERE status='pending' ORDER BY firstname ASC"); Test. $result = mysql_query("SELECT * FROM friendlist WHERE firstname='".$_SESSION['SESS_FIRST_NAME'] ."' and status='pending' ORDER BY firstname ASC"); If the last test does not work, then we can say there is no record that has the value assigned to $_SESSION['SESS_FIRST_NAME'].
-
In my experience with some versions of the MySQL database engine, status is a reserved word. Please try your query using backticks to delineate table and column names: AND `status` = 'pending' (The backtick character is on the key just above the TAB key on the keyboard.)
-
Please give some consideration to this: //begin while loop while ( $new_array ) { $a = $new_array['some_value']; $b = $new_array['another_value']; } //end while loop Within each iteration of the loop, $a and $b is being assigned values. Yet, nothing is being done with $a and $b. $a and $b is constantly being assigned new values with nothing having been done with the values they had in the prior iteration.
-
How to retain Select option after submitting the form in php
bsmither replied to raymak's topic in PHP Coding Help
Please be very careful and note where the quote marks are located: <option value="<?php echo $line['serviceid']; if ($line['serviceid'] == $service) {echo 'selected="selected"'} echo $line['serviceid']; ?>"> The above line, when completed, will look like: <option value="3selected="selected"3"> Your statement should read: <option value="<?php echo $line['serviceid']; ?>" <?php if ($line['serviceid'] == $service) {echo 'selected="selected"'} ?>> The above line gives, when completed: <option value="3" selected="selected">- 12 replies
-
- php coding
- web application
-
(and 1 more)
Tagged with:
-
How to retain Select option after submitting the form in php
bsmither replied to raymak's topic in PHP Coding Help
Ok, so we have this at some point: $service = $_POST['service']; Then we have this inside the loop -- looking for something that changes in each iteration of the loop: if ($_POST['service'] == $service) { Consider that $_POST['service'] and $service never change at any point in the loop, there is nothing different that is being checked. The code needs to test on that thing which changes for every iteration of the loop: $line['serviceid'] if ($line['serviceid'] == $service) {- 12 replies
-
- php coding
- web application
-
(and 1 more)
Tagged with:
-
How to retain Select option after submitting the form in php
bsmither replied to raymak's topic in PHP Coding Help
I am not liking this: <option value="<?php echo $line['serviceid']; if ($_POST['service'] == $service) { // What value does $service currently hold? echo 'selected="selected"'; } echo $line['serviceid']; ?>"> <?php echo $line['service']; ?> </option> In the code above, the variable $service will need to equal the value being held in $_POST['service'] for a true result. Let us know if it is defined anywhere. The code is iterating through the $resultservice array on a $line by $line basis. So, $_POST[service'] will actually need to equal the current iteration's $line['serviceid'] for a true result.- 12 replies
-
- php coding
- web application
-
(and 1 more)
Tagged with: