wildteen88
Staff Alumni-
Posts
10,480 -
Joined
-
Last visited
Never
Everything posted by wildteen88
-
[SOLVED] $_POST is different from $_REQUEST
wildteen88 replied to Xeoncross's topic in PHP Coding Help
$_REQUEST and $_POST the same here! Array ( [txtbox] => foo [inputs] => Array ( [0] => b [1] => c ) [submit] => submit ) Array ( [txtbox] => foo [inputs] => Array ( [0] => b [1] => c ) [submit] => submit Not sure what you mean? Test code: <?php echo '<h1>$_REQUEST</h1> <pre>' . print_r($_REQUEST, true) . '</pre> <h1>$_POST</h1> <pre>' . print_r($_POST, true) . '</pre>'; ?> <form action="#" method="post"> Text: <input type="text" name="txtbox" /><br /> Inputs:<br /> <input type="checkbox" name="inputs[]" value="a" /> A<br /> <input type="checkbox" name="inputs[]" value="b" /> B<br /> <input type="checkbox" name="inputs[]" value="c" /> C<br /> Submit: <input type="submit" name="submit" value="submit" /> </form> -
It would be a good idea to turn display_errors on and up error_reporting to E_ALL in the php.ini. That way if there is any errors they be shown during run time rather than getting an unhelpful blank screen. But for now try removing these two lines: require_once('db_fns.php'); db_connect(); in user_auth_fns.php. You have already included db_fns.php in index.php. No need to include it again in user_auth_fns.php.
-
[SOLVED] trouble displaying tooltip containing an apostrophe
wildteen88 replied to Jago6060's topic in PHP Coding Help
use htmlentities with the ENT_QUOTES flag for the $db variable: echo "<td><center><img src=$d2 border=0 width='$width' height='$height' title='" . htmlentities($d3, ENT_QUOTES) . "'></center></td>"; -
Quick search on google returned this. Woking example included. Seems to be what you're after.
-
Switch misbehaving - driving me round the bend
wildteen88 replied to pbannist's topic in PHP Coding Help
This is why it is recommended to always format your code example: switch($_REQUEST["page"]) { case "about": $trg1 = "blank3"; $trg2 = "blank1"; $trg3 = "blank2"; $txt = "about.php"; break; // ... } -
When you go to View > Source in your browser do you see your PHP code? If so your server (I'm guessing you're using Apache) is not configured correctly. Could you explain how you have installed PHP and how you have set up your http server on your computer.
-
apache can't locate module
wildteen88 replied to codefreaq's topic in PHP Installation and Configuration
You need to use php5apache2_2.dll with Apache2.2.x php5apache2.dll is for Apache2.0.x only. Apache2.2.x has changed the way it handles modules and so Apache2.0.x modules are no longer compatible with Apache2.2.x -
Can't you just use file, set the variables you want and then unset the handler? Eg: $file = file('myfile.txt'); // set the variables for the first two lines. $line1 = $file[0]; $line2 = $file[1]; // remove handler. unset($file).
-
Its just basic html/css. For information search google for creating css based layouts.
-
Well that code has many HTML and and PHP syntax errors. You cannot place html code within php tags. All html must be placed within an echo statement. You are not concatenating strings properly either. Define is used incorrectly and you are using variables which don't exist, due to them being spelled incorrectly. Your DOCTYPE isn't closed properly due to using incorrect quotes. Corrected code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 strict//EN" "http://www.W3.org/TR/xhtmll/DTD/xhtmll1_strict.dtd"> <html> <head> <title>Hello World</title> </head> <body> <?php define ("WORLD_INFO",92897000); define ("SUN_INFO", 72000000); define ("MOON_INFO", 3456); $WorldInfo = 92897000; $SunInfo = 72000000; $MoonInfo = 3456; echo "<p>Hello", $WorldInfo."!<br /> "; echo "The $WorldInfo is", WORLD_INFO," miles from the $SunInfo. "; echo "Hello ", $SunInfo, "! "; echo "The $SunInfo's core temperature is approximately", SUN_INFO," degrees Fahrenheit. "; echo "Hello ", $MoonInfo, "! "; echo "The $MoonInfo is MOON_INFO, miles in diameter.</p>"; ?> </body> </html>
-
I Really Need Help With... Everything.
wildteen88 replied to AndyDS's topic in PHP Installation and Configuration
How is it corrupt? I don't understand. What are you doing? Have you any archive extracting software installed? Such as WinZip or WinRAR? -
Its now found a match for the selected ip(s) to delete as it is reporting it in the debug information: has issues_deleted.txt and banips.txt been updated now?
-
Umm... Change this line: <td align=\"center\" width=\"1%\" class=\"rowB\"><input name=\"todelete[$key]\" type=\"checkbox\" id=\"ids[]\" value=\"$value\" onClick=\"this.form.chkAll.checked=false; \"></td> in your form to this: <td align=\"center\" width=\"1%\" class=\"rowB\"><input name=\"todelete[$key]\" type=\"checkbox\" id=\"ids[]\" value=\"" . trim($value) . "\" onClick=\"this.form.chkAll.checked=false; \"></td> Also add the following lines: else { echo '</b> does not exist in <b>' . $file['banip'] . "</b></div>\n"; echo '<p><b>' . $ip2del . '</b> exists in <b>' . $banip_file . "</b><br />\n"; } After these lines: // write deleted banned ip to issues_deleted.txt fwrite($handle['issues'], $ip2del . "\n"); } In banip.php. Re-run banip.php again.
-
You probably mean object chaining (works only with php5 or greater), an example: <?php class text { public $str; function str($str) { $this->str = $str; return $this; } function bold() { $this->str = '<b>' . $this->str . '</b>'; return $this; } function size($size) { $this->str = '<font style="font-size: ' . $size . 'px;">' . $this->str . '</font>'; return $this; } function __destruct() { echo $this->str; } } $txt = 'hello world!'; $text = new text; $text->str($txt)->bold()->size(50); ?>
-
When you get to this screen: You see where it says (Databases)... in the drop down menu on the left you have to choose a database to use. When you select a database from that menu you should be shown a table editor on the right hand side/or an option to create a table if there is no tables currently available for that database.
-
use session_id() to grab the users unique sessions id.
-
I Really Need Help With... Everything.
wildteen88 replied to AndyDS's topic in PHP Installation and Configuration
When downloading mysql you should download the Windows ZIP/Setup.EXE (x86) option here. Once downloaded extract the zip and run setup.exe to install mysql. Follow the onscreen instructions for installation. NOTE: When you download mysql make sure you pick a mirror that is closest to you. For configuring Apache with PHP. Go to php.net and download the zipped binaries package (not the installer). Once downloaded extract the contents of the zip to C:\php. Open up Apache's configuration file (httpd.conf) and add the following lines at the end of the httpd.conf: LoadModule php5_module "C:/php/php5apache2_2.dll" PHPIniDir "C:/php/" AddType application/x-httpd-php .php Save the httpd.conf and restart Apache. Go to http://localhost/ and run a test php script with the following code in it: <?php phpinfo(); ?> You should see a page generated full of information about php and the servers setup. PHP is installed and Apache is configured correctly. Now go to C:\php and rename a file called php.ini-recommended to just php.ini. You can now configure PHP. Note: With PHP5 you must enable the mysql extension manually. Please read this FAQ thread. Only apply this step once you have MySQL setup. -
help with an "undefined varible" issue...
wildteen88 replied to gr8graphix's topic in PHP Coding Help
Is $file set before or after when the language file is included. The file that sets $file must be included before your include the language file. PHP does not back tract when calling variables. Variables must be set before that can be used. -
Messed up something on one of my site pages
wildteen88 replied to randalusa's topic in PHP Coding Help
Because you didn't use tags. The forum started parsing some parts of your html code. -
[SOLVED] Is it possibe to sum values while in loop?
wildteen88 replied to t_machine's topic in PHP Coding Help
Yes you can do that, your example is correct: $myarray = array(12, 6, 25, 2, 1, 15, 20); $gt10_total = 0; foreach($myarray as $val) { if($val >10) { $gt10_total += $val; } } echo 'Total (greater than 10): ' . $gt10_total; -
PHP installation help
wildteen88 replied to BlinkSumGreen's topic in PHP Installation and Configuration
What is your DocumentRoot set to? By default it'll be set to something like C:/Program Files/Apache Foundation/Apache2/htdocs (If you used the default installation path when installing Apache) you must place all your web related files in that folder. This is where Apache serves the files from when you got to localhost. Also remove all existing files in the htdocs folder. That way when you go to localhost you'll see a list of files and folders currently located in your DocumentRoot rather than a "It Works" page. If you are creating your php files in Notepad or similar editor make sure you set the File Type dropdown box to All Files. Otherwise the editor may add on .txt to the end of the file name. Which will result in your php file being named filename.php.txt and not filename.php. Windows has habit of hiding file extensions from filenames when viewing files in a folder in Windows Explorer. I always disable the option called "Hide extensions for known file types" in Tools > Folder Options > General -
Do you just have those two lines in your php.ini or is that just an excerpt from the php.ini? If its an excerpt than just change ./ to the full path of your php extension folder, eg if you installed PHP in C:/PHP then set extension_dir to: extension_dir = "C:/php/ext" Save the php.ini and PHP will now look for extensions located in C:/php/ext when you uncomment them in the php.ini.
-
Use $_SERVER['REQUEST_URI'] instead. This includes everything after the domain name, eg it'll return: foo/bar.php?woo=noo if the url is www.example.com/foo/bar.php?woo=noo
-
If want the days drop down menu to adapt so the correct number of days are displayed for the selected the month then you'll need to use javascript to repopulate the days list, or submit the form when the month drop down box has changed.
-
Not sure whats going on. Added in some echo's to see what is going on during script execution. <?php error_reporting(E_ALL); ini_set('display_errors', 'On'); $banip_file = '../banip/banip.txt'; $delip_file = '../banip/issues_deleted.txt'; if(file_exists($banip_file)) { echo $banip_file . ' exists'; if(is_readable($banip_file)) echo ' and is readable'; else die(' is not readable'); if(is_writable($banip_file)) echo ' and writable'; else die(' is not writable'); } else { die($banip_file . ' does not exist in ' . dirname(__FILE__)); } if(file_exists($delip_file)) { echo "\n<br />" . $delip_file . ' exists'; if(is_readable($delip_file)) echo ' and is readable'; else die(' is not readable'); if(is_writable($delip_file)) echo ' and writable'; else die(' is not writable'); } else { die($delip_file . ' does not exist in ' . dirname(__FILE__)); } echo "\n<p>Opening $banip_file<br />\nFile contents:\n"; $ban_ips = array_map('trim', file($banip_file)); echo '<pre>' . print_r($ban_ips, true) . "</pre></p>\n<p>Opening $delip_file<br />\nFile contents:\n"; $deleted_ips = file($delip_file); echo '<pre>' . print_r($deleted_ips, true) . "</pre></p>\n"; // [ DELETE ROUTINE ] // delete triggered if(isset($_POST['action']) && $_POST['action'] == "delete") { echo '<p>Entered delete routine<p><pre>' . print_r($_POST, true) . "</pre></p>\n"; // if the array isnt open proceed if(isset($_POST['todelete']) && !empty($_POST['todelete'])) { $arrToDelete = $_POST['todelete']; // assign checked items array to var echo '<p>Opening ' . $delip_file . '</p>'; $handle['issues'] = fopen($delip_file, "r+"); // assign a key and value to foreach($arrToDelete as $key => $ip2del) { if(in_array($ip2del, $ban_ips)) { echo '<p><b>' . $ip2del . '</b> exists in <b>' . $banip_file . "</b><br />\n"; echo 'Getting key from $ban_ips<br />'; $banip_key = array_keys($ban_ips, $ip2del); echo 'key retrived - Key:' . $banip_key[0] . "<br />\n"; // remove banned ip from ban_ips array unset($ban_ips[$banip_key[0]]); echo 'Deleted: ' . $ip2del; // write deleted banned ip to issues_deleted.txt fwrite($handle['issues'], $ip2del ."\n"); echo ' and has been written to ' . $delip_file . "</p>\n"; } } fclose($handle['issues']); echo "<p>Closed $delip_file</p>\n<p>Opening $banip_file</p>\n<p>"; // open banip.txt and remove existing ips $handle['banip'] = fopen($banip_file, "w"); // rewrite banip.txt with undeleted ips foreach($ban_ips as $ip) { echo "Writting $ip to $banip_file<br />\n"; fwrite($handle['banip'], $ip . "\n"); } fclose($handle['banip']); echo "</p>\n<p>Closing $banip_file</p>"; } } else { echo 'No post data!<pre>' . print_r($_POST, true) . '</pre>'; } ?>