wildteen88
Staff Alumni-
Posts
10,480 -
Joined
-
Last visited
Never
Everything posted by wildteen88
-
Your code appears to be relying on register_globals in order to function correctly. registert_globals has long been depreciated and has been disabled by default for along time. It is now due to be removed as of PHP6 Also when handling settings avoid using functions such as session_register, session_is_registered etc. These are also depreciated. Instead you should use the $_SESSION superglobal variable instead, examples file1.php <?php // start the session session_start(); // create a session variable $_SESSION['my_var'] = 'hello world'; ?> <a href="file2.php">Next</a> file2.php <?php // start the session session_start(); // check that our session variable 'my_var' exists if(isset($_SESSION['my_var'])) { echo $_SESSION['my_var']; } else { echo "the session variable 'my_var' does not exist!"; } ?>
-
I noticed I had a slight typo, the line: <?php include("templates/{$page}body-tpl.php"); ?> should of been <?php include("templates/{$page}-tpl.php"); ?>
-
I guess your variable is called $page? If so then you'll do: <?php include("templates/head-tag1-tpl.php"); ?> <?php include("templates/{$page}-meta-tpl.php"); ?> <?php include("templates/head-tag2-tpl.php"); ?> <?php include("templates/header-tpl.php"); ?> <?php include("templates/{$page}body-tpl.php"); ?> <?php include("templates/footer-tpl.php"); ?> Or <?php include("templates/head-tag1-tpl.php"); ?> <?php include('templates/'.$page.'-meta-tpl.php'); ?> <?php include("templates/head-tag2-tpl.php"); ?> <?php include("templates/header-tpl.php"); ?> <?php include('templates/'.$page.'body-tpl.php'); ?> <?php include("templates/footer-tpl.php"); ?>
-
403 Permission error accesing index.php (Apache 2.2)
wildteen88 replied to eM's topic in PHP Installation and Configuration
Seems you haven't configured Apache correctly. Post you httpd.conf configuration here (including your virtualhosts configuration) -
htmlentities or htmlspecialchars
-
Computer Name links to web root on server
wildteen88 replied to stevesimo's topic in Apache HTTP Server
You'll want to look into virtual hosts for this. http://httpd.apache.org/docs/2.2/vhosts/ -
Shorten and dispaly text from database row
wildteen88 replied to ow-design's topic in PHP Coding Help
Sorry, line 27 should of been while($row = mysql_fetch_assoc($result)) EDIT: you query should be // get the latest 3 news feeds $sql = 'SELECT title from table ORDER by id DESC LIMIT 3'; -
$nums = array(0, 1, 7, 20, 40, 55); foreach($nums as $key => $num) { // check that numb is dividable by 20 if(num >= 20 && ($num%20 == 0)) $num -= 20; else $num = floor($num/20) * 20; $rounded[] = $num; } echo '<pre>' . print_r($rounded, true) . '</pre>';
-
Shorten and dispaly text from database row
wildteen88 replied to ow-design's topic in PHP Coding Help
To get the latestest 3 rows from the database you'll apply LIMIT 3 to your query, eg function ShortenText($text, $chars=80) { $text = substr($text,0,$chars); $text = substr($text,0,strrpos($text,' ')); $text .= '...'; return $text; } // get the latest 3 news feeds $sql = 'SELECT news_title_field from news_table ORDER by news_id_field DESC LIMIT 3'; $result = mysql_query($sql); // display news while($row = mysql_num_assoc($result)) { // display shortened news title, returns the first 30 chars. echo shortText($row['news_title_field'], 30); } NOTE: I made $chars an optional parameter for your function. -
[SOLVED] switch() - deafult case: break;
wildteen88 replied to soycharliente's topic in PHP Coding Help
You don't have to specify a default case no, you can leave this out if you so wish to. The default case will be run if none of the cases matched the argument. -
Ensure display_errors is enabled too: error_reporting(E_ALL); ini_set('display_errors', 'On');
-
Then post the error(s) you are getting. Posting "it errors out" isn't helpful
-
[SOLVED] file_exists only works in root dir
wildteen88 replied to cganim8's topic in PHP Coding Help
$_SERVER['DOCUMENT_ROOT'] holds the absolute path to your sites root folder, eg /home/yoursite.com/htdocs/ define('BASE', $_SERVER['DOCUMENT_ROOT']); if (file_exists(BASE."/images/image.jpg") { echo '<image src="/images/image.jpg" />'; } -
I remember this, I provided the function. I think what you need to do is construct your session better. Rather than do: $_SESSION[ 'MEBL1' ] $_SESSION[ 'MEBLab1' ] $_SESSION[ 'MEBL1' ] $_SESSION[ 'ME'PageID' ] $_SESSION[ 'MEBL2' ] $_SESSION[ 'MEBLab2' ] $_SESSION[ 'MEBL2' ] $_SESSION[ 'ME'PageID' ] etc I'd construct it like so: $_SESSION['ME'][1]['BL'] $_SESSION['ME'][1]['BLab'] $_SESSION['ME'][1]['BL'] $_SESSION['ME'][1]['PageID'] $_SESSION['ME'][2]['BL'] $_SESSION['ME'][2]['BLab'] $_SESSION['ME'][2]['BL'] $_SESSION['ME'][2]['PageID'] etc Which makes it a multiple dimensional array. This will make it a lot more easier to work with as you can then easily loop through your session data, eg <?php // dummy session data $_SESSION['ME'][1]['BL'] = 'ButtonID 1'; $_SESSION['ME'][1]['BLab'] = 'Lab 1'; $_SESSION['ME'][1]['PageID'] = 'PageID 1'; $_SESSION['ME'][2]['BL'] = 'ButtonID 2'; $_SESSION['ME'][2]['BLab'] = 'Lab 2'; $_SESSION['ME'][2]['PageID'] = 'PageID 2'; $_SESSION['SW'][1]['BL'] = 'ButtonID 4'; $_SESSION['SW'][1]['BLab'] = 'Lab 4'; $_SESSION['SW'][1]['PageID'] = 'PageID 4'; $_SESSION['SW'][2]['BL'] = 'ButtonID 5'; $_SESSION['SW'][2]['BLab'] = 'Lab 5'; $_SESSION['SW'][2]['PageID'] = 'PageID 5'; // departments $depts = array('MA','PM','EE', 'ME', 'OE', 'SW', 'SE', 'ST'); // loops through departments foreach($depts as $dept ) { // check to see if the department is in the array if(isset($_SESSION[$dept]) && is_array($_SESSION[$dept])) { echo '<p>Depertment: <b>'.$dept.'</b><br />'; // loop through the fields foreach($_SESSION[$dept] as $fid => $field_data) { echo '<b>Field #'.$fid.'</b><br />'; echo $field_data['BL'].'<br />'; echo $field_data['BLab'].'<br />'; echo $field_data['PageID'].'<br />'; echo '<br />'; } echo '</p><hr />'; } } ?>
-
Localhost Shows Raw PHP Code - WTF?
wildteen88 replied to pricelessproperty's topic in PHP Installation and Configuration
You should save all your PHP scripts and its resources (images/css/javascript etc) in C:/WAMP/www <-- this is where WAMP loads your files from when you access http://localhost Also ensure you're saving your PHP scripts as a .php file and not .html. By default PHP code will only be parsed within .php files, however this can be changed. -
[SOLVED] Preg_split - Filtering the "." from strings
wildteen88 replied to transparencia's topic in PHP Coding Help
You should be able to group those into one character set: "/[\s\.-_,?!]/" -
So you have: require('../forums/config.php'); In members.php which is located in root/home/modules in that case you're path should be ../../forums/config.php ../ goes one level higher up the directory tree. The first ../ goes out of the modules/ folder, the second ../ goes out of the home/ folder. However my suggestion should work though.
-
You'll have to look into some pagination tutorials for that.
-
use require($_SERVER['DOCUMENT_ROOT'].'/forums/config.php');
-
You'll need to initiate $count outside of your while loop: f(mysql_num_rows($hent)) { $count = 0; // initiate counter while ($vis = mysql_fetch_array($hent)) {
-
[SOLVED] Preg_split - Filtering the "." from strings
wildteen88 replied to transparencia's topic in PHP Coding Help
Umm, I just said. You escape it like so: \. -
That is not a MySQL error but a PHP error. Post your PHP code
-
[SOLVED] Preg_split - Filtering the "." from strings
wildteen88 replied to transparencia's topic in PHP Coding Help
With preg_split you'll have to escape it, eg: \. The period (.) in regex has a special meaning, escaping it tells the PCRE engine to treat it as literal. -
[SOLVED] Basic CSS: Body Margins (stuck with a 1px margin somehow)
wildteen88 replied to webmaster1's topic in CSS Help
The gap can be remove by typing your HTML in one line, like so <table bgcolor="#00CC66" border="0" cellpadding="0" cellspacing="0"> <td><img src="images/dummy.jpg" border="0"></td> </table> However yes you should not use tables for layouts. -
[SOLVED] form not showing up in IE and google chrome?
wildteen88 replied to liamloveslearning's topic in PHP Coding Help
It could be to do with you not closing the comment tag within your <style></style> tags here You do not need wrap CSS within comments.