Welcome! Log In Create A New Profile

Advanced

parse error, unexpected T_VARIABLE - in

Posted by Anonymous User 
Announcements Last Post
Announcement myUnisa availability 21 to 24 March 2019 03/17/2019 02:24PM
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Anonymous User
parse error, unexpected T_VARIABLE - in
May 10, 2010 11:36AM
Hi
I have a "parse error, unexpected T_VARIABLE" in the following code
it is in line 43 that will be the line starting with $sno=$row['0'];
I have tryed different things like including { } in the beginning and the end of the string
and cant find the problem
can any body pleas help me out

<?php

if(mysql_affected_row()==1)
mysql_select_db("dbregistration"winking smileyor die("Unable to select database"winking smiley;
$result=mysql_query("SELECT*from student WHERE sno='$sno'"winking smiley;
while($row=mysql_query(fetch_row($result))

$sno=$row['0'];
echo"your student number is:$sno";

?>


thanks
avatar
Mac
Re: parse error, unexpected T_VARIABLE - in
May 10, 2010 02:58PM
Put your code in a code PHP block (4th button from left here on top) here on the forum to make it readable. And always make use of braces - it is good programming practice!

The while row is not equal in brackets - 3 versus two - therefore the error. Also not ['0'] but [0].

Language: PHP
<?php $result = mysql_query(" SELECT * from student WHERE sno='$sno'"); if ($result) { $row = mysql_fetch_row($result); $sno=$row[0]; } else { echo "$sno not found!"; } ?>
Anonymous User
Re: parse error, unexpected T_VARIABLE - in
May 11, 2010 09:25PM
Thanks Mac
Sorry, only registered users may post in this forum.

Click here to login