Hi, hoping someone can help, think it’s something small. I’m trying to make a friendly URL. I’ve added the Rewrite Rule to my .htaccess as below:
Options +FollowSymLinks
Options +Indexes
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^\\.]+)$ $1.php [NC,L]
RewriteEngine On
RewriteRule pass/(.*)$ pass.php?section=$1
However, the page is appearing with the text but the data from the database is not displayed at all, the only text displayed is ‘Your name is’ and ‘Your date of birth is’.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<?php
include_once('connectionpass.php');
$section = $_GET['section']; // get var from URL
$result = mysql_query("SELECT * FROM birthdays WHERE section = $section");
$row = mysql_fetch_array($result);
?>
Your name is,
<?php echo $row['firstname'];?>
<?php echo $row['lastname'];?>.
Your date of birth is <?php echo $row['birthday'];?>.
</body>
</html>
My SQL is below:
-- phpMyAdmin SQL Dump
-- version 3.2.5
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Nov 26, 2010 at 12:27 AM
-- Server version: 5.1.44
-- PHP Version: 5.2.13
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
--
-- Database: `newdb`
--
-- --------------------------------------------------------
--
-- Table structure for table `birthdays`
--
CREATE TABLE `birthdays` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`section` varchar(30) NOT NULL,
`firstname` varchar(30) NOT NULL,
`lastname` varchar(30) NOT NULL,
`birthday` varchar(30) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
--
-- Dumping data for table `birthdays`
--
INSERT INTO `birthdays` VALUES(2, 'about-us', 'Kriss', 'Kerr', '19/11/1990');
INSERT INTO `birthdays` VALUES(3, 'hello', 'Marc', 'Batty', '19/11/1990');
I’m sure it’s something so simple that I have missed or something.