Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 03-27-2003, 07:17 PM   #1 (permalink)
trevor
Code Monkey
 
Join Date: Jan 2003
Location: Canada
Posts: 91
trevor is on a distinguished road
whats wrong with this code

Hey sde and others,
ive been away for a while and a problem i was dealing with 3 weeks ago sorta got forgotten........
lol anyways sde, you gave me this code and i am getting a "parse error, unexpected T_STRING" on the "or die(error);" line, so its probably the line above, but i cant figure it out....

here is the code snippet:
PHP Code:
<?
$query 
= ("Select * from news order by ID desc limit 5");
$result mysql_query($query$db)
                        or die(
"error");

while (
$row mysql_fetch_array ($result)) {

    print(
"<br><br><p>
    <b><i>posted by</i> -=[$row[author]]=-  <u>$row[header]</u></b>
    <font size='2'><i> $row[date] @ $row[time] </i></font>
    <br>
    $row[content] </p>
    <br>
    <hr width='85%'>"
);
}
?>
thanks all,
peace,
Trevor
trevor is offline   Reply With Quote
Old 03-27-2003, 07:35 PM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,505
sde is on a distinguished road
Re: whats wrong with this code

sorry, .. i don't take credit for that script... i never use anything like 'or die(error)'

try this:
PHP Code:
<?
$query 
= ("Select * from news order by ID desc limit 5");
if(
$result mysql_query($query$db))
{
  while (
$row mysql_fetch_row($result)) {

    print(
"<br><br><p>
    <b><i>posted by</i> -=[" 
$row[author] . "]=-  <u>$row[header]</u></b>
    <font size='2'><i> " 
$row[date] . " @ " $row[time] . "</i></font>
    <br>
    " 
$row[content] . " </p>
    <br>
    <hr width='85%'>"
);
   }
}
else
{
  exit;
}
?>
also, .. when posting code with errors.. please communicate which line the error is being reported on =)

thanks,
sde

:: edited ::
sde is offline   Reply With Quote
Old 03-27-2003, 07:58 PM   #3 (permalink)
trevor
Code Monkey
 
Join Date: Jan 2003
Location: Canada
Posts: 91
trevor is on a distinguished road
yeah........
now i am getting a:

"parse error, unexpected '{'"

on the line:

while ($row = mysql_fetch_array ($result)) {

but i need that '{'?

wtf?
thanks sde
trevor is offline   Reply With Quote
Old 03-27-2003, 09:35 PM   #4 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,505
sde is on a distinguished road
i jsut edited the code above .. i think it was the space between mysql_fetch_array - and - the parameter ($result)

however, .. i also switched it to mysql_fetch_row($result)

try that
sde is offline   Reply With Quote
Old 03-30-2003, 03:09 PM   #5 (permalink)
trevor
Code Monkey
 
Join Date: Jan 2003
Location: Canada
Posts: 91
trevor is on a distinguished road
nope. still doesnt want to work. Same error on the same "{".
i dunno i played around with it for a while and i cant seem to figure it out.
thanks
trevor is offline   Reply With Quote
Old 03-30-2003, 07:48 PM   #6 (permalink)
Ryan
Registered User
 
Join Date: Mar 2003
Location: Virginia
Posts: 4
Ryan is on a distinguished road
Send a message via ICQ to Ryan Send a message via AIM to Ryan Send a message via Yahoo to Ryan
Hi,

Try this code out:

PHP Code:
<?
$query 
= ("SELECT * FROM news ORDER BY ID DESC LIMIT 5");
$result mysql_query($query);

while (
$row mysql_fetch_array($result)) {

    print(
"<br><br><p>");
    print(
"<b><i>posted by</i>");
    print(
"-=[" $row[author] . "]=-");
    print(
"<u>" $row[header] . "</u></b>");
    print(
"<font size='2'><i> " $row[date] . " @" .  $row[time]);
    print(
"</i></font><br>");
    print(
$row[content] . " </p>");
    print(
"<br><hr width='85%'>");
}
?>
I added a lot more "print" functions in there but I tried to make it a bit more organized.
Ryan is offline   Reply With Quote
Old 04-01-2003, 05:46 PM   #7 (permalink)
trevor
Code Monkey
 
Join Date: Jan 2003
Location: Canada
Posts: 91
trevor is on a distinguished road
hey,

I'm getting a:
PHP Parse error: parse error, unexpected T_VARIABLE in /var/www/htdocs/ao/main.php on line 177

error on Ryan's code. (btw thanks Ryan)

line 177 is:
PHP Code:
print("<font size='2'><i> " $row[date] . " @" .  $row[time]); 
thanks everyone so far
trevor is offline   Reply With Quote
Old 04-01-2003, 06:00 PM   #8 (permalink)
joe_bruin
LOAD "*",8,1
 
Join Date: Feb 2003
Location: la.ca.us
Posts: 254
joe_bruin is on a distinguished road
try:

PHP Code:
print("<font size='2'><i> " $row["date"] . " @" .  $row["time"]); 
you're missing alot of other quotes too, but the php parser was smart enough to figure out what you meant in all the other instances.
joe_bruin is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cisco Code breaking sde Code Newbie News 0 05-21-2004 07:10 AM
Microsoft probes Windows code leak redhead Code Newbie News 0 02-13-2004 12:41 AM
ok, what is wrong with this code? trevor PHP 3 02-04-2003 10:09 PM


All times are GMT -8. The time now is 08:40 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting