Jump to content

Parse error


alen

Recommended Posts

I'm making a news management script!

So far I have managed to make the script add news, so that I can view it on the index page. Now I've started with the edit part.

First off I got an error ... then I added a mysql_error to check it.

This is the result of the new error:

[b]Parse error:[/b] parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in [b]/path/path/rediger.php[/b] on line [b]8[/b].

I can't seem to find any extra spaces in the script, so I don't think that's causing the error.

Here's my code, http://anigma.sitees.com/rediger.txt and http://anigma.sitees.com/lagre.txt

It consist's of two parts, firstly I have to extract the news from my database, and secondly I have to display this data.

I have chosen to display the latest 10 newest posts.


Link to comment
Share on other sites

that'll be because you havent got an 'id' in the URL. tack on a rediger.php?id=1 or something to your URL and try it out. you'll need to decide what you want to do in the event that 'id' hasnt been passed in the URL, and put in a check to handle it before you query the DB
Link to comment
Share on other sites

This is how my edit script looks like right now,

http://anigma.sitees.com/rediger.txt
and
http://anigma.sitees.com/lagre.txt

I keep getting a notice error..

[b]Notice:[/b] Undefined index: id in [b]rediger.php[/b] on line [b]8[/b]

Should I just get this away with, error_reporting(E_ALL ^ E_NOTICE); ?
Link to comment
Share on other sites

Yes I have a field/column for the date, but I got this,

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY date DESC LIMIT 10' at line 1
Link to comment
Share on other sites

you could, but it's best to deal with your errors rather than hide them. especially as considering your query, an undefined index (and hence no value) would make your query fail. ([b]edit[/b] which is what your reply you just posted has shown)

replace the query line with the following:

[code]
<?php
if (isset($_GET['id']))
{
  $query = "SELECT * FROM news WHERE id = {$_GET['id']}";
}
else
{
  $query = "SELECT * FROM news ORDER BY date DESC LIMIT 10";
}
?>
[/code]

which means if an ID is passed in the URL (notice the 'isset' check), then that record will be picked and displayed. otherwise, the latest 10 records order by most recent first will be displayed.

cheers
Mark
Link to comment
Share on other sites

That was better, but... I want to have links on the rediger.php site to each post.

Let's say this is the page:

rediger.php :

Random test (the first post i posted)
Whatever (the second)
etc...

And then I want to make each title to a link like rediger.php?id=1 (which is Random test since it was the first post i posted), and then I click on the title and then I would be able to edit/save the content.
Link to comment
Share on other sites

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.