|
-
Aug 22nd, 2005, 12:25 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] MySQL blog
on this script i keep getting this error Parse error: syntax error, unexpected $end in C:\Program Files\xampp\htdocs\xampp\Sites\Band\Templates\forum.php on line 55 (line 55 is the last line </form> line )
Code:
<?php
if (isset ($_POST['submit']))
{
if ($dbc = @mysql_connect ('localhost', 'root', ''))
{
if (!@mysql_select_db ('forum'))
{
die ('<p>Could not select the database because: <b>' . mysql_error() . '</b></p>');
}
$query = "INNSERT INTO forum_entries (blog_id, title, entry, date_entered)
VALUES (0, '{$_POST['title']}', '{$_POST['entry']}', NOW())";
if (@mysql_query ($query))
{
echo '<p>The blog entry has been added.</p>';
} else {
echo "<p>Could not add the entry because: <b>" . mysql_error() . "</b>. The query was $query</p>";
}
}
mysql_close();
if ($dbc = @mysql_connect ('localhost', 'root', ''))
{
if (!@mysql_select_db ('forum'))
{
die ('<p>Could not select the database because: <b>' . mysql_error() . '</b></p>');
}
$query = 'SELECT * FROM forum_entries ORDER BY date_entered ASC';
if ($r = mysql_query ($query))
{
while ($row = mysql_fetch_array ($r))
{
echo "<p><h3>{$row['title']}</h3>{$row['entry']}<br />
<a href=\"forum.php?id={row['forum_id']}\">Edit</a>
<a href=\"delete_entry.php?id={$row['blog_id']}\">Delete</a>
</p><hr />\n";
}
} else {
die ('<p>Could not retrieve the data because: <b>' . mysql_error() ."'</b>The query was $query</p>");
}
mysql_close();
?>
<form acrtion="forum.php" method="post">
<p>Entry Title: <input type="text" name="title" size="40" maxsize="100" /><br />
Entry Text: <textarea name="entry" columns="40" rows="5"></textarea></p>
<input type="submit" name="submit" value="Add to the Forum!" />
</form>
also i was wondering if its possible to make a blog scpirt like this that shows the form, shows the other entered blogs, and shows an edit and delete button for each all on the same script. right now i ahve the add and view parts in this script and the delete on the other...no idea if it worx though because i cant test it due to the last error.
-
Aug 22nd, 2005, 12:26 AM
#2
Thread Starter
Hyperactive Member
Re: MySQL blog
and yes, even after spelling action right in the form action the error is still there
-
Aug 22nd, 2005, 12:34 AM
#3
Lively Member
Re: MySQL blog
You were missing a couple ending curly braces:
PHP Code:
if (isset ($_POST['submit']))
{
if ($dbc = @mysql_connect ('localhost', 'root', ''))
{
if (!@mysql_select_db ('forum'))
{
die ('<p>Could not select the database because: <b>' . mysql_error() . '</b></p>');
}
$query = "INNSERT INTO forum_entries (blog_id, title, entry, date_entered)
VALUES (0, '{$_POST['title']}', '{$_POST['entry']}', NOW())";
if (@mysql_query ($query))
{
echo '<p>The blog entry has been added.</p>';
} else
{
echo "<p>Could not add the entry because: <b>" . mysql_error() . "</b>. The query was $query</p>";
}
}
}
mysql_close();
if ($dbc = @mysql_connect ('localhost', 'root', ''))
{
if (!@mysql_select_db ('forum'))
{
die ('<p>Could not select the database because: <b>' . mysql_error() . '</b></p>');
}
$query = 'SELECT * FROM forum_entries ORDER BY date_entered ASC';
if ($r = mysql_query ($query))
{
while ($row = mysql_fetch_array ($r))
{
echo "<p><h3>{$row['title']}</h3>{$row['entry']}<br />
<a href=\"forum.php?id={row['forum_id']}\">Edit</a>
<a href=\"delete_entry.php?id={$row['blog_id']}\">Delete</a>
</p><hr />\n";
}
}
}
else
{
die ('<p>Could not retrieve the data because: <b>' . mysql_error() ."'</b>The query was $query</p>");
}
-
Aug 22nd, 2005, 12:46 AM
#4
Thread Starter
Hyperactive Member
-
Aug 22nd, 2005, 12:47 AM
#5
Thread Starter
Hyperactive Member
Re: MySQL blog
long scripts are annoyin with the closing tags lol i always leave 1 out and it makes all the difference
-
Aug 22nd, 2005, 12:55 AM
#6
Lively Member
Re: MySQL blog
I always format my code like this:
Code:
<?php
if(this == this)
{
while(some condition)
{
if(this == that)
{
// do this
}
}
}
?>
I'm not saying it's the right way to format your code or anything, but I find it easier to spot such things.
-
Aug 22nd, 2005, 01:00 AM
#7
Thread Starter
Hyperactive Member
Re: MySQL blog
yea mines easier to read but i cant find the missing } i'll try maybe indenting everything but the opening and closing brackets or something
-
Aug 22nd, 2005, 01:04 AM
#8
Thread Starter
Hyperactive Member
Re: MySQL blog
alright it worked now i just gotta run the script that makes a database lol
thanx {yak}
-
Aug 22nd, 2005, 04:05 AM
#9
Hyperactive Member
Re: [RESOLVED] MySQL blog
i double space my stuff... and indent "sumtimes" like that.
Without balance, there could only be chaos.
Without chaos, there could be no balance.
I live with karma. Eat with destiny. Dream of life without shackles....
Yet. If life had no consequences, life could not exist, nor could it flourish.
If at first you dont succeed.You're screwed.
C++/Java NOOB.
I aint a professional at PHP, but if i can help i will.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|