wildteen88
Staff Alumni-
Posts
10,480 -
Joined
-
Last visited
Never
Everything posted by wildteen88
-
What body section? I'm confused.
-
recompiling is only need when PHP is used on non-Windows based operating system. The PHP package for windows is all pre-compiled - no need to recompile anything on windows. All you have to do is enable the mysql extension within the php.ini. The FAQ I linked to tells you how to enable the mysql extension on windows. if you are not using windows then I can't provide instructions for recompiling, except from what I read form the manual you have to use the --with-mysql="PATH/TO/MYSQL" command when recompiling.
-
"Undefined Variable" notices has nothing to do with mysql? Do you mean "Undefined mysql_connect"? If you do then what OS (Window, Mac, *nix) is PHP running on. If you're on Windows, PHP does not need recompiling. Instead please read this FAQ. If you're on a Mac/*nix then yes you do need to recompile PHP with the --with-mysql="PATH/TO/MYSQL" command when recompiling.
-
Whys it got newlines at the start of the script? You haven't modified the script have you, except the additions I told you to make? Change this part of the code to: // Change the array so that it's keyed on IP and the value is the hits foreach ($data as $d) { list($ip, $hits) = explode('|', $d); $new_data[$ip] = trim($hits); } to: $i = 1; echo '<pre>'; // Change the array so that it's keyed on IP and the value is the hits foreach ($data as $d) { $d = trim($d); if(!empty($d)) { echo $i . ': ' . $d . "\n"; $i++; list($ip, $hits) = explode('|', $d); $new_data[$ip] = trim($hits); }else{$i++;} } echo '</pre>'; Re run the code.
-
Delete the contents of counter.php and re run the script again. Also run it a couple of times.
-
Interesting, looks like something is not quite write. Added in some echo's at different stages of the script to see what is happening. Re run the following code: <?php echo 'PHP Version: ' . phpversion() . '<br />'; if(file_exists('counter.php')) { echo 'counter.php exists'; if(is_readable('counter.php') && is_writable('counter.php')) { echo ' and is readable and writable<br />'; echo 'Opening counter.php<br />'; // Open the file and read the details into an array $data = file('counter.php'); // Change the array so that it's keyed on IP and the value is the hits foreach ($data as $d) { list($ip, $hits) = explode('|', $d); $new_data[$ip] = trim($hits); } echo 'Retrived ips: <pre>' . print_r($new_data, true) . '</pre><br />'; // Check if the ip already exists if (isset($new_data) && array_key_exists($_SERVER['REMOTE_ADDR'], $new_data)) { // If it does then increase the hits by one $new_data[$_SERVER['REMOTE_ADDR']]++; echo $_SERVER['REMOTE_ADDR'] . ' exists hits incremented (' . $new_data[$_SERVER['REMOTE_ADDR']] . ')<br />'; } else { // If it doesn't then add it $new_data[$_SERVER['REMOTE_ADDR']] = 1; echo $_SERVER['REMOTE_ADDR'] . ' does not exists added to list:<pre>' . print_r($new_data, true) . '</pre>'; } echo 'Rewriting data to counter.php<br />'; // rewrite new data to counter.php $handle = fopen('counter.php', 'w'); foreach($new_data as $ip => $hits) { $data = $ip . '|' . $hits . "\n"; echo 'Adding: ' . $data . '<br />'; fwrite($handle, $data); } echo 'Counter.php closed'; fclose($handle); } else { echo 'counter.php is either not writable or readable!'; } } else { echo 'counter.php does not exists'; } ?>
-
[SOLVED] Changing database column datatype
wildteen88 replied to MasterACE14's topic in PHP Coding Help
Use the ALTER TABLE syntax. Eg: ALTER TABLE tbl_name CHANGE col_name new_col_name DATATYPE_HERE -
[SOLVED] Using Apache with a Wireless ROuter
wildteen88 replied to joeysarsenal's topic in Apache HTTP Server
Go to http://portforward.com/routers.htm for how to port forward your FTP servers port. I used that site for learning how to port forward. Just find your router in the list (the model number) and read through instructions provided. -
Code works flawlessly here. I'm assuming contact.php is formatted like the following: 127.0.0.1|1 192.168.2.2|1 The code should automatically increase the hits for the ip address already logged, eg if a user comes to the script and they have an ip address of 127.0.0.1 for example the script will increment the current hits for that ip address by 1. Which will result in contact.php changing to: 127.0.0.1|2 192.168.2.2|1 If a user has an ip address not currently listed in counter.php then it'll get added to the bottom, eg: 127.0.0.1|2 192.168.2.2|1 xxx.xx.x.xxx|1 xxx.xx.x.xxx being the ip address.
-
Huggies code had a slight bug in it. Try the following code: <?php // Open the file and read the details into an array $data = file('counter.php'); // Change the array so that it's keyed on IP and the value is the hits foreach ($data as $d) { list($ip, $hits) = explode('|', $d); $new_data[$ip] = trim($hits); } // Check if the ip already exists if (isset($new_data) && array_key_exists($_SERVER['REMOTE_ADDR'], $new_data)) { // If it does then increase the hits by one $new_data[$_SERVER['REMOTE_ADDR']]++; } else { // If it doesn't then add it $new_data[$_SERVER['REMOTE_ADDR']] = 1; } // rewrite new data to counter.php $handle = fopen('counter.php', 'w'); foreach($new_data as $ip => $hits) { $data = $ip . '|' . $hits . "\n"; fwrite($handle, $data); } fclose($handle); ?>[code] [/code]
-
If you are using bbcodes (, etc.) then you should parse them as pairs. I guess at the moment you are using str_replace to parse into <b>. This is not very particle. The best way is to use regex for bbcode parsing. I would recommend you searching this forum for the term bbcode, best place to search is in the Regex help forum. There has been many posts about BBCode.
-
Quick Question so resolve a php / apache windows problem.
wildteen88 replied to bank's topic in Apache HTTP Server
PLease read this faq lib_mysql.dll relies on another library called libmysql.dll. This file should be located in the root of the PHP folder. PHP cannot the contents of the PHP folder what you should do is add the PHP folder to the WIndows Path. Note: After adding PHP to the PATH windows must be restarted. -
If you dont want to update all your .html files then you could use mod_rewrite for this. Using mod_rewrite you'll catch the requested html file and then pass this html file to a php script, the php file will include the requested HTML file, and update the file statics at the same time.
-
You're not using the concatenating assignment operator (.=) as I suggested in my post above. Re-read my post above for what to do.
-
Can't use php extensions.
wildteen88 replied to cgimusic's topic in PHP Installation and Configuration
Run phpinfo and ensure PHP is reading the php.ini you are editing. Also have a read of this FAQ. If you have gone through that FAQ, then make sure the following files: php_mysql.dll libmysql.dll Are only located in PHP's and MySQL's installation folders only. Any of those files above outside of of your installation folders either delete or rename. -
You'll want to use the concatenating assignment operator (.=) instead of a normal assignment operator (=) $StringIngrediant .= $quantity . ' ' . $fraction . ' ' . $measure . ' ' . $ingrediant . '-'; Then echo $StringIngrediant outside of the for loop (before or after the 'echo $preperation; line)
-
You cannot catch the key from an array in a for loop, unless you know what the keys are in the array. If the keys are defined as a1, a2 ... a12 etc. Then you could do: $MyArray = array("a1"=>5,"a2"=>6,"a3"=>7,"a4"=>8,"a5"=>9); for ($i = 1; $i < count($MyArray); $i++) { $key = 'a' . $i; echo $key . ' = ' . $MyArray[$key] . '<br />'; } However foreach would be better as its sole purpose is to loop through arrays. $MyArray=array("a1"=>5,"a2"=>6,"a3"=>7,"a4"=>8,"a5"=>9); foreach($MyArray as $key => $value) { echo $key . ' = ' . $value . '<br />'; }
-
Try: <?php if(isset($_POST['enterReceipt'])) { echo '<h1>Recipe:</h1> <p> <b>Ingrediants:</b><br /> '; for($i = 0; $i < count($_POST['ingredient']); $i++) { $quantity = $_POST['wholeNum'][$i]; $fraction = ($_POST['fraction'][$i] !== '00') ? $_POST['fraction'][$i] : null; $measurement = ($_POST['meassure'][$i] !== '00') ? $_POST['meassure'][$i] : null; $ingrediant = $_POST['ingredient'][$i]; echo ' <b>' . $quantity . ' ' . $fraction . '</b> ' . $measure . ' ' . $ingrediant . "<br />\n"; } echo '</p> <p> <b>Preperation:</b><br /> ' . $_POST['preperation'] . ' </p>'; } else { ?> <form name="numItems" method="post" action="<?php $_SERVER['PHP_SELF']; ?>"> <table class="nonBorder"> <tr> <td> <label>Number of ingredients</label> <select name="numItems" id="numItems" onchange="this.form.submit()"> <?php $items = $_POST['numItems']; $range = range(0, 20); foreach($range as $value) { $newValue = 21 - $value; echo '<option value="' . $newValue . '"'; if($newValue == $items) { echo ' selected="selected"'; } echo '>' . $value . "</option>\n"; } ?> </select> </td> </tr> </table> </form> <form name="enterReceipt" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <table class="table"> <?php if(isset($_POST['numItems'])) { $numItems = $_POST['numItems']; while ($numItems <= 20) { ?> <tr> <td> <select name="wholeNum[]"> <option value="00">Whole Num</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">0</option> <option value="10">10</option> </select> <select name="fraction[]"> <option value="00">Fraction</option> <option value="1/16">1/16</option> <option value="1/8">1/8</option> <option value="1/4">1/4</option> <option value="1/2">1/2</option> <option value="3/4">3/4</option> </select> <select name="meassure[]" id="measurement"> <option value="">Measure</option> <option value="Teaspoon(s)">Teaspoon(s)</option> <option value="Tablespoon(s)">Tablespoon(s)</option> <option value="Cup(s)">Cup(s)</option> <option value="Pint(s)">Pint(s)</option> <option value="Quart(s)">Quart(s)</option> <option value="Pound(s)">Pound(s)</option> <option value="Pintch">Pintch</option> <option value="Ounce">Ounce</option> </select> <input name="ingredient[]" type="text" /> <?php $numItems ++; ?> </td> </tr> <?php } } ?> <tr><td>Preperation</td></tr> <tr> <td><textarea style="width:470px;" name="preperation" cols="" rows=""></textarea></td> </tr> <tr> <td> <label> <input type="submit" name="enterReceipt" id="button" value="Enter Receipt" /> <input type="reset" name="reset" id="reset" value="Reset" /> </label> </td> </tr> </table> </form> <?php } ?>
-
My advice - make it easy to read and someone might try to help. It actually was a lot easier to read before WILDTEEN88 altered it. Now it's just one long continuous single line. Worse than ever. Well it helps if has line breaks in it. That way it wont display as one continuous line. I am just enforcing the rules.
-
if you are using a script which requires register_globals then either upgrade the script (if one is available) or look for similar script which does not require this setting.
-
[SOLVED] Records managment with functions
wildteen88 replied to SpireLink's topic in PHP Coding Help
Why are you retrieving the id from get in your function? The id already gets passed to the function from the code at the top of your script. Change your function to: // START DELETE RANK function remove ($id) { if (is_numeric($id) { include("../includes/config.php"); $sql= "DELETE FROM ranks WHERE rank_id=$id"; if(mysql_query($sql, $db)) { echo 'Record deleted'; } else { echo 'Unable to delete record!<br />Query: ' . $sql . '<br /><br />' . mysql_error($db); } } else { echo 'id must only be a number!'; } } // END DELETE RANK -
Try the following example code: <?php if(isset($_POST['submit'])) { $fr = range('a', 'e'); foreach($fr as $f) { foreach($_POST[$f] as $k => $v) { $field = trim($_POST[$f][$k]); if(!empty($field) && !is_numeric($field)) { $error = "numbers only"; break; } } if(isset($error)) break; } if(isset($error)) echo $error; } ?> <form method="post"> <?php for($x = 0; $x < 3; $x++) { $i = $x+1; echo @<<<EOF <p> <b>Line {$i}:</b><br /> <input type="text" size="2" maxlength="2" name="a[$x]" value="{$_POST['a'][$x]}"> <input type="text" size="2" maxlength="2" name="b[$x]" value="{$_POST['b'][$x]}"> <input type="text" size="2" maxlength="2" name="c[$x]" value="{$_POST['c'][$x]}"> <input type="text" size="2" maxlength="2" name="d[$x]" value="{$_POST['d'][$x]}"> <input type="text" size="2" maxlength="2" name="e[$x]" value="{$_POST['e'][$x]}"> </p> EOF; } ?> <input type="submit" name="submit" /> </form> Is that how your form is laid out and does the form checking work fine for you?
-
Ok, how is your form laid out. Post some example code for form here.
-
[SOLVED] Records managment with functions
wildteen88 replied to SpireLink's topic in PHP Coding Help
Oh, I see. Maybe because your link is base.php?crl=rank.php&do=delete&id= and not base.php?crl=rank.php&do=remove&id= -
The answer to that has already been posted in this topic, I believe.