View Full Version : Output Results On To Two Pages
Jamie
January 23rd, 2005, 15:11
The scripts results are output to index.php but I would also like them to be output on another page.
Doing that is the easy part, the hard part is that I want the script to create the page and name it based on 'ID'. So if the ID is output by the database as 12, the script will create a page named 12.php and output the results on that page.
Would anyone care to point me in the right direction, examples or external links would be great.
Alex
January 23rd, 2005, 15:53
[syntax:d0e76fd5af="php"]
<?php
$c = mysql_connect("localhost","","");
if (!$c) die("Crap.. not again " . mysql_error());
mysql_select_db(blogn,$c) or die(" Grrrr " . mysql_error());
$get = mysql_query("SELECT * FROM entries") or die("Oh man..." . mysql_error());
while($row = mysql_fetch_row($get)) {
$content ="
<div class=\"name\">$row[1]</div><br /> \n
<div class=\"email\">$row[2]</div><br /> \n
<div class=\"subject\">$row[3]</div><br /> \n
<div class=\"comments\">$row[4]</div><br /> \n
";
$all ="
<html>
<head><title></title></head>
<body>
$content
</body>
</html>
";
$filename = $row[0].".php";
if($createfile = fopen($filename,"a")) {
fwrite($createfile, $all);
}
}
echo "New files created";
?>
[/syntax:d0e76fd5af]
this will create files for all the ids in the database.
sonicgroup
January 23rd, 2005, 15:55
Why are you creating pages? For permalinks? If so, look into using mod_rewrite to rewrite (ex.) 12.php to index.php?id=12. It'll still look like a real page, but you save the space and the time/effort of using the filesystem functions to create files.
If you really want to create the files, then you need to investigate the fopen(), fwrite() and fclose() functions. The tricky part comes when you want to include PHP in one of those pages. If you need to include PHP, then I would suggest creating a template file and using the file_get_contents() function to get all of the stuff in the template file into a variable without executing it. You can also experiment with str_replace() and using template variables (i.e. {CONTENT}) to replace the text from your database into the template file.
Jamie
January 23rd, 2005, 16:09
This is looking complicated. I will have a look at your example Alex in a few minutes.
Dave, the reason I am wanting to create pages is as follows:
The original output of the form will go on to index.php as that is my main blog page.
Under each blog entry however are View Comments and Post Comments links.
These links are to go to ID.php, the first blog entry will be displayed on view_comments.php and then when somebody posts a comment it will be displayed under the blog entry on view_comments.php
Jamie
January 23rd, 2005, 16:14
Alex, could you confirm to me where your above example is to be placed? Is it supposed to overwrite the whole of submit_entry.php?
Alex
January 23rd, 2005, 16:55
OK, I see what you're trying to do
store_message.php
[syntax:d9279d4fab="php"]
<?php
ob_start();
$c = mysql_connect("localhost","","");
if (!$c) die("Crap.. not again " . mysql_error());
mysql_select_db(blogn,$c) or die(" Grrrr " . mysql_error());
if($_POST["name"] || $_POST["comments"] ) {
$name = $_POST["name"];
$email = $_POST["email"];
$subject = $_POST["subject"];
$comments = $_POST["comments"];
$store = "INSERT INTO entries (name,email,subject,comments) VALUES ('$name', '$email', '$subject', '$comments')";
mysql_query($store) or die("This isn't working well..." . mysql_error());
//Now to make the new file:
$content ="
<div class=\"name\">$name</div><br /> \n
<div class=\"email\">$email</div><br /> \n
<div class=\"subject\">$subject</div><br /> \n
<div class=\"comments\">$comments</div><br /> \n
";
$get = mysql_query("SELECT id FROM entries") or die("Oh man..." . mysql_error());
while($row = mysql_fetch_row($get)){
$id = end($row);
}
$filename = $id.".php";
if($createfile = fopen($filename,"a")) {
fwrite($createfile, $content);
}
echo "New file created...<br /><br />";
echo "and success! Data added to database! Page refreshing now...";
header('Refresh: 3; URL=display_message.php');
}
?>
[/syntax:d9279d4fab]
This will add the data to the MySql table and create a file named by the ID with the the contents (name,email,subject,comments)
Jamie
January 23rd, 2005, 17:21
Alex, that is fantastic, just what I wanted! Thanks very much. Just one thing, how would I set it to make the file in a different directory rather than the same diretory that store_entry.php is in?
Jamie
January 23rd, 2005, 17:56
I have been looking at it more closely and to be able to store the files in a seperate directory I assume it is the fopen funtion that does it? I have read about it on php.net and had a few goes but keep getting "no such file or directory" errors.
sonicgroup
January 23rd, 2005, 18:21
Change the $filename variable to have a directory in front of the filename. Make sure that the directory you are wanting to write in is CHMOD at least 755 (777 would be best).
Jamie
January 23rd, 2005, 18:28
I might be misunderstanding you here Dave because I am getting a parse error. Here is what I have now
[syntax:bcdb64831d="php"]
$filename = /archive/$id.".php";
[/syntax:bcdb64831d]
I am wanting the new files to be placed in a folder called archive that is in my root folder.
sonicgroup
January 23rd, 2005, 19:27
Your syntax is incorrect. The directory needs to be part of the string, so you need to concatenate it like so:
[syntax:18227bf0f9="php"]
$filename = '/archive/'.$id.'.php';
[/syntax:18227bf0f9]
Jamie
January 23rd, 2005, 19:35
Thanks Dave, but, before I implement it there is something else. I am getting myself it an a right old pickle.
I have incorporated the output of the 2nd page in to the template. Now, the 2nd page is there to serve two purposes, 1. to display the blog entry and any comments 2. to provide a form to allow people to add comments.
Everything is fine, until I add the form, where suddenly parse errors are on the menu.
[syntax:a473d40691="php"]
<div class=\"content\">
<div>
<h2 class=\"blogh\">$subject</h2> \n
<span class=\"bydate\">Posted By <span class=\"name\"><a href=\"mailto:$email\" class=\"mailblog\">$name</a> On $endate</span></span><p /> \n
<div class=\"comments\">$comments</div><p /> \n
<a href=\"#comment\">Leave a Comment</a><p class=\"break\" />
<form method="post" action="store_comment.php">
Name*<br />
<input type="text" name="namecom" value="Jamie Harrop"><p />
Email*<br />
<input type="text" name="emailcom" value="jamieharrop14@hotmail.com"><p />
<input type="hidden" name="subjectcom" value="<?php $hidden_sub = Re: $subject; echo $hidden_sub; ?>"><p />
Entry*<br />
<textarea cols="50" rows="12" name="commentcom">Message</textarea><p />
<input type="text" name="endatecom" value="<?php $posted_on = date("M j Y"); echo $posted_on; ?>"><p />
<input type="reset" value="Clear"> <input type="submit" value="Post Entry">
</form>
</div> </div>
[/syntax:a473d40691]
That is what I have, when I fill in the 1st form to create a blog entry I receive:
Parse error: parse error in c:\documents and settings\jamie\desktop\jamie harrop\admin\store_entry.php on line 47
Line 47 is the line:
<form method="post" action="store_comment.php">
Jamie
January 23rd, 2005, 19:42
I have implemented the code for the archive folder but I am still getting the errors.
Warning: fopen("/archive/38.php", "a") - No such file or directory in c:\documents and settings\jamie\desktop\jamie harrop\admin\store_entry.php on line 124
New file created...
and success! Data added to database! Page refreshing now...
I am assuming that because this is on my local machine, running apache, there is no need to chmod? If I do need to chmod, how do I go about it on my local machine?
Marble
January 23rd, 2005, 19:52
What OS are you using (*edit* der - he's got a c:\ drive...)? cli syntax goes: chmod ### file (or dir..) so for example to make a directory world (everyone) read/write/execute:
chmod 777 directory_name
but this is for Unix/Linux OS's
If you are using windows then you will have to set permissions (right click directory - then set for anonymous user (guest?) full permissions...)
Jamie
January 23rd, 2005, 20:01
I have followed instructions on several sites and in windows help but the tabs etc that are supposed to be there are not there, so, for now, I will trust that it will work once uploaded to the server.
So, the second form problem, that seems to be the last piece of the jigsaw, lets hope somebody knows what is wrong.
sonicgroup
January 23rd, 2005, 20:40
I'm guessing that you are assigning all of what you posted to a variable? If so, you need to escape the quote marks with slashes ( \ ) as the previous attributes have in order to not cause parse errors.
Jamie
January 23rd, 2005, 20:48
I have done that, now I am getting an error referring to another line...
Parse error: parse error in c:\documents and settings\jamie\desktop\jamie harrop\admin\43.php on line 87
Line 87 is:
<li><a href=\"http://www.wy-media.co.uk\">WY Media</a> <br />Jamie's web development company</li>
There is nothing wrong with that from what I can see. Any ideas? Dave/Alex, would you be able to take a closer look for me if I PM you the files?
Jamie
January 23rd, 2005, 22:00
Update of the PHP aspects of the three files.
submit_entry.php - This contains the form to submit a top level blog entry
[syntax:3ab597d89f="php"]
<form method="post" action="store_entry.php">
Name*<br />
<input type="text" name="name" value="Jamie Harrop"><p />
Email*<br />
<input type="text" name="email" value="jamieharrop14@hotmail.com"><p />
Subject*<br />
<input type="text" name="subject" size="50" value="Subject"><p />
Entry*<br />
<textarea cols="50" rows="12" name="comments">Message</textarea><p />
<input type="text" name="endate" value="<?php $posted_on = date("M j Y"); echo $posted_on; ?>"><p />
<input type="reset" value="Clear"> <input type="submit" value="Post Entry">
</form>
[/syntax:3ab597d89f]
store_entry.php - This processes the storing of the top level blog entry in to the database. It also takes care of the output of the sub level comments. It contains the code to add the top level entry information, any sub level comments and also a form to submit sub level comments.
[syntax:3ab597d89f="php"]
<?php
ob_start();
$c = mysql_connect("localhost","","");
if (!$c) die("Crap.. not again " . mysql_error());
mysql_select_db(blogn,$c) or die(" Grrrr " . mysql_error());
if($_POST["name"] || $_POST["comments"] ) {
$name = $_POST["name"];
$email = $_POST["email"];
$subject = $_POST["subject"];
$comments = $_POST["comments"];
$endate = $_POST["endate"];
$store = "INSERT INTO entries (name,email,subject,comments,endate) VALUES ('$name', '$email', '$subject', '$comments', '$endate')";
mysql_query($store) or die("This isn't working well..." . mysql_error());
//Now to make the new file:
$content ="
//ALL THE TOP HALF OF THE TEMPLATE IS HERE
//START OF DISPLAYING TOP LEVEL BLOG ENTRY
<div>
<h2 class=\"blogh\">$subject</h2> \n
<span class=\"bydate\">Posted By <span class=\"name\"><a href=\"mailto:$email\" class=\"mailblog\">$name</a> On $endate</span></span><p /> \n
<div class=\"comments\">$comments</div><p /> \n
<a href=\"#comment\">Leave a Comment</a><p class=\"break\" />
//END DISPLAYING TOP LEVEL BLOG ENTRY
//START DISPLAYING FORM FOR SUB LEVEL COMMENTS
<form method=\"post\" action=\"store_entry_comments.php\">
Name*<br />
<input type=\"text\" name=\"name\" value=\"Jamie Harrop\"><p />
Email*<br />
<input type=\"text\" name=\"email\" value=\"jamieharrop14@hotmail.com\"><p />
Subject*<br />
<input type=\"text\" name=\"subject\" size=\"50\" value=\"Subject\"><p />
Entry*<br />
<textarea cols=\"50\" rows=\"12\" name=\"comments\">Message</textarea><p />
<input type=\"text\" name=\"endate\" value=\"<?php $posted_on = date(\"M j Y\"); echo $posted_on; ?>\"><p />
<input type=\"reset\" value=\"Clear\"> <input type=\"submit\" value=\"Post Entry\">
</form>
//END DISPLAYING FORM FOR SUB LEVEL COMMENTS
</div> </div>
//BOTTOM HALF OF TEMPLATE HERE
</body>
</html>
";
$get = mysql_query("SELECT id FROM entries") or die("Oh man..." . mysql_error());
while($row = mysql_fetch_row($get)){
$id = end($row);
}
$filename = $id.".php";
if($createfile = fopen($filename,"a")) {
fwrite($createfile, $content);
}
echo "
//TOP HALF OF TEMPLATE HERE
<div>
New file created...<br /><br />
And success! Data added to database! Page refreshing now...
</div> </div>
//BOTTOM HALF OF TEMPLATE HERE
";
header('Refresh: 3; URL=/index.php');
}
?>
[/syntax:3ab597d89f]
index.php - this is the main blog page, displays all top level blog entries
[syntax:3ab597d89f="php"]
<?php
$c = mysql_connect("localhost","","");
if (!$c) die("Crap.. not again " . mysql_error());
mysql_select_db(blogn,$c) or die(" Grrrr " . mysql_error());
$get = mysql_query("SELECT * FROM entries ORDER BY id DESC") or die("Mmm pie:" . mysql_error());
echo "
<div>
";
while ($row = mysql_fetch_row($get)) {
echo "
<h2 class=\"blogh\">$row[3]</h2> \n
<span class=\"bydate\">Posted By <span class=\"name\"><a href=\"mailto:$row[2]\" class=\"mailblog\">$row[1]</a> On $row[5]</span></span><p /> \n
<div class=\"comments\">$row[4]</div><p /> \n
<a href=\"/archives/$row[0].php\">Show Comments</a> | <a href=\"/archives/$row[0].php#comment\">Leave a Comment</a><p class=\"break\" />
";
}
echo "</div>";
?>
[/syntax:3ab597d89f]
sonicgroup
January 23rd, 2005, 22:23
I'm not seeing any of what you posted in your previous post in any of those code sections. Where does that appear? Is it within a PHP section?
Jamie
January 24th, 2005, 11:40
Sorry I should have told you where that bit is, it is in store_entry.php under the form for the sub comments, where it says //BOTTOM HALF OF TEMPLATE HERE
Alex
January 24th, 2005, 13:52
Is "store_entry_comments.php" supposed to be "store_message.php"?
What SQL did you use to make the table?
Jamie
January 24th, 2005, 17:46
store_entry_comments.php is the php script that processes the form that is used to submit comments. I haven't created this script yet but this shouldn't make a difference because I cannot get on to store_entry.php to be able to fill in the comments form.
As far as I can remember the sql below is what I used to make the table.
CREATE TABLE entries (
id int(9) NOT NULL auto_increment,
name TEXT NOT NULL,
email TEXT NOT NULL,
subject TEXT NOT NULL,
comments TEXT NOT NULL,
dateen TEXT NOT NULL,
PRIMARY KEY (id))
sonicgroup
January 24th, 2005, 18:14
Can you post the part below the //BOTTOM HALF... and/or the complete text of that page? I have a feeling that the error you are having is caused by something earlier or later than what you've posted above.
Jamie
January 24th, 2005, 18:55
you asked for it...
[syntax:2932ccb7d9="php"]
<?php
ob_start();
$c = mysql_connect("localhost","","");
if (!$c) die("Crap.. not again " . mysql_error());
mysql_select_db(blogn,$c) or die(" Grrrr " . mysql_error());
if($_POST["name"] || $_POST["comments"] ) {
$name = $_POST["name"];
$email = $_POST["email"];
$subject = $_POST["subject"];
$comments = $_POST["comments"];
$endate = $_POST["endate"];
$store = "INSERT INTO entries (name,email,subject,comments,endate) VALUES ('$name', '$email', '$subject', '$comments', '$endate')";
mysql_query($store) or die("This isn't working well..." . mysql_error());
//Now to make the new file:
$content ="
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
<html>
<head><title>Jamie Harrop - My Life... Or The Lack Of It</title>
<meta name=\"Description\" content=\"Jamie Harrop - My blog, photos, myself and testing ground. Come and introduce 15 minutes of excitement to your boring lives.\" />
<meta name=\"Keywords\" content=\"jamie harrop,harrop,jamie,blog,photos,testing ground,web design,web,development,hosting\" />
<link rel=\"StyleSheet\" href=\"/include/style.css\" type=\"text/css\" />
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\" />
<script src=\"/include/preload.js\" type=\"text/javascript\"></script></head>
<body>
<div class=\"container\">
<div class=\"header\">
<!-- Makes It Look Pretty !-->
</div>
<div class=\"navigation\"><a href=\"/index.php\" onmouseover=\"MM_swapImage('blog','','/graphics/blog_over.gif',1)\" onmouseout=\"MM_swapImgRestore()\"><img id=\"blog\" src=\"/graphics/blog.gif\" alt=\"Blog\" style=\"width: 34px; height: 20px; padding-left: 5px;\" /></a><a href=\"/about.php\" onmouseover=\"MM_swapImage('about','','/graphics/about_over.gif',1)\" onmouseout=\"MM_swapImgRestore()\"><img id=\"about\" src=\"/graphics/about.gif\" alt=\"About Me\" style=\"width: 74px; height: 20px;\" /></a><a href=\"/1cornwall.php\" onmouseover=\"MM_swapImage('photos','','/graphics/photos_over.gif',1)\" onmouseout=\"MM_swapImgRestore()\"><img id=\"photos\" src=\"/graphics/photos.gif\" alt=\"Photos\" style=\"width: 58px; height: 20px;\" /></a><a href=\"/testing.php\" onmouseover=\"MM_swapImage('testing','','/graphics/testing_over.gif',1)\" onmouseout=\"MM_swapImgRestore()\"><img id=\"testing\" src=\"/graphics/testing.gif\" alt=\"Web Development\" style=\"width: 132px; height: 20px;\" /></a><a href=\"/contact.php\" onmouseover=\"MM_swapImage('contact','','/graphics/contact_over.gif',1)\" onmouseout=\"MM_swapImgRestore()\"><img id=\"contact\" src=\"/graphics/contact.gif\" alt=\"Contact\" style=\"width: 82px; height: 20px;\" /></a></div>
<div class=\"content\">
<div>
<h2 class=\"blogh\">$subject</h2> \n
<span class=\"bydate\">Posted By <span class=\"name\"><a href=\"mailto:$email\" class=\"mailblog\">$name</a> On $endate</span></span><p /> \n
<div class=\"comments\">$comments</div><p /> \n
<a href=\"#comment\">Leave a Comment</a><p class=\"break\" />
<form method=\"post\" action=\"store_entry_comments.php\">
Name*<br />
<input type=\"text\" name=\"name\" value=\"Jamie Harrop\"><p />
Email*<br />
<input type=\"text\" name=\"email\" value=\"jamieharrop14@hotmail.com\"><p />
Subject*<br />
<input type=\"text\" name=\"subject\" size=\"50\" value=\"Subject\"><p />
Entry*<br />
<textarea cols=\"50\" rows=\"12\" name=\"comments\">Message</textarea><p />
<input type=\"text\" name=\"endate\" value=\"<?php $posted_on = date(\"M j Y\"); echo $posted_on; ?>\"><p />
<input type=\"reset\" value=\"Clear\"> <input type=\"submit\" value=\"Post Entry\">
</form>
</div> </div>
<div class=\"sidebar\">
<div class=\"buddies\">
<h2>Special Thanks</h2>
Special thanks must go to <a href=\"http://www.devplant.com/\">Alex B</a>, <a href=\"http://www.thesonicgroup.us/\">Dave Scott</a> &amp; <a href=\"http://www.pixelday.com/\">Marble</a> for 'holding my hand' while I crossed the PHP road with this bespoke blog.
<h2>Friends Sites</h2>
<ul>
<li><a href=\"http://www.farstyle.com\">Far Style</a> <br />Tjobbe Andrews' blog &amp; other bits</li>
<li><a href=\"http://www.paulhirsch.com\">Paul Hirsch</a> <br />Paul Hirsch's personal web site</li>
<li><a href=\"http://www.martinridgway.com/\">Martin Ridgway</a> <br />Martin Ridgway's personal web site</li>
<li><a href=\"/contact.php\">Your Link Here</a> <br />Friend of mine? Have a site? Tell me!</li>
</ul>
<h2>Miscellaneous Links</h2>
<ul>
<li><a href=\"http://forums.iwdn.net\">IWDN Forums</a> <br />Great community over at the International Web Developers Network</li>
<li><a href=\"http://www.wy-media.co.uk\">WY Media</a> <br />Jamie's web development company</li>
<li><a href=\"http://www.innovationhosting.net\">Innovation Hosting</a> <br />Jamie's web hosting company</li>
<li><a href=\"http://www.sxc.hu\">Stock.XCHNG</a> <br />Leading free stock photo site</li>
<li><a href=\"http://www.morguefile.com/archive/\">morgueFile</a> <br />Free stock photographer site</li>
<li><a href=\"http://www.abcarcade.com\">ABC Arcade</a> <br />Some great flash and shockwave games</li>
<li><a href=\"/contact.php\">Your Link Here</a> <br />Have a link? Tell me about it!</li>
</ul>
<h2>Bits &amp; Bats</h2>
<ul style=\"margin-left: 18px;\">
<li style=\"list-style: none; margin-left: 5px;\">
<a href=\"http://www.iwdn.net/redirects/88x31.html\" title=\"Learn more about IWDN\"><img src=\"http://www.iwdn.net/redirects/88x31.png\" alt=\"Jamie Harrop - IWDN Core Team Member\" style=\"border:none ; height:31px ; width:88px\" /></a>
</li>
<li style=\"list-style: none; margin-left: 5px;\">
<a href=\"http://validator.w3.org/check?uri=referer\" title=\"Valid XHTML 1.1\"><img src=\"/graphics/valid-html.png\" alt=\"Valid XHTML 1.1\" style=\"border:none ; height:31px ; width:88px\" /></a>
</li>
<li style=\"list-style: none; margin-left: 5px;\">
<a href=\"http://jigsaw.w3.org/css-validator/validator?uri=http%3A%2F%2Fwww.jamieharrop.com%2Fi nclude%2Fstyle.css&amp;usermedium=all\" title=\"Valid CSS\"><img src=\"/graphics/valid-css.gif\" alt=\"Valid CSS\" style=\"border:none ; height:31px ; width:88px\" /></a>
</li>
</ul>
<h2>Administration</h2>
<ul>
<li><a href=\"/admin\">Login</a> <br />Admin use only!</li>
</ul>
<div class=\"footer\">
&copy; 2005 JamieHarrop.com<br />
All Rights Reserved
</div> </div>
</div>
<br class=\"clear\" />
</div>
</body>
</html>
";
$get = mysql_query("SELECT id FROM entries") or die("Oh man..." . mysql_error());
while($row = mysql_fetch_row($get)){
$id = end($row);
}
$filename = $id.".php";
if($createfile = fopen($filename,"a")) {
fwrite($createfile, $content);
}
echo "
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
<html>
<head><title>Jamie Harrop - My Life... Or The Lack Of It</title>
<meta name=\"Description\" content=\"Jamie Harrop - My blog, photos, myself and testing ground. Come and introduce 15 minutes of excitement to your boring lives.\" />
<meta name=\"Keywords\" content=\"jamie harrop,harrop,jamie,blog,photos,testing ground,web design,web,development,hosting\" />
<link rel=\"StyleSheet\" href=\"/include/style.css\" type=\"text/css\" />
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\" />
<script src=\"/include/preload.js\" type=\"text/javascript\"></script></head>
<body>
<div class=\"container\">
<div class=\"header\">
<!-- Makes It Look Pretty !-->
</div>
<div class=\"navigation\"><a href=\"/index.php\" onmouseover=\"MM_swapImage('blog','','/graphics/blog_over.gif',1)\" onmouseout=\"MM_swapImgRestore()\"><img id=\"blog\" src=\"/graphics/blog.gif\" alt=\"Blog\" style=\"width: 34px; height: 20px; padding-left: 5px;\" /></a><a href=\"/about.php\" onmouseover=\"MM_swapImage('about','','/graphics/about_over.gif',1)\" onmouseout=\"MM_swapImgRestore()\"><img id=\"about\" src=\"/graphics/about.gif\" alt=\"About Me\" style=\"width: 74px; height: 20px;\" /></a><a href=\"/1cornwall.php\" onmouseover=\"MM_swapImage('photos','','/graphics/photos_over.gif',1)\" onmouseout=\"MM_swapImgRestore()\"><img id=\"photos\" src=\"/graphics/photos.gif\" alt=\"Photos\" style=\"width: 58px; height: 20px;\" /></a><a href=\"/testing.php\" onmouseover=\"MM_swapImage('testing','','/graphics/testing_over.gif',1)\" onmouseout=\"MM_swapImgRestore()\"><img id=\"testing\" src=\"/graphics/testing.gif\" alt=\"Web Development\" style=\"width: 132px; height: 20px;\" /></a><a href=\"/contact.php\" onmouseover=\"MM_swapImage('contact','','/graphics/contact_over.gif',1)\" onmouseout=\"MM_swapImgRestore()\"><img id=\"contact\" src=\"/graphics/contact.gif\" alt=\"Contact\" style=\"width: 82px; height: 20px;\" /></a></div>
<div class=\"content\">
<div>
New file created...<br /><br />
And success! Data added to database! Page refreshing now...
</div> </div>
<div class=\"sidebar\">
<div class=\"buddies\">
<h2>Special Thanks</h2>
Special thanks must go to <a href=\"http://www.devplant.com/\">Alex B</a>, <a href=\"http://www.thesonicgroup.us/\">Dave Scott</a> &amp; <a href=\"http://www.pixelday.com/\">Marble</a> for 'holding my hand' while I crossed the PHP road with this bespoke blog.
<h2>Friends Sites</h2>
<ul>
<li><a href=\"http://www.farstyle.com\">Far Style</a> <br />Tjobbe Andrews' blog &amp; other bits</li>
<li><a href=\"http://www.paulhirsch.com\">Paul Hirsch</a> <br />Paul Hirsch's personal web site</li>
<li><a href=\"http://www.martinridgway.com/\">Martin Ridgway</a> <br />Martin Ridgway's personal web site</li>
<li><a href=\"/contact.php\">Your Link Here</a> <br />Friend of mine? Have a site? Tell me!</li>
</ul>
<h2>Miscellaneous Links</h2>
<ul>
<li><a href=\"http://forums.iwdn.net\">IWDN Forums</a> <br />Great community over at the International Web Developers Network</li>
<li><a href=\"http://www.wy-media.co.uk\">WY Media</a> <br />Jamie's web development company</li>
<li><a href=\"http://www.innovationhosting.net\">Innovation Hosting</a> <br />Jamie's web hosting company</li>
<li><a href=\"http://www.sxc.hu\">Stock.XCHNG</a> <br />Leading free stock photo site</li>
<li><a href=\"http://www.morguefile.com/archive/\">morgueFile</a> <br />Free stock photographer site</li>
<li><a href=\"http://www.abcarcade.com\">ABC Arcade</a> <br />Some great flash and shockwave games</li>
<li><a href=\"/contact.php\">Your Link Here</a> <br />Have a link? Tell me about it!</li>
</ul>
<h2>Bits &amp; Bats</h2>
<ul style=\"margin-left: 18px;\">
<li style=\"list-style: none; margin-left: 5px;\">
<a href=\"http://www.iwdn.net/redirects/88x31.html\" title=\"Learn more about IWDN\"><img src=\"http://www.iwdn.net/redirects/88x31.png\" alt=\"Jamie Harrop - IWDN Core Team Member\" style=\"border:none ; height:31px ; width:88px\" /></a>
</li>
<li style=\"list-style: none; margin-left: 5px;\">
<a href=\"http://validator.w3.org/check?uri=referer\" title=\"Valid XHTML 1.1\"><img src=\"/graphics/valid-html.png\" alt=\"Valid XHTML 1.1\" style=\"border:none ; height:31px ; width:88px\" /></a>
</li>
<li style=\"list-style: none; margin-left: 5px;\">
<a href=\"http://jigsaw.w3.org/css-validator/validator?uri=http%3A%2F%2Fwww.jamieharrop.com%2Fi nclude%2Fstyle.css&amp;usermedium=all\" title=\"Valid CSS\"><img src=\"/graphics/valid-css.gif\" alt=\"Valid CSS\" style=\"border:none ; height:31px ; width:88px\" /></a>
</li>
</ul>
<h2>Administration</h2>
<ul>
<li><a href=\"/admin\">Login</a> <br />Admin use only!</li>
</ul>
<div class=\"footer\">
&copy; 2005 JamieHarrop.com<br />
All Rights Reserved
</div> </div>
</div>
<br class=\"clear\" />
</div>
</body>
</html>
";
header('Refresh: 3; URL=/index.php');
}
?>
[/syntax:2932ccb7d9]
sonicgroup
January 24th, 2005, 18:59
Ok, I'll be honest with you - I can't see any problem with what you have at all. Now that I've seen all of it, I know it can't be the single quote since you've used it several times previous to that line. I'm stumped. :(
Jamie
January 24th, 2005, 19:09
Dave Scott stumped? That is never a good sign! I always assume a parse error with a missing colon, bracket or something similar, is there any php validator online?
Jamie
January 24th, 2005, 19:28
Stuff it, I am going to get rid of the sub comments feature for now and upload as I have it, we will concentrate on the comments later. All will be revealed soon...
sonicgroup
January 24th, 2005, 20:02
Well, generally you'd get a parse error for not escaping something correctly or leaving out semi-colon. The error you are getting doesn't make any sense to me because it occurs in the middle of the text, with everything, as near as I can tell, correctly escaped.
Most often, the parse error you'll get from a missing semi-colon includes more information though (such as T_ENCAPSED_STRING) or some other constant variable (or an unexpected 'X'). Once you know these, you have a better idea of what to look for.
Edit: What editor are you using when making your PHP pages? If it has syntax highlighting, make sure that the color of your strings isn't changing somewhere in the middle. A change from string color to anything else can indicate a missed escape.
Jamie
January 24th, 2005, 20:05
I'm using textpad, doesnt have syntax highlighting for php, I will download one though and have a closer look.
sonicgroup
January 24th, 2005, 20:12
Definitely get an editor that has syntax highlighting for PHP. From my quick run-through on here, I didn't spot an missed escapes, but you never know.
If you're looking for a good editor, I'd suggest Notepad++ (http://notepad-plus.sourceforge.net).
vBulletin® v3.6.8, Copyright ©2000-2010, Jelsoft Enterprises Ltd.