Reply to Re: While Loop Issues

Your name:

Reply:


Posted by Rik Wasmus on 12/22/07 17:46

On Sat, 22 Dec 2007 18:04:19 +0100, <MKruer@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=3D10&t=3D588149&p=3D356=
3595#p3563595
>
> -TIA-
>
> [Code]
> while ( $row =3D mysql_fetch_object( $result ) ) {
> // remove extra slashes
> $subject =3D 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 =3D preg_replace ('/\'/', '\\\'', $subject);
> $query=3D"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 =3D 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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация