wildteen88
Staff Alumni-
Posts
10,480 -
Joined
-
Last visited
Never
Everything posted by wildteen88
-
PHP installation help
wildteen88 replied to BlinkSumGreen's topic in PHP Installation and Configuration
That error basically means something else is running on port 80 and so Apache cannot listen on that port. Without a port Apache cannot run. Apache uses port 80 by default for TCP/IP requests. Either stop the application/service that is using port 80 or configure Apache to use a different port such as port 8080 by changing the Listen directive in the httpd.conf from: Listen 80 to Listen 8080 Save httpd.conf and restart Apache. Open your web browser and go to http://localhost:8080/ -
Oh sorry I thought you took a screenshot from an existing page. For an ajax tutorial your can go to ajaxfreaks.com there is a very good beginner tutorial there.
-
[SOLVED] Session variable inside IF statement
wildteen88 replied to markkanning's topic in PHP Coding Help
You'll only know if you test it. I don't know what you doing. I just assumed $submit variable refers to your form's submit button, make sure you have a submit button in your form named submit in order for the if/else statement to work. The problem is to do with the argument in your if statement. Not to do with your session variables. -
[SOLVED] locating a table to input information to
wildteen88 replied to adam291086's topic in PHP Coding Help
Have you add mysql_error as i suggested earlier (above) to this line: mysql_select_db("albums",$con) or die('Error finding database table'); Adding mysql_error to the die function will give you more information. -
[SOLVED] Session variable inside IF statement
wildteen88 replied to markkanning's topic in PHP Coding Help
Where does $submit come from? Is this the name of your submit button? If it is it should be $_POST['submit'] or $_GET['submit'] depending on your forms submit method (this is defined in the form tag). <?php session_start(); include "./header.php"; if(isset($_POST['submit'])) { $_SESSION['page'] = "Thank You!"; //RESULT OF SUBMITTED FORM HERE } else { $_SESSION['page'] = "Send Us Your Event"; //PAGE WITH FORM HERE } include "./footer.php"; ?> -
[SOLVED] locating a table to input information to
wildteen88 replied to adam291086's topic in PHP Coding Help
Add mysql_errror into the die function: mysql_select_db("albums",$con) or die('Error finding database: '. mysql_error()); Have you established a connection to mysql yet? I do not see a call to mysql_connect. -
This is most probably down to ajax or the content under the box is an (i)frame. Using FF you can tell if it is a (i)frame or not if you right click on the content there'll be a This Frame context menu available. If its not a frame then it is most probably done by ajax or just plain javascript which is hiding and showing certain divs. Have a look in the source code.
-
PHP not recognising new version of MYSQL
wildteen88 replied to rn14's topic in PHP Installation and Configuration
Have you restarted Apache? Also did you remove all files left over from the previous MySQL installation. I am not sure what you mean by (the highlighted text): -
How to deal with HTML code in PHP to overcome alignment issues
wildteen88 replied to jwhite68's topic in HTML Help
Try: div.offer1 { padding: 0 30px 30px 30px; overflow: auto; width: 874px; border: 1px solid #DDDDDD; margin-top: 10px; background-color: #F4F3EE; } h3 { margin: 15px 0 15px -15px; padding: 0; } <div class="offer1"> <h3>Summary</h3> <?php echo $summary; ?> <h3>Description</h3> <?php echo $desc; ?> </div> Also !important only works outside of CSS element values not within CSS values. -
How to deal with HTML code in PHP to overcome alignment issues
wildteen88 replied to jwhite68's topic in HTML Help
Wrapp <?=$desc?> in a span and apply 15px left padding to that rather than your <p> tags. That all text will align 15px in from the left regardless whether text in paragraph tags or not. -
list can only be used in conjunction with arrays. if you want to return multiple variables from your function you're best of of storing all the variables to be returned into an array, then use list out side of your function: eg: function myfunc() { // vars to be returned $var1 = 'foo'; $var2 = 'bar'; // set up an array to store all variables to be returned. $return = array($var1, $var2); // return the array of variables return $return; // ALTERNATIVELY you could do: // return array($var1, $var2); // instead. } // gets vars out of array of variables return from myfunc list(var1, $var2) = myfunc(); // use variables echo $var1; echo $var2;
-
Add ../banip/ before any instance of banip.txt or issues_deleted.txt in the file and fopen functions.
-
What version of Apache do you have installed? Note: PHP comes with there Apache modules these are following: php5apache.dll - for use with Apache1.3.x php5apache2.dll - for use with Apache2.0.x php5apache2_2.dll = for use with Apache2.2.x You must use the correct Apache module for the version of Apache you have installed.
-
Elementary question undefined index/variable
wildteen88 replied to Lassie's topic in PHP Coding Help
The undefined index notices are normally caused by not checking whether a user defined variable exists or not, such as $_GET, $_POST and $_COOKIE vars. Consider this code: <?php $name = $_POST['name']; if($name) { echo 'Your Name is: '. $name; } ?> <form action="#" method="post"> Name: <input type="text" name="name"><br> <input type="submit" value="Post my name"> </form> That code is fine to use. However if you run the script without submitting the form you'll get an Undefined index 'name' notice message displayed. This is because PHP is assigning the $name variable to the value of $_POST['name']. But we haven't submitted the form yet! So $_POST['name'] wont exist. If you call any variable within your code PHP is expecting that variable exists. What you should do to prevent notices is to first verify that variable exists before using it. PHP has handy function for this called isset. In stead of doing the following: $name = $_POST['name']; if($name) You should do: if(isset($_POST['name']) { $name = $_POST['name']; Now if you run the script again without submitting the form there will be no notice message. -
Why do you need to convert the html back into bbcode? It is best to convert the bbcode into html when it is needed, eg when being retrieved from the database and not when you insert it in to the database.
-
Is display_errors turned on in the php.ini? display_errors must be enabled in order for errors to be shown during runtime.
-
Have a read of the documentation for the following functions: opendir readdir Over at php.net. You'll find example code there (look in the user comments at the bottom of the page too).
-
Look into sessions. Sessions are only valid while the user is on the site. As soon as you leave the site your session will be invalid. Sessions are the same as cookies except all data is stored in a session file on the server rather than on the users computer.
-
Yes it would! What is the path to banip.txt and the path to the script you place my code in? Both files will have to be in the same folder as each other or you'll need to specify the path to banip.txt (and issues_deleted.txt) in my script for the file() and fopen() functions. Also with that example data my code works no problem. The issue is to do with the script not finding banip.txt if its in a different folder than the script.
-
I see, banip.txt does not hold just the ip address but other info. My code still works fine! Could you also post example data for banip.txt too.
-
What's happening when you run the script? Is it adding anything to any files. Need more info. Also could you post some code for your form. So I can understand how $_POST is formatted. I'm assuming your using checkboxs in your form which is named todelete[] for choosing which banned ips to delete from banip.txt. And that each ip address is one its own line in banip.txt
-
Problem generating code with PHP printing to multiple lines
wildteen88 replied to seventhwiskey's topic in PHP Coding Help
prehaps use trim on the $array variables: $cname . '.addDisabledDates("' . trim($array[$i]) . '","' . trim($array[$i+1]) . '"); -
There are a few problems in your code. Try: <?php $ban_ips = array_map('trim', file('banip.txt')); $deleted_ips = file('issues_deleted.txt'); // [ DELETE ROUTINE ] // delete triggered if($_POST['action'] == "delete") { // if the array isnt open proceed if(isset($_POST['todelete']) && !empty($_POST['todelete'])) { $arrToDelete = $_POST['todelete']; // assign checked items array to var $handle['issues'] = fopen("issues_deleted.txt", "r+"); // assign a key and value to foreach($arrToDelete as $key => $ip2del) { if(in_array($ip2del, $ban_ips)) { $banip_key = array_keys($ban_ips, $ip2del); // remove banned ip from ban_ips array unset($ban_ips[$banip_key[0]]); print('Deleted: ' . $ip2del . "<br />\n"); // write deleted banned ip to issues_deleted.txt fwrite($handle['issues'], $ip2del ."\n"); } } fclose($handle['issues']); // open banip.txt and remove existing ips $handle['banip'] = fopen("banip.txt", "w"); // rewrite banip.txt with undeleted ips foreach($ban_ips as $ip) { fwrite($handle['banip'], $ip . "\n"); } fclose($handle['banip']); } } ?>
-
You've removed the else statment from the if on this block of code: // 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']]++; } It should be: // 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; } Without the else newer IP's wont be added to current list. Only existing ips will be updated! <?php if(file_exists('counter.php')) { if(is_readable('counter.php') && is_writable('counter.php')) { // Open the file and read the details into an array $data = file('counter.php'); // remove first line from file, this is the PHP line to stop people from viewing contact.php array_shift($data); // 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)) { 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'); // shtop people from viewing the file. fwrite($handle, "<?php die('You are not allowed to view this page'); ?>\n"); foreach($new_data as $ip => $hits) { $data = $ip . '|' . $hits . "\n"; fwrite($handle, $data); } fclose($handle); } else { echo 'counter.php is either not writable or readable!'; } } else { echo 'counter.php does not exists'; } ?>
-
I dunno! My code doesn't add the line: <?php die('You are not allowed to view this page'); ?>| As for recording multiple ips it should do. Try hard coding a value for $_SERVER['REMOTE_ADDR'] variable, eg: add $_SERVER['REMOTE_ADDR'] = 'dummyip; at the top of the script. Run the script then remove that line re run script and you should see your ip address logged as well as your hard coded one.