Jump to content

Archadian

Members
  • Posts

    225
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Archadian's Achievements

Member

Member (2/5)

0

Reputation

  1. mysql_query and mysql_fetch_assoc...I could be wrong (highly doubt it) but these two functions pull data from the actual database. Why in God's name you are passing $this->connection in them is beyond me. Maybe reading up on the functions would help a little. mysql_query: http://us2.php.net/mysql_query mysql_fetch_assoc: http://us2.php.net/mysql_fetch_assoc
  2. I believe the best way to upload multiple files is to use arrays. Try this: http://www.phpeasystep.com/workshopview.php?id=2 Change $HTTP_VARS_FILES to $_FILES[]...i don't think HTTP_VARS_FILES works anymore in the newer PHP versions
  3. Thanks that worked but why wouldn't this work? private $host = 'localhost'; private $user = 'user'; private $pass = 'pass'; private $result = ''; private $db = ''; public function __construct($host, $user, $pass, $result, $db) { If $host = localhost, $user = username, $pass = password is being set why wouldn't it work for the __contruct()? Or is that just for the other variables in the other functions of the class? Thanks.
  4. On my homepage i am getting this: here is the class.php section that is causing it: class Mysql { private $host = 'localhost'; private $user = 'user'; private $pass = 'pass'; private $result = ''; private $db = ''; public function __construct($host, $user, $pass, $result, $db) { $this->host = $host; $this->user = $user; $this->pass = $pass; $this->result = $result; $this->db = $db; } public function cabal() { $filename = dirname(__FILE__); if (preg_match('/wwwroot/', $filename)) { $this->db = 'cabalweb'; } $conn = @mysql_connect($this->host, $this->user, $this->pass); $this->result = @mysql_select_db($this->db); if(!$conn || !$this->result) { die('Please check the Cabal connection.'); } return $this->result; } public function forums() { $filename = dirname(__FILE__); if (preg_match('/forums/', $filename)) { $this->db = 'c_forums'; } $conn = @mysql_connect($this->host, $this->user, $this->pass); $this->result = @mysql_select_db($this->db); if(!$conn || !$this->result) { die('Please check the Forums connection.'); } return $this->result; } } and here is the lines around line 38 on index.php: require('include/class.php'); $db =& new Mysql(); //line 38 $db->cabal(); It was working fine, I did not change anything and all of a sudden it stops working and gives me the warning messages. Any ideas on what this could be or what is wrong in the code? Thanks.
  5. fwrite() will create the file if it does not exist in that directory and it will input the contents in that file for you.
  6. Using ProjectFear's code you can also store it in cookie: $query = mysql_query("SELECT * FROM users") or die(mysql_error()); echo <<<html <table border="0"> <tr> <td><b>Username:</b></td> </tr> html; while($r = mysql_fetch_assoc($query)){ echo <<<html setcookie('user', $r['username'], time() + (seconds # here), "/", websiteurl); $username = $_COOKIE['user']; <tr> <td>{$username}</td> </tr> html; } echo "</table>"; By using a cookie you can use $_COOKIE['user'] on any page you like without having to set the username over and over again. I hope this helps.
  7. <?php session_start(); define('WEB', true); echo "<head>"; echo "<title>The Cabal Online Guide</title>"; echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"include/cabal.css\">"; echo "</head>"; include('include/class.php'); $db =& new Mysql(); $db->cabal(); if (isset($_POST['submit']) && isset($_POST['username']) && isset($_POST['password'])) { login(); } if ($_GET['action'] == 'logout') { logout(); } include('include/func.php'); echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" background=\"#000000\">"; echo "<div width = \"100%\">"; echo "<tr>"; echo "<td width=\"29\" height=\"62\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" background=\"" . $mtbl['topleft'] . "\"></td>"; echo "<td width=\"940\" height=\"62\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" background=\"" . $mtbl['topmid'] . "\"></td>"; echo "<td width=\"29\" height=\"62\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" background=\"" . $mtbl['topright'] . "\"></td>"; echo "</tr>"; echo "</div>"; echo "<div width = \"100%\">"; echo "<tr>"; echo "<td width=\"27\" height=\"500\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" background=\"" . $mtbl['left'] . "\"></td>"; echo "<td width=\"940\" height=\"500\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">"; //echo "<div>{CONTENT}</div>"; echo "</td>"; echo "<td width=\"27\" height=\"500\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" background=\"" . $mtbl['right'] . "\"></td>"; echo "</tr>"; echo "</div>"; echo "<div width = \"100%\">"; echo "<tr>"; echo "<td width=\"27\" height=\"24\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" background=\"" . $mtbl['botleft'] . "\"></td>"; echo "<td width=\"960\" height=\"24\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" background=\"" . $mtbl['botmid'] . "\"></td>"; echo "<td width=\"27\" height=\"24\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" background=\"" . $mtbl['botright'] . "\"></td>"; echo "</tr>"; echo "</div>"; echo "</table>"; ?>
  8. I was just wondering why isn't my table going the full width and length of the webpage? Yes i know this is a noob question but still any help will be appreciated. Thanks here is the link: http://phpweb.no-ip.com/index.php
  9. I was just wondering why isn't my table going the full width and length of the webpage? Thanks here is the link: http://phpweb.no-ip.com/index.php
  10. nice. thx for the reply and the help
  11. Ok 8 lines up from the bottom of index.php i put this: $content = $get_page->parse(); echo 'This is the content: ' . $content; and when it echoed $content it was right...the content got passed in $get_page->parse();. So whats going on that would cause nothing to show up on the links in the first post i made? I have revised the login link so you can see what its doing now. Thanks
  12. I changed it but still nothing. Thanks for the reply
  13. Sorry in advance for the long post: The contents is not getting passed here are the websites: http://phpweb.no-ip.com/index.php?page=login http://phpweb.no-ip.com/index.php Here is the code: index.php $temp_dir = dirname(__FILE__) . '\\templates\\'; $get_page =& new Template(); $page = $_GET['page']; if (!isset($_GET['page'])) { $page = $temp_dir . "index.html"; } else { $page = $temp_dir . $page . '.html'; } $get_page->set_template($page); if ($page === 'login.html') { // Just the login template (login.html) $get_page->page('TITLE', "Login"); $get_page->page('T_USERNAME', "Username:"); $get_page->page('T_PASSWORD', "Password:"); $get_page->page('B_LOGIN', "Login"); } $content = $get_page->parse(); $page_title = "Title Here"; $interface =& new Template(); $interface->set_template($page); $interface->page('CONTENT', $content); $interface->page('PAGE_TITLE', $page_title); print $interface->parse(); class.php class template { protected $template; //The template name protected $temp_string; //The template string will be stored here protected $prefix = "{"; //The variable prefix character. protected $suffix = "}"; //The variable suffix character. protected $items = array(); //The values of your variables will be stored here public function set_template($filename) { $this->template = $filename; } public function page($name, $value) { //storing our variable and its value into an array $this->items[$name] = $value; } public function load_file() { //saving its contents into a string $this->temp_string = file_get_contents($this->template); } public function replace_items() { //The foreach loop is very useful when we want to loop through //associative arrays. foreach($this->items as $assoc => $value) { //appending the variable prefixes to match. ex: {VAR_NAME} $name = $this->prefix.$assoc.$this->suffix; //replacing every instance of the variable with it's corresponding value. //so {VAR_NAME} becomes "this is my variable" $this->temp_string = str_replace($name, $value, $this->temp_string); } } public function parse() { //loading the file $this->load_file(); //setting the variables $this->replace_items(); //outputting the newly parsed template return $this->temp_string; } } If the index.html and login.html code is needed just let me know. Anyways...the contents is not getting passed as you have seen in the web links i provided above. What am i doing wrong? If anyone can help with this problem i HIGHLY appreciate it. Thanks.
×
×
  • 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.