Jump to content

A2enMOD

New Members
  • Posts

    8
  • Joined

  • Last visited

A2enMOD's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. So I dont understand what you mean?
  2. Hi guys, I am having trouble with the following code that I put together. It is not getting any data from the DB, can you see if I have made any errors in my syntax? // DATABASE FUNCTION //Search database for pages matching the current // page and display the title, description and keywords $page = isset($_GET['page']) ? $_GET['page'] : 'home'; if ($mysqli->connect_errno) { printf("Connect failed: %s\n", $mysqli->connect_error); exit(); } if($stmt = $mysqli->prepare("SELECT * FROM url WHERE page=? LIMIT 1")) { $stmt -> bind_param("s",$page); $stmt -> execute(); $sql = $stmt; if ($sql->num_rows > 0) { while ($row = $sql->fetch_object()) { $title = $row->title; $description = $row->descr; $keywords = $row->keywords; } } else { $title = 'Set Default Title'; $description = 'Set Default Description'; $keywords = 'Set Default Keywords'; $stmt -> close(); } } $mysqli -> close();
  3. Yep you were right on the mark there. I changed it to: define('BASE', 'http://'.$_SERVER['HTTP_HOST'] . "/");
  4. The problem I had with your solution is this: it output: http://mysite.com/mysite.com/privacy
  5. Hi, I have taken some advice on the use of constants from this forum and wish to move a step forward: Presently I have "href" declared like the following: <a href="<?php echo $base_url; ?>privacy" class="link">Privacy Policy</a> But now I have a constant in the config file like this: define('BASE', $_SERVER['HTTP_HOST'] . "/"); So my question is, how to I replace the $base:url; with the Constant. I hope that makes sense....
  6. Ok that's great let me give that a try and report back
  7. Hi, This little man in the back of my head keeps telling me that I am not using PHP efficiently enough when trying to tell code where the location of things are. I will give you a few examples: 1. For the start I created a variable to deal with the URL of the site like below: $base_url = "http://www.mysite.com/"; unitl recently I have learned a different way which I will be implementing using the define CONSTANT method like below: define('BASE', 'www.mysite.com'); The reason I want to use that is because I am putting together a function that will detect my server name like the example below: $host = $_SERVER['SERVER_NAME']; if($host == 'domain.com) { define('BASE', '$host'); } else { define('BASE', '$host'); } Firstly is the syntax correct above? 2. Images - when I check out the source of my site the location of the images are displayed like so: <img src="http://sitenorhost/images/home/image.png" title="random image" alt="random image" class="img"> but on other sites I have visited the display output is like this: <img src="/img/graphics/navigation/noTab/ns-logo.png" alt="Network Solutions" border="0"> Why is this, what have I done wrong. Of course from a PHP point of view I want a robust dynamic solution to locate the necessary content. This also goes for links like below: This is how I want it: <li><a href="/main/mypage.php">Mypage</a></li> but my ouput is like this: <li><a href="http://www.mysite.com/main/mypage.php">Mypage</a></li> this is because am using the variable $base_url . I believe it is not good to use the methods above and would like some sound detailed advice on how to make this work for me. I am a leaner at PHP and I have got to this stage so far. Thanks in advance
  8. Hi, I have read numerous posts in this forum regarding clean URLs but its either I am not understanding or none of the posts relate to my situation. First my code .htaccess: RewriteRule ^(([^/]+/)*[^/.]+)$ index.php?page=$1 [L] My folder structure: Content - this folder contains all of the called pages index.php - all pages are called into this file using GET The result of the above in URLs is a follows: http://www.example.com/about The problem I have is when I want to call a second level for example: http://www.example.com/about/profiles So just to recap all of the physical files are located in the Folder "content", though I believe from what I have been reading this is irrelevant. Or do I have to create separate folders for each? Primarily this is a mod_rewrite question so any help would be great
×
×
  • 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.