Jump to content

Error when using fetch_array


bugmero

Recommended Posts

Hi all ,

 

I have this code :

 

<?php

 

$dbuser="";

$dbpassword="";

$servername="";

$dbname="";

 

connecttodb($servername,$dbname,$dbusername,$dbpassword);

function connecttodb($servername,$dbname,$dbuser,$dbpassword)

{

global $link;

$link=mysql_connect ("$servername","$dbuser","$dbpassword");

if(!$link){die("Could not connect to MySQL");}

mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error());

}

 

$query="select * from swr_player"

$rt=mysql_query($query);

echo mysql_error();

while($nt=mysql_fetch_array($rt)){

echo "$nt[FName] $nt[Lname] $nt[FB]<br>";   

}

 

 

?>

 

The data for connection is entered correctly . But i get this error messege :

 

Parse error: syntax error, unexpected T_VARIABLE in ................  line 18

 

Please help

 

Thanks

Link to comment
Share on other sites

so many details you have to watch for

 

Actually, the syntax rules of any computer programming language are much simpler and consistent than the syntax rules of a written linguistic language, but you do need to proofread your code to make sure it has the correct syntax everywhere.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.