wildteen88
Staff Alumni-
Posts
10,480 -
Joined
-
Last visited
Never
Everything posted by wildteen88
-
Have look at the manual on output buffering.
-
Then replace the spaces with an underscore (_) instead?
-
On line 67 in form_proceessed2011-NEW.php there is some form of output therefore header() will not work. The solution would be to modify your script so there is no output before the use of the header() function. Or for a simple fix revert to using output buffering.
-
Look for PHP validation tutorials. There isn't a built in function which will do it all for you.
-
fwrite() expects parameter 1 to be resource, string given
wildteen88 replied to rpjd's topic in PHP Coding Help
Does the folder Changes exist within the Projects folder? fwrite will not create the directory structure if it doesn't exist. You'll first need to create the directory structure and then create/write to the file. Also make sure the folder Changes if it exists is not set to Read Only in Windows. -
sort decimals least to greatest and vice versa?
wildteen88 replied to devWhiz's topic in PHP Coding Help
The only way I got it to work is to use type casting. Change the foreach loop to foreach($XML->xml->establishments->land as $value) { $key = (int) $value->id; $cost = (int) $value->cost; $income = (int) str_replace(array('$', ','), '', (string) $value->income); $properties[ $key ]['cost'] = $cost; $properties[ $key ]['income'] = $income; $ratios[ $key ] = $income / $cost; } -
sort decimals least to greatest and vice versa?
wildteen88 replied to devWhiz's topic in PHP Coding Help
I didn't test my code using XML data. I used some hard coded values. However this shouldn't make a difference. Could I see how your XML file is constructed? -
You should be replacing the spaces in PHP when outputting your links. Not mod_rewrite.
-
The only places you use explode on are lines 58 and 69 58. $temp = explode(' ', $this->numbers[$j]); 59. for ($a =0; $a <$temp.length; $j++); ... 69. $temp1 = explode(' ', $this->numbers[$j]); 70. for ($a =0; $a <$temp1.length; $j++); On lines 58 and 69 you use explode to get the individual numbers from $this->numbers[$j]. But you are not doing anything with them afterwards (lines 59 and 70). The for loop is not constructed incorrectly. Variables do not have properties such as .length.
-
fwrite() expects parameter 1 to be resource, string given
wildteen88 replied to rpjd's topic in PHP Coding Help
Why when that is what append mode does. Quote from the manual -
sort decimals least to greatest and vice versa?
wildteen88 replied to devWhiz's topic in PHP Coding Help
Yea sorry, I posted in the wrong code earlier. I tried to edit it before you read my reply. -
Templates as in what?
-
That fine. I just through you may have forgotten about your previous post as you didn't reply to it last time. If you want to add a string of numbers, eg $numbers = '1, 3, 18, 27'; And you want to add them into an array you can simply do $array[] = $numbers; That will add the string of numbers to the array.
-
You can use a script called PHPMailer for sending emails with attachments. Basic usage example: http://phpmailer.worxware.com/index.php?pg=examplebmail
-
Just replace the HTML with header('Location: thankyou.php'); However you will want to remove this gap ?> <?php Before using that function. header() will not work if there is any kind of output beforehand.
-
There is nothing wrong with building a CMS in PHP. There a probably thousands of content management scripts that where made with PHP, the most popular being Joomla and WordPress and few others.
-
sort decimals least to greatest and vice versa?
wildteen88 replied to devWhiz's topic in PHP Coding Help
Rather than assign each properties values to seperate variables ($id10_code $id10_value $id10_id etc). You'll want to assign them to an array instead within your foreach loop $key = $value->id; $properties[ $key ]['name'] = $value->name; $properties[ $key ]['cost'] = $value->cost; $properties[ $key ]['income'] = $value->income; After calculate the ratio and add it to a separate array for storing the ratios. When adding the ratio to the array assign its key as the property id eg $ratios[ $key ] = $value->income / $value->cost; Now after the foreach loop you then use max to get the highest ratio from the $ratios array. $highestRatio = max($ratios); // get the highest ratio Next use array_search to get property details for the highest ratio. $propertyKey = array_search($highestRatio, $ratios); // get the property key $property = $properties[ $propertyKey ]; // get the property with the highest ratio $property will be associative array of the properties details (name, cost, income). Complete code $XML = simplexml_load_string("property_list.xml"); $ratios = array(); $properties = array(); foreach($XML->xml as $value) { $key = $value->id; $properties[ $key ]['name'] = $value->name; $properties[ $key ]['cost'] = $value->cost; $properties[ $key ]['income'] = $value->income; $ratios[ $key ] = $value->income / $value->cost; } $highestRatio = max($ratios); // get the highest ratio $propertyKey = array_search($highestRatio, $ratios); // get the properties ID $property = $properties[ $propertyKey ]; // get the property with the highest ratio echo $property['name'] . ' has the best ratio of ' . $highestRatio; -
sort decimals least to greatest and vice versa?
wildteen88 replied to devWhiz's topic in PHP Coding Help
So you only want to calculate the ratios with the properties that have the id of 10, 12 and 16? Or do you want to do it for all properties within property_list.xml? -
sort decimals least to greatest and vice versa?
wildteen88 replied to devWhiz's topic in PHP Coding Help
Without seeing your code how you are getting the cost/income and calculating the ratio I cannot provide you a better answer other than what I posted above. This is what you will need to do -
fwrite() expects parameter 1 to be resource, string given
wildteen88 replied to rpjd's topic in PHP Coding Help
fopen returns a handler which you need to capture using a variable when calling fopen. You then pass this handler as the first parameter to fwrite. You don't pass the filename. Corrected code $handle = fopen($file,'a') or die("can't open file"); fwrite($handle, $Username); -
sort decimals least to greatest and vice versa?
wildteen88 replied to devWhiz's topic in PHP Coding Help
Basically add all the ratios your script calculates into an array then use max which will pick the highest ratio from the array -
sort decimals least to greatest and vice versa?
wildteen88 replied to devWhiz's topic in PHP Coding Help
No point I don't read PM's. If you need help post it in the forums. -
sort decimals least to greatest and vice versa?
wildteen88 replied to devWhiz's topic in PHP Coding Help
Use an if which compares the two variables if($FirstRatio > $SecoundRatio) echo $FirstRatio; else echo $SecoundRatio;