somehow my code is not displaying the records ...it is showing error on line 12...
Error :
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\wamp\www\php\view_student.php on line 12
My code is:-
------------------------------------------------------------------------------------------
1 <?php
2 echo "here";
3 $con = mysql_connect("localhost","root","");
4 if (!$con)
5 {
6 die('Could not connect: ' . mysql_error());
7 }
8 mysql_select_db("users", $con);
9 $result = mysql_query("SELECT * FROM user WHERE id = '$_POST [userid]' );
10 while($row = mysql_fetch_array($result))
11 {
12 echo $row['id'] . $row['username'] . $row['Address'];
13 echo "<br />";
14 }
15 mysql_close($con);
16 ?>
------------------------------------------------------------------------------------------
php my sql
Moderator: General Moderators
- Maugrim_The_Reaper
- DevNet Master
- Posts: 2704
- Joined: Tue Nov 02, 2004 5:43 am
- Location: Ireland
Re: php my sql
try9 $result = mysql_query("SELECT * FROM user WHERE id = '$_POST [userid]' );
Code: Select all
$result = mysql_query("SELECT * FROM user WHERE id = " . mysql_real_escape_string($_POST['userid']));2. You missed a closing double-quote.
3. You never escaped the value entering the SQL statement.
The first error, 1, is probably what caused the fatal error - it's the first problem the parser would have found in that line.
Re: php my sql
Thanks very much man