Currently all of the jokes and the details for that section are stored in a MYSQL database and the information is called depending on the id no. (i.e view.php?id=2) However since I started this the number of referrals from search engines, particularly google has dropped to none.
So what I want to do is have the pages created using fopen() meaning that the pages are all there for search engines to trawl through.
At the moment my code is:
<?php
# phpBB necessities
define('IN_PHPBB', true);
$phpbb_root_path = '/home/www/teenonyM/forum/';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//
# If user is not logged in redirect
if ( !$userdata['session_logged_in'] )
{
redirect(append_sid("login.$phpEx?redirect=/forum/content/jokes/submit.$phpEx"));
}
# Include Error handling and connection file
include('/home/www/teenonyM/scripts/database_functions.php');
# Open MYSQL connection
OpenConnection();
# Assign all variables required
$date = date("Y-m-d");
$user_ip = $_SERVER["REMOTE_ADDR"];
$author = $userdata['username'];
$authorid = $userdata['user_id'];
# Check that the submit button has been pressed and the user has not executed script directly
if ($submit == "Submit")
{
#Assign the query a variable so that it can be parsed by the custom error handler
$query = "INSERT INTO phpbb_content_jokes
(title,content,author,author_id,date,warning,user_ip) values
('$title', '$content', '$author', '$authorid', '$date', '$warning', '$user_ip')";
@mysql_query($query, $connection)
or ThrowError("error with query: " . mysql_error() . "\n\nQuery: " . $query);
$result = mysql_query($query);
while( $row = mysql_fetch_array($result) )
{
$title = $row['title'];
$content = $row['content'];
$author = $row['author'];
$author_id = $row['author_id'];
$date = $row['date'];
}
$lastentry = mysql_insert_id();
$filename = $lastentry.".html";
$html = '<html>
<head>
<title>'.
$title
.'</title>
<link rel="stylesheet" href="http://www.gravity.me.uk/subSilver.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div align="center">
<p><b><a href="/forum/index.php">Home</a></b></p>
<p><b>'.
$title
.'</body>
</html>';
$fp = fopen( "$filename","w" );
fwrite($fp,
$html);
fclose( $fp );
?>
Note: not all of the necessary HTML is in place as I think it a better idea to get it working on a smaller scale first.
When the script is executed I receive the error
Parse error: parse error in /home/www/teenonyM/scripts/wip/test.php on line 83
Normally I can see obvious errors on lines such as missing semicolons, however in this case line 83 if the final line containing just '?>' Therefore I'm assuming the error lies several lines ahead, and the PHP manual doesn't particularly cover file writing in great detail. So my questions are...
1 What is causing the parse error?
2 Am I using the variables rihgt inside the HTML?
- Anthony