Small help about localhost

Hi

Have some problems with this code. I get
Parse error: syntax error, unexpected ‘}’, expecting ‘,’ or ‘;’ in C:\Program Files (x86)\xampp\htdocs\test\111.php on line 29 Whats wrong with this code

[php]
mysql_connect(‘localhost’,‘root’,’’)
or die(‘cant connect to server’);

mysql_select_db(‘ulv’)
or die(‘cant connect to dabase.’);

$sql= “select * from deadlines” ;
$resultat=mysql_query($sql);
$antall=mysql_num_rows($resultat);

for ($i=0; $i <$antall; $i++){
$rad=mysql_fetch_row($resultat);
echo ‘

’;
echo $rad[0];
echo ‘ ’;
echo $rad[1];
echo ‘ ’;
echo $rad[2];
echo ‘ ’;
echo $rad[4];
echo ‘ ’;
echo $rad[5];
echo ‘ ’;
echo $rad[6];
echo ‘ ’};

[/php]

';
Inforation name detail date time
;

Just a rough guess here swap the positions of the semi colon and the closing brace

[php] echo ‘’};[/php]

Here??

yes swap them round to ;}

now i get this massage

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\Program Files (x86)\xampp\htdocs\test\listallefrister.php on line 13

You need to change that like to this

[php]
$rad=mysql_fetch_row($resultat) {
[/php]

And then add another } at the bottom of the code after the last one like this

[php]
echo ‘’;
}
}
[/php]

Now I get this: Parse error: syntax error, unexpected ‘{’ in C:\Program Files (x86)\xampp\htdocs\test\listallefrister.php on line 16

[php]$sql= “select * FROM deadlines ORDER BY date” ;
$resultat=mysql_query($sql);
$antall=mysql_num_rows($resultat);

for ($i=0; $i <$antall; $i++){
$rad=mysql_fetch_row($resultat) {
echo ‘

’;
echo $rad[0];
echo ‘ ’;
echo $rad[1];
echo ‘ ’;
echo $rad[2];
echo ‘ ’;
echo $rad[4];
echo ‘ ’;
echo $rad[5];
echo ‘ ’;
echo $rad[6];
echo ‘ ’;
}
}[/php]

That code is not valid. There should be a ; after mysql_fetch_row instead of {

However, I believe you want a while loop here instead.

[php]
$sql= “select * FROM deadlines ORDER BY date” ;
$resultat=mysql_query($sql);

while($row = mysql_fetch_row($resultat)) {
echo ‘

’;
echo $rad[0];
echo ‘ ’;
echo $rad[1];
echo ‘ ’;
echo $rad[2];
echo ‘ ’;
echo $rad[4];
echo ‘ ’;
echo $rad[5];
echo ‘ ’;
echo $rad[6];
echo ‘ ’;
}
[/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service