Jump to content

wildteen88

Staff Alumni
  • Posts

    10,480
  • Joined

  • Last visited

    Never

Everything posted by wildteen88

  1. 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!"; } ?>
  2. 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"); ?>
  3. 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"); ?>
  4. Seems you haven't configured Apache correctly. Post you httpd.conf configuration here (including your virtualhosts configuration)
  5. htmlentities or htmlspecialchars
  6. You'll want to look into virtual hosts for this. http://httpd.apache.org/docs/2.2/vhosts/
  7. 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';
  8. $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>';
  9. 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.
  10. 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.
  11. Ensure display_errors is enabled too: error_reporting(E_ALL); ini_set('display_errors', 'On');
  12. Then post the error(s) you are getting. Posting "it errors out" isn't helpful
  13. $_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" />'; }
  14. 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 />'; } } ?>
  15. 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.
  16. You should be able to group those into one character set: "/[\s\.-_,?!]/"
  17. 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.
  18. You'll have to look into some pagination tutorials for that.
  19. use require($_SERVER['DOCUMENT_ROOT'].'/forums/config.php');
  20. 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)) {
  21. Umm, I just said. You escape it like so: \.
  22. wildteen88

    Syntax

    That is not a MySQL error but a PHP error. Post your PHP code
  23. 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.
  24. 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.
  25. 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.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.