|
Posted by MKruer on 12/22/07 22:42
On Dec 22, 2:04 pm, MKr...@gmail.com wrote:
> On Dec 22, 9:46 am, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote:
>
>
>
> > On Sat, 22 Dec 2007 18:04:19 +0100, <MKr...@gmail.com> wrote:
> > > I am having issues with a while loop in a modified script. It gives me
> > > the error "Fatal error: Cannot access empty property in fb2phpbb2.php
> > > on line 146" If i comment out the loop. The script does populate the
> > > table. Because the script was designed for php 4.x, I think its just a
> > > syntactical issue. More info can be found at
> > >http://www.phpbb.com/community/viewtopic.php?f=10&t=588149&p=3563595#...
>
> > > -TIA-
>
> > > [Code]
> > > while ( $row = mysql_fetch_object( $result ) ) {
> > > // remove extra slashes
> > > $subject = stripslashes( $row->subject );
> > > // Some messages still had the single quote in them without a \
> > > // which was causing import problems so we
> > > // removed the single quote and replaced it with HTML for the
> > > quote
> > > $subject = preg_replace ('/\'/', '\\\'', $subject);
> > > $query="INSERT INTO {$phpbb_dbprefix}topics"
> > > ." (topic_id, forum_id, topic_poster, topic_title, topic_time,"
> > > ." topic_views, topic_replies, topic_status, topic_vote,
> > > topic_type,"
> > > ." topic_first_post_id, topic_last_post_id, topic_moved_id)"
> > > ." VALUES ('$row->id', '$row->catid', '$row->userid',
> > > '$subject', '$row->time',"
> > > ." '$row->hits', '$row->reply', '$row->locked', '0', '',"
> > > ." '$row->min', '$row->max', '0')";
> > > $updateresult = mysql_query($query) or die("<br />Invalid
> > > query:<br />$query<br />" . mysql_error());
> > > }
> > > mysql_free_result($result);
>
> > > [/Code]
>
> > First of all: mysql_real_escape_string()
> > Also, try to use curly braces around 'complex' variables in strings.
> > Lastly, probably you don't even need a loop and you can do this with a
> > simple 'INSERT .... SELECT...' query.
> > --
> > Rik Wasmus
>
> That still does not answer my question of what is wrong with the loop.
> What I posted is a simple while loop. there are other parts of the
> code that are much more complex that I simply cant update the query
> with a replace string SQL query.
>
> -Matt-
Never mind. i found the issue. it was problem with the Select
statement above. By itself its fine but in a while loop, it blew it
up.
Navigation:
[Reply to this message]
|