Jump to content
Killersites Forums


  • Posts

  • Joined

  • Last visited

Everything posted by jp612

  1. Oops, I didn't turn on the rewrite module in WAMP. My problem is fixed now.
  2. Hi, Just started trying some MVC organisation with PHP but I think theres something wrong with my .htaccess since i get this error: "The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, admin@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log." My htaccess looks like this: RewriteEngine On RewriteBase /test_mvc/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [QSA.L] I also have these files and classes: index.php <?php // define site url define("BASE_PATH", "http://localhost"); // define our base path $path = "/my_mvc"; // Take the initial PATH. $url = $_SERVER['REQUEST_URI']; $url = str_replace($path,"",$url); //make array from rest or url $array_tmp_uri = preg_split('[\\/]',$url -1, PREG_SPLIT_NO_EMPTY); //Here, we will define what is what in the URL $array_uri['controller'] = $array_tmp_uri[0]; //a class $array_uri['method'] = $array_tmp_uri[1]; //a função $array_uri['var'] = $array_tmp_uri[2]; //a variavel //Load base require_once("application/application.php"); //Load controller object $application = new Application($array_uri); $application = new Application($array_uri['controller']); ?> application class <?php class Application { var $uri; var $model; function __construct($uri) { $this->uri = $uri; } function loadController($class) { $file = "application/controller/".$this->uri['controller'].".php"; if(!file_exists($file)) die(); require_once($file); $controller = new $class(); if(method_exists($controller, $this->uri['method'])) { $controller->{$this->uri['method']}($this->uri['var']); }else{ $controller->index(); } } function loadView($view,$vars="") { if(is_array($vars) && count($vars) > 0) extract($vars, EXTR_PREFIX_SAME, "wddx"); require_once('view/'.$view.'.php'); } function loadModel($model) { require_once('model/'.$model.'php'); $this->$model = new $model; } } ?> the class that loads views. <?php class Blog extends Application { function __construct() { $this->loadModel('model_blog'); } function index() { $articels = $this->model_blog->select(); $data['articles'] = $articles; $this->loadView('view_blog',$data); } function add($title="") { $data['title'] = $title; $this->loadView('view_blog_add',$data); } } ?> I have hardly any idea of whats going on here. Im just learning how to get the controller to pass link the right view. Thanks
  3. except the title thing. Since the isset $GET['page] failed. Which makes sense since the get page stuff is called later on in the document?
  4. Ahh i saw my error. Used your code now.
  5. ohh yes, I have to use a for loop not just a if statement for the title thing. Now all of a sudden i cant use variables i defined in another function, this is my functons.php which i included into my index: <?php // Navbar top. Use array to add content. function get_mainmenu_array() { $menu = array( "1" => array ( "title" => 'Home', "page" => 'home', "url" => "../content/home.php", "desc_title" => "Web Design Services - Affordable Web And Graphic Design Services | Debes Design" ), "2" => array ( "title" => "Our Services", "page" => 'services', "url" => "../content/services.php", "desc_title" => "Our Services - Static Websites, Dynamic Websites And Content Management Systems | Debes Design" ), "3" => array ( "title" => 'Portfolio', "page" => 'portfolio', "url" => "../content/portfolio.php", "desc_title" => "Our Portfolio - Our Recent Web Design Work | Debes Design" ), "4" => array ( "title" => 'About', "page" => 'about', "url" => "../content/about.php", "desc_title" => "About Us | Debes Design" ), "5" => array ( "title" => 'Contact', "page" => 'contact', "url" => "../content/contact.php", "desc_title" => "Contact Us - Get A Free Quote About Any Design Work | Debes Design" ) ); } function get_mainmenu(){ echo "<ul>"; for ($i = 1; $i <= count($menu); $i++) { echo '<li><a href="index.php?page=' . $menu[$i]['page'] . '">' . $menu[$i]['title'] .'</a></li>'; }; echo "</ul>"; } // dynamic title function html_title() { if(isset($GET['page'])) { $title = 0; $page = $GET['page']; for ($i = 1; $i <= count($menu); $i++) { if($page == $menu[$i]['page'] ) { $title = $i; }else{ echo "Error! No Page"; } } if($title != 0) { echo $menu[$title]['desc_title']; }else{ echo "Error! Title = 0"; } }else{ echo "Error! GET page not set"; } } //Show content works with menu, put in content function get_content() { if(isset($GET['page'])) { if(file_exists("includes/views/" . htmlentities($GET['page'], ENT_QUOTES). ".php")) { include("includes/views/" . htmlentities($_GET['page'], ENT_QUOTES) . ".php"); }else{ include("includes/views/home.php"); } }else{ include("includes/views/home.php"); } } ?> Problem is when the first for loop playes i get the error that the function $menu is undefined. Which is my array at the top. Why? I packed the array into a function and before i just loaded it like so in the title before the second loop: get_mainmenu_array();
  6. since my most of my stuff to do with the $GET['page'] function and the loops variale $i is called later in the document (and has to be) does that mean my function that puts in the title at the top of the html page isnt going to work since almost everything used in it will be defined later? if(isset($GET['page'])) { if($GET['page'] == $menu[$i]['page'] ) { echo $menu[$i]['page']; }else{ die("Error!"); } }else{ die("Error!"); } ?>
  7. ok i made a function containing the script. ahh i seem to have more problems. What I want to create a dynamic html page title which grabs stuff from the array depending on which page is included. So i created this <?php if(isset($GET['page'])) { if($GET['page'] == $menu[$i]['page'] ) { echo $menu[$i]['page']; }else{ echo "Error!"; } }else{ echo "Error!"; } } ?> however the isset already fails since the array is loaded later in the document (I also have no idea if the above script will work). So i figured that i'd give my function some parameters so i can only load the array at the start. But how do i put a large chunk of code in a parameter? ( I cant pack it all into a variable.)
  8. So if I want to put my array and loop into a class along with the second item. Would i do it something like this? <?php class header_menu { var $menu = array( "1" => array ( "title" => 'Home', "page" => 'home', "url" => "../content/home.php" ), "2" => array ( "title" => "Our Services", "page" => 'services', "url" => "../content/services.php" ), "3" => array ( "title" => 'Portfolio', "page" => 'portfolio', "url" => "../content/portfolio.php" ), "4" => array ( "title" => 'About', "page" => 'about', "url" => "../content/about.php" ), "5" => array ( "title" => 'Contact', "page" => 'contact', "url" => "../content/contact.php" ) ); function menu_loop() { for ($i = 1; $i <= count($menu); $i++) { echo '<li><a href="index.php?page=' . $menu[$i]['page'] . '">' . $menu[$i]['title'] .'</a></li>'; }; } function get_main_menu() { echo "<ul>"; echo menu_loop(); echo "</ul>"; } } ?> I dont know how to get further than this. I also dont know where to use any $this-> type stuff. Since all variables are already defined do i still have to inistiate it? or is using a class a bit over the top for this??
  9. I have actually stopped using Dreamweaver for several reasons: 1. Its ridiculously expensive 2. Its not even that great (in relation to price) 3. It doesn't run natively on Linux (probably wont be your problem) Some features like the FTP site synchronization and upload don't work well. When i try to upload sites (10+mb) the thing takes all night and constantly has some issue. On top of all of that the thing is pretty flimsy and isn't even a proper integrated development environment. PHP programming is about as complex as it gets. It has no support and debugging tools for Java, C++ etc. Its way over priced in my opinion. However I have never (and don't) work with WYSIWYG editors etc so I don't know what it offers there. All i ask for is a tool that helps organise the site with a folder explorer thing built in. Has some code hinting (as you type), possibly some site to server sync stuff. And a pleasant interface (since I spend alot of time working with it). Have a look at some open source integrated development environment like eclipse. Eclipse offers plugins for web development (HTML, CSS, PHP, Javascript). It has templates, code hinting etc and is free. However it has no WYSIWYG editor. Heres a list of IDE's http://en.wikipedia.org/wiki/Comparison_of_integrated_development_environments IDE's can be a bit overwhelming since they are mainly for Java, C, Ruby, Perl, PHP etc. But i find eclipse quite easy. They even have a special PHP and web developer edition of it: http://www.eclipse.org/pdt/downloads/ But at the end of the day notepad is just fine too. I started out using it
  10. Cool! I finally get loops now. that opened a lot of php doors for me. BTW: I also had a look at the killerphp OOP PHP tutorial. I just have one question about that and functions in general if i define a function,constant,class in a different file i.e class_lib.php or function_lib.php. If i then call it in another file thats in another folder or on the same level how does it (or does it) know that that function, constant, class was defined in some file in my website folder somewhere?
  11. Thanks. I still have a bit of trouble understanding loops. So the $i is a variable that defines the starting value and by using $i++ makes it go up by one number each time the loop is run. The count function is able to count my array items which are numbers. Is all this correct? But why is it $i <= count($menu)?? why could the above method be a security risk? Is it like the $GET function that presents a security risk because everything has to be put into the url so its possible to manipulate it? also how does the htmlentites know which include file to include??
  12. I have created my menu using a multi dimensional array like so: <?php $menu = array( "1" => array ( "title" => Home, "page" => home, "url" => "../content/home.php" ), "2" => array ( "title" => "Our Services", "page" => services, "url" => "../content/services.php" ), "3" => array ( "title" => Portfolio, "page" => portfolio, "url" => "../content/portfolio.php" ), "4" => array ( "title" => About, "page" => about, "url" => "../content/about.php" ), "5" => array ( "title" => Contact, "page" => contact, "url" => "../content/contact.php" ) ); ?> for this format: <li> <a href='index.php?page='<?php $menu['1'] "page" ?>'></a><?php $menu['1'] "title" ?></li> how do i make it a loop that changes the number next to $menu accordingly? then in my content file i have to make it include the content file <?php if($_GET['page'] == "services") { include("includes/design.html"); }else if($_GET['page'] == "about") { include("includes/graphic.html"); }else if($_GET['page'] == "contact") { include("includes/contact.php"); }else if($_GET['page'] == "portfolio") { include("includes/about.html"); }else{ include("includes/home.php"); } ?> Is there a better way to do it rather than using if , elseif? I know its possible to do something thats just 1 line long but i cant remember it.
  13. Sounds like a good idea. I had a look at the paypal security center and apparently they have alot of buyer and seller dispute assistance etc. So for legal concerns i guess they can help out. I but I think billing in 1/3 is good idea especially if its the first time working with the client. Thanks!
  14. I just got a client who is based overseas. Whats the best method of billing? I like Paypal is that a good idea? Also if I charge upfront, what gives the client piece of mind? How can they protect their initial deposit and be sure that I don't run off with it? on the flip side, if I do some work for a client how can I be sure that I will receive my payment? I obviously don't want to have to charge every 3 minutes. Since a email quote/agreement can be a legally binding contract. Can that help protect me if the client is in a different country? So in essence whats a good quoting and billing strategy in this scenario? Thanks
  15. Yeah I think your right. I just like to keep my localhost similar to my production server. oh well the header function does the job well. However since alot of my config files in zencart are different to the localhost files I wonder how i will keep them in sync. I have always used dreamweaver to keep my sites in sync over ftp. But now i need to exclude some files from synchronization. I also dont want to have to manually backup and dump the database all the time. Is there something that can help me with this??
  16. Yeah I was afraid that may be the case. although the chdir function didnt work and i used: chdir("zc-gj/"); I have never used that function before so i was interested to see how it works. Does using a header or any re-direct function that redirects to the zc-gj folder slow down the loading time of the site? The whole thing I'm trying to do seems a bit inefficient.
  17. No errors I have already given that a go. when i go to www.gamecat.co.nz/zc-gj it works fine. Its not even working on my local host when i simulate the situation. right now on godaddy it gives an error which i have already fixed. But godaddy hasnt registred the changes again even though i have cleared cache etc. I know that because it creates the same error even if i change the include code to echo "hello"; code it still gives the function include fail error which i have actually fixed. But on the local host it gives a blank screen now and i have all error reporting on.
  18. I recently shifted a ZenCart site to a godaddy shared hosting server. However it requires me to put the whole site inside a their html folder. However I want to put my ZenCart Folder called "zc-gj" into there with all the stuff inside. But of course it doesnt find the index.php file thats in zc-gj folder. So i thought I would create a index.php in the html folder and write: <?php include("zc-gj/index.php"); ?> but all it does is give a blank screen I've tried it on my localhost and it also gives a blank screen there. I have also tried chdir,require & chroot functions but they all give a blank screen. why doesn't this work?
  19. I have just created my design website and I have used google adwords to advertise since I had a $100 voucher which came with my domain name. I've let it run for 2 days now on a small budget of $8.00 per day. Which gets me around 19 clicks per day. Now I'm totally new to web advertising but I'm starting to wonder why I'm not getting any enquiries through my site. Is 19 clicks even a lot? Also, should I do put a rough pricing list on my site, since I see a lot of other web design sites selling packages and stuff. But I don't get how its possible. I mean a quote for a site depends a lot on what the client wants done specifically. What are your experiences on this? btw my site is www.debesdesign.com
  20. I have actually contacted Godaddy (my hosting) to ask them if there was something on their end but they said it would be all my browsers fault. I have told my Firefox to never cache sites but it still occasionally happens. Its quite strange because the changes usually register automatically after a while and I often check after reboots (coincidentally). I dont think its the browser because when I clear cache on my localhost test server the changes always register. Its only when I check online.
  21. This is really starting to bug me.... on my localhost when i make large css changes the changes register straight away after clearing cache. However on my www site when I upload the changes to the server it never registers the changes even after I clear cache. Usually after some time period when I check the changes do register. I have noticed this with every browser especially IE. Which does it all the time. Other browsers only do it sometimes. Why does this happen?
  22. The wordpress is much easier to setup and understand. I haven't used Joomla! before but I think its similar to Drupal which is one I use. I use wordpress for simpler sites, but for sites that are more complex I would use something else like Drupal. Wordpress does have a lot of good plugins and themes, if your not into making those yourself. A CMS that is more complex is usually more flexible.
  23. Oh i see. So my command didn't really do anything accept always echo the command. Oh well I put in this: <?php if(isset($_GET['page']) == FALSE || $_GET['page'] == 'home') echo "<link href=\"css/home.css\" rel=\"stylesheet\" type=\"text/css\" />"; ?> which basically says: if the $_GET['page'] function isn't being executed OR if it is and its getting the page 'home'. Then echo my css link? It works, great!
  24. For some strange reason one of my php if statements isnt working for opera. Which is odd since the browser has nothing to do with the php right? this is my index.php: <?php session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> <?php if($_GET['page'] == "design") { echo "Website Design Services - Affordable Website Design | Debes Design"; }else if($_GET['page'] == "graphic") { echo "Graphic Design Services - Affordable Graphic Website Design | Debes Design"; }else if($_GET['page'] == "contact") { echo "Contact Us - Place An Enquiry About A Website | Debes Design"; }else if($_GET['page'] == "about") { echo "About Us"; }else{ echo "Web Design Services - Effective And Affordable Websites | Debes Design"; } ?> </title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="description" content="We provide affordable web and graphic design solutions for our customers - Debes Design" /> <meta name="keywords" content="Debes Design,website,business,webpage,design,services,graphic,CMS,content management system,affordable,effective" /> <link href="css/style.css" rel="stylesheet" type="text/css" /> <?php $include_home = "include(\"includes/home.php\")"; if($include_home) echo "<link href=\"css/home.css\" rel=\"stylesheet\" type=\"text/css\" />"; ?> <!--[if lt IE 8]> <link rel="stylesheet" type="text/css" href="css/ie7.css" /> <![endif]--> </head> <body> <div id="page-wrapper"> <div id="header-wrapper"> <div id="header"> <div id="logo"> <a href="index.php?page=home"><img src="images/debes-logo.png" width="210" height="88" alt="Debes Web Design Logo"/></a> </div> <div id="navbar"> <ul> <li> <a href='index.php?page=home'>Home</a> </li> <li> <a href='index.php?page=design'>Web Design</a> </li> <li> <a href='index.php?page=graphic'>Graphic Design</a> </li> <li> <a href='index.php?page=contact'>Contact</a> </li> <!-- <li> <a href='index.php?page=about'>About</a> </li> --> </ul> </div> </div> </div> <div id="content-push"> <?php if($_GET['page'] == "design") { include("includes/design.html"); }else if($_GET['page'] == "graphic") { include("includes/graphic.html"); }else if($_GET['page'] == "contact") { include("includes/contact.php"); }else if($_GET['page'] == "about") { include("includes/about.html"); }else if($_GET['page'] == "redirect") { include("includes/re-direct.php"); }else{ include("includes/home.php"); } ?> </div> <div id="push"></div> </div> <div id="footer"> <div id="footer-content"> <a href="https://www.paypal.com/verified/pal=info@debesdesign.com"><img id="paypal" src="images/icons/Paypal-Verified-CC.png" alt="Paypal Verified" /></a> <p>© debesdesign.com 2010</p> </div> </div> </body> </html> What i have is a css file that i only want attached when my home.php or default index.php include is included. So I created a php statement in my index.php: <?php $include_home = "include(\"includes/home.php\")"; if($include_home) echo "<link href=\"css/home.css\" rel=\"stylesheet\" type=\"text/css\" />"; ?> It does the trick in firefox and chrome and IE (I think) but not in Opera. In Opera the home.css is always attached which creates difficulties. Should i be doing this another way?
  • Create New...