Jump to content

tomb04

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Everything posted by tomb04

  1. I have been using a different css file to the one in the example (doh!) but it only works with the code that jl5501 gave. Also when using jl5501 code I can see the css file and clicking on it, in the view source. So not sure if I should put the status solve. Thanks for your help to both of you. <?php ini_set('display_errors','on'); error_reporting(E_ALL); require_once("ViewHelper.php"); ViewHelper::DisplayHeader("Blog index"); ?>
  2. I got this error. Is this what you were expecting? Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\xampp\htdocs\test\views\ViewHelper.php on line 11 line 11 is this code echo(" <link href="/stylesheet/main.css" media="all" rel="stylesheet" type="text/css"/>"); in the ViewHelper.php file Your code is placed like this... <?require_once("ViewHelper.php"); ViewHelper::DisplayHeader("Blog index");?> <?php ini_set('display_errors','on'); error_reporting(E_ALL); require_once("ViewHelper.php"); ViewHelper::DisplayHeader("Blog index"); ?> <h1>Blog index</h1> <p>You can <a href="index.php?cmd=BlogAddForm">add messages</a> !</p> <form action="index.php" method="post"> Search: <input name="search"> <input type="submit" value="Search!"> </form> <?php foreach($data as $messages) echo("<div class=\"message\"> <h2>{$messages['title']}</h2> <p>{$messages['message']}</p> <a href=\"index.php?cmd=BlogDelete&id={$message['id']}\">Delete this message</a> </div>"); //pagination probably need to go here ?> <?ViewHelper::DisplayFooter();?>
  3. I cannot see the include css in the view souce. So what is this telling me? I am working on a sample work, so according to the tutorial, the frames and backgound colour should be displaying. Also I should tell you that in views\index.php file the foreach loop shown in the tutorial had without the php tags. I put them there. Even without the php tags the css will still not show and also the contents will not show correctly. So that is why I had to put the tags there. So orginally the foreach code is like this... <? foreach($data as $message) echo("<div class=\"message\"> <h2>{$message['title']}</h2> <p>{$message['message']}</p> <a href=\"index.php?cmd=BlogDelete&id={$message['id']}\">Delete this message</a> </div>"); ?>
  4. Not sure what you mean. Are you asking the main index.php (that handles all user requests) or css file. By the way I don't have html file, but I assume I don't need that.
  5. I tried both of your codes and it didn't work.
  6. Hello, When I open the main index.php file in the browser, the stylesheet is not displaying at all. My header file is called ViewHelper.php and Footer file name is called index.php. Both of these files are in a subfolder called views. My stylesheet file name is main.css in the stylesheet folder. To clarify I have a main folder called test. Inside this folder I two subfolders as explained above. Where am I going wrong? Thanks in advance ViewHelper.php code... <?php class ViewHelper { static function DisplayHeader($pageTitle = "") { echo("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">"); echo("<html>"); echo(" <head>"); echo(" <title>{$pageTitle}</title>"); echo(" <link href="stylesheet/main.css" media="all" rel="stylesheet" type="text/css"/>"); echo(" </head>"); echo(" <body>"); } static function DisplayFooter() { echo(" </body>"); echo("</html>"); } } ?> index.php code... <?require_once("ViewHelper.php");?> <?ViewHelper::DisplayHeader("Blog index");?> <h1>Blog index</h1> <p>You can <a href="index.php?cmd=BlogAddForm">add messages</a> !</p> <form action="index.php" method="post"> Search: <input name="search"> <input type="submit" value="Search!"> </form> <?php foreach($data as $messages) echo("<div class=\"message\"> <h2>{$messages['title']}</h2> <p>{$messages['message']}</p> <a href=\"index.php?cmd=BlogDelete&id={$message['id']}\">Delete this message</a> </div>"); ?> <?ViewHelper::DisplayFooter();?>
  7. Request.php is showing blank page. I have created tables fields are id, title, message, date_added. But no there is no data in the field. So you reckon there is something wrong with Registry() class. class Registry { private static $values = array(); static function set($key, $val) { self::$values[$key] = $val; } static function get($key) { if(isset(self::$values[$key])) { return self::$values[$key]; } return null; } } I have ammended typo errors and the error is now showing... Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000] [1049] Unknown database 'messages'' in C:\xampp\htdocs\Manager.php:17 Stack trace: #0 C:\xampp\htdocs\Manager.php(17): PDO->__construct('mysql:host=loca...', 'root', 'thepassword') #1 C:\xampp\htdocs\Command_BlogIndex.php(9): Manager->__construct() #2 C:\xampp\htdocs\Command.php(14): Command_BlogIndex->doExecute(Object(Request)) #3 C:\xampp\htdocs\Controller.php(38): Command->execute(Object(Request)) #4 C:\xampp\htdocs\Controller.php(14): Controller->handleRequest() #5 C:\xampp\htdocs\index.php(5): Controller::run() #6 {main} thrown in C:\xampp\htdocs\Manager.php on line 17 Unknown database 'messages'' -- Is it saying that there is no database called messages? When I have created messages table in phpmyadmin. The sample I am working on is based on linux. Has this got anything to do with it.
  8. So what you saying I got get and set wrong. Manager.php The syntax is reading... function __construct() { $database_dsn = Registry::get("database_dsn"); $database_login = Registry::get("database_login"); $databse_password = Registry::get("database_password"); $pdo = new PDO($database_dsn, $databse_user, $database_password); self::$DB = $pdo; self::$DB->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXECPTION); } function prepareStatment($stmt_s) { if(isset(self::$stmts[$stmt_s])) { return self::$stmts[stmt_s]; } $stmt_handle = self::$DB->perpare($stmt_s); self::$stmts[$stmt_s] = $stmt_handle; return $stmt_handle; } and in the controller.php the sytax is read... function init() { Registry::set("database_dsn", "mysql:host=localhost;dbname=messages"); Registry::set("database_login", "root"); Registry::set("database_password", "thepassword"); }
  9. Actually I had the wrong password typed so pls disregard my previous notes. However I am having the following error... Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[28000] [1045] Access denied for user 'ODBC'@'localhost' (using password: NO)' in C:\xampp\htdocs\Manager.php:17 Stack trace: #0 C:\xampp\htdocs\Manager.php(17): PDO->__construct('mysql:host=loca...', NULL, NULL) #1 C:\xampp\htdocs\Command_BlogIndex.php(9): Manager->__construct() #2 C:\xampp\htdocs\Command.php(14): Command_BlogIndex->doExecute(Object(Request)) #3 C:\xampp\htdocs\Controller.php(38): Command->execute(Object(Request)) #4 C:\xampp\htdocs\Controller.php(14): Controller->handleRequest() #5 C:\xampp\htdocs\index.php(5): Controller::run() #6 {main} thrown in C:\xampp\htdocs\Manager.php on line 17
  10. For some reason the password has changed now I have to figure how reset password to do this. Can this be done. The password saved in config.inc.php is not the one. I went through cmd (C:\xampp\mysql\bin\mysql -u root -p). To find out about the password. I wonder if the following has anything to do it in the phpadmin (I don't think so)... Connection for controluser as defined in your configuration failed.
  11. gizmola, Do you mean through config.inc.php? I have already configured the username and password when I was reading through Peachpit Press PHP 6 and MySQL 5 for Dynamic Web Sites (which worked all well). If else were can you explain where and how? Thank you
  12. Hello, I am getting the following error message... Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: YES)' in C:\xampp\htdocs\Manager.php:23 Stack trace: #0 C:\xampp\htdocs\Manager.php(23): PDO->__construct('mysql:host=loca...', 'root', 'mypassword') #1 C:\xampp\htdocs\Command_BlogIndex.php(9): Manager->__construct() #2 C:\xampp\htdocs\Command.php(14): Command_BlogIndex->doExecute(Object(Request)) #3 C:\xampp\htdocs\Controller.php(38): Command->execute(Object(Request)) #4 C:\xampp\htdocs\Controller.php(14): Controller->handleRequest() #5 C:\xampp\htdocs\index.php(5): Controller::run() #6 {main} thrown in C:\xampp\htdocs\Manager.php on line 23 When I looked at Manager.php file, line 23 there is no typo error. Line 23 reads... $pdo = new PDO($database_dsn, $database_login, $database_password); This is straight copy and paste. I am working on sample only. Not a assignment. PDO is enabled, So this has lead me to think that I have not been able to contect to the mysql db. I am using xampp (see below the version I am using) on Windows 7 64bit which I don't think is the problem. I have attached the some of the files. I think I have identified where I need to change the characters in the database dsn, username and password? Thank you Tomb Apache Friends XAMPP (Basis Package) version 1.7.3 ###### + Apache 2.2.14 (IPV6 enabled) + MySQL 5.1.41 (Community Server) with PBXT engine 1.0.09-rc + PHP 5.3.1 (PEAR, Mail_Mime, MDB2, Zend) + Perl 5.10.1 (Bundle::Apache2, Apache2::Request, Bundle::Apache::ASP, Bundle::Email, Bundle::DBD::mysql, DBD::SQlite, Randy Kobes PPM) + XAMPP Control Version 2.5.8 (ApacheFriends Edition) + XAMPP CLI Bundle 1.6 + XAMPP Port Check 1.5 + XAMPP Security 1.1 + SQLite 2.8.17 + SQLite 3.6.20 + OpenSSL 0.9.8l + phpMyAdmin 3.2.4 + ADOdb v5.10 + FPDF v1.6 + Zend Framework 1.9.6 Minimal Package (via PEAR) + Mercury Mail Transport System v4.72 + msmtp 1.4.19 (a sendmail compatible SMTP client) + FileZilla FTP Server 0.9.33 + Webalizer 2.21-02 (with GeoIP lite) + apc 3.1.3p1 for PHP + eAccelerator 0.9.6-rc1 for PHP + Ming 0.4.3 for PHP + PDF with pdflib lite v7.0.4p4 for PHP + rar 2.0.0-dev for PHP + Xdebug 2.0.6-dev for PHP + libapreq2 v2.12 (mod_apreq2) for Apache [attachment deleted by admin]
×
×
  • 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.