Current location: Hot Scripts Forums » Programming Languages » PHP » Script Error


Script Error

Reply
  #1 (permalink)  
Old 04-08-04, 07:57 PM
Fitzo Fitzo is offline
New Member
 
Join Date: Apr 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Script Error

When i run this script i get a Parse error on line 46 which is the ?> tag.

heres my code

PHP Code:

<?php


// Server
$dbserver "localhost"

// Database Username
$dbuser "user";

// Database Password
$dbpass "pass";

// Database Name
$dbname "db"

// Connects to database
$db mysql_connect($dbserver,$dbuser,$dbpass) or die("Failed to cennect to mysql server on: $dbserver");
if(
mysql_select_db($dbname)==false) { mysql_close($db); die("Failed to select database: $dbname"); }

// Lets select our record fields from our database table and check for results 

$sql "SELECT title, date, user FROM news"

$mysql_result mysql_query($sql,$db); 

// We carry out the table population using a 'while' loop 

echo '<table align=\"center\" cellspacing=\"1\" cellpadding=\"0\" width=\"485\" border=\"1\" bordercolor=\"#000000\">';
echo 
'<tr>';

// Get data

while ($row=mysql_fetch_array($mysql_result)) 

$title $row["title"]; 
$date $row["date"]; 
$user $row["user"]; 

echo 
'<td class=\"td\" background=\"images/v1.gif\">
           $title posted on $date by $user'
;

echo 
'</td>';
echo 
'</tr>';
echo 
'</table>';

mysql_close($db);
?>
Reply With Quote
  #2 (permalink)  
Old 04-08-04, 09:08 PM
mdhall's Avatar
mdhall mdhall is offline
Aspiring Coder
 
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
mysql_close($db);
}
?>
Reply With Quote
  #3 (permalink)  
Old 04-09-04, 12:17 PM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
you forgot to close your while loop !
and actually it's:
PHP Code:

}


mysql_close($db);
?> 
you don't want to close the connection inside the loop, do you ?
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]

Last edited by NeverMind; 04-09-04 at 12:38 PM.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there any integrity of script rankings? webmaster@atmanager.com Hot Scripts Forum Questions, Suggestions and Feedback 17 08-06-04 12:12 AM
parse error... help? kappler0 PHP 2 01-21-04 03:57 AM
Error in Safelist script. mononom Hot Scripts Forum Questions, Suggestions and Feedback 2 01-11-04 09:13 PM
error when creating database tables with php script spiroth10 PHP 4 01-06-04 03:59 PM
[php error] parse error | fatal error xeoHosting PHP 1 01-03-04 08:12 PM


All times are GMT -5. The time now is 10:25 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.