Jump to content

[SOLVED] Error, "unexpected $end" on line 1?


Recommended Posts

I've looked through my code so many times, but I'm just not getting it. I Googled this error and found that it's usually a problem with a missing } or not having quick start enabled... but uh, line 1 of my document is "<?php" and that's not quick starting, is it?

 

I guess I'll just post the code here:

<?php 
$title = "thechickennuggit";
include ("/home/heathenk/public_html/tcn/skins/cookiecheck.php");
$headervar="/home/heathenk/public_html/tcn/skins/header"; $extension=".php";
include($headervar.$skin.$extension);

$con = mysql_connect("localhost","heathenk_nuggit","******");
if(!$con){ die('Could not connect:' . mysql_error()); }

$idnum = $_GET['id'];
mysql_select_db("heathenk_dbfornuggit", $con);
$query = mysql_query("SELECT * FROM Sk_book WHERE id=$idnum");

echo "<h1>Editing #" . $idnum . "</h2>";

while($row = mysql_fetch_array($query))
{
//THE DISPLAY OF WHAT I'M EDITING
echo '<table id="db" cellspacing="0" cellpadding="8">';
echo "<tr><td valign='top'>" . $row['id'] . "</td>";
echo "<td valign=top>" . $row['category'] . "</td>";
echo "<td>" . $row['Title'] . " (".$row['filename'] . ".php) ";
echo "<a href='" . $row['imgURL'] . "'>[x]</a><br />";
echo "<p style='size:8pt;margin:2px;border:2px azure;'>";
if ($row['blurb'] !== null) { echo $row['blurb']; }
	else { echo "<b style='color:red;'>OMG this needs a blurb.</b>"; }
echo "</p></td></tr>";
echo "</table>";
//THE FORM
echo "<form action='edit123.php' method='post'>";
echo "<input type='hidden' name='id' value='".$idnum."' />";
echo "filename: <input type='text' value='".$row['filename']."' name='filename' style='font:8pt verdana;margin:5px;' />*<br />";
echo "category: <input type='text' value='".$row['category']."' name='category' style='font:8pt verdana;margin:5px;' />*<br />";
echo "Title: <input type='text' value='".$row['Title']."' name='Title' style='font:8pt verdana;margin:5px;' />*<br />";
echo "imgURL: <input type='text' value='".$row['imgURL']."' name='imgURL' style='font:8pt verdana;margin:5px;' /><br /><br />";
echo "blurb:<br /><textarea name='blurb' rows='14' cols='80' style='font:8pt verdana;margin:5px;'>".$row['blurb']."</textarea>";
echo '<input type="submit" /></form>';
} //while ends here

mysql_close($con);

  $footervar = "/home/heathenk/public_html/tcn/skins/footer";
  $extension = ".php";
  include ($footervar.$skin.$extension);
?>

Link to comment
https://forums.phpfreaks.com/topic/38050-solved-error-unexpected-end-on-line-1/
Share on other sites

ok, well i have no idea how to fix this error, with the code youve posted here

 

all i can say is that if youve included it from another page, then maybe its that page thats the problem.  if you incldue filse, and receive an error, check all of the error line becauase often the error is like "output started line 54 of "INC FILE.inc" Error on line 97 of page 'File that icludes the other'".  in that case, your error is in the included file...... so maybe your script actually has a problem with an included file or something like that

Well, I fixed the problem...

 

It worked after I took out the comments inside the while {}, and after I turned stuff like $row['filename'] to $row[filename]. So what I learned is that Mr. While does not like comments, and you shouldn't use single quotes to call stuff from a row.

 

>.> It's a little vexing.

 

Isn't it?

 

Why can't I comment inside there? And why do I see code bits in tutorials using single quotes for $row, when it doesn't work for me?

 

Oh well, I solved the problem.

Sorry for bumping, but I just felt like writing this out... and see if anyone could tell me more if they know off the top of their heads.

Well, the entirety of my code looks like this now:

<?php 
$title = "thechickennuggit";
include ("/home/heathenk/public_html/tcn/skins/cookiecheck.php");
$headervar="/home/heathenk/public_html/tcn/skins/header"; $extension=".php";
include($headervar.$skin.$extension);

$con = mysql_connect("localhost","heathenk_nuggit","******");
if(!$con){ die('Could not connect:' . mysql_error()); }

$idnum = $_GET['id'];
mysql_select_db("heathenk_dbfornuggit", $con);

$query = "SELECT * FROM Sk_book WHERE id=$idnum";
$result = mysql_query($query); 

echo "<h1>Editing #" . $idnum . "</h2>";

while($row = mysql_fetch_array($result))
{
echo '<table id="db" cellspacing="0" cellpadding="8">';
echo "<tr><td valign='top'>$row[id]</td>";
echo "<td valign=top>$row[category]</td>";
echo "<td>$row[Title] ($row[filename].php) ";
echo "<a href=\"$row[imgURL]\">[x]</a><br />";
echo "<p style='size:8pt;margin:2px;border:2px azure;'>";
if ($row[blurb] !== null) { echo $row[blurb]; }
	else { echo "<b style='color:red;'>OMG this needs a blurb.</b>"; }
echo "</p></td></tr>";
echo "</table>";

echo "<form action=\"edit123.php\" method=\"post\">";
echo "<input type='hidden' name='id' value='$idnum' />";
echo "filename: <input type='text' value=\"$row[filename]\" name='filename' style='font:8pt verdana;margin:5px;' />*<br />";
echo "category: <input type='text' value=\"$row[category]\" name='category' style='font:8pt verdana;margin:5px;' />*<br />";
echo "Title: <input type='text' value=\"$row[Title]\" name='Title' style='font:8pt verdana;margin:5px;' />*<br />";
echo "imgURL: <input type='text' value=\"$row[imgURL]\" name='imgURL' style='font:8pt verdana;margin:5px;' /><br /><br />";
echo "blurb:<br /><textarea name='blurb' rows='14' cols='80' style='font:8pt verdana;margin:5px;'>$row[blurb]</textarea>";
echo "<input type=\"submit\" /></form>";
} //while ends here
mysql_close($con);

  $footervar = "/home/heathenk/public_html/tcn/skins/footer";
  $extension = ".php";
  include ($footervar.$skin.$extension);
?>

 

(What's fishy now is that the footer isn't showing up. But I suppose that'd be for another topic later.)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.