html - PHP not executing -
so im still beginning learn php , im trying make code upload 2 items,name , age. database "nk" table "players" , display entries in players. whenever hit submit, page reloads show php code , doesn't execute.
<html> <body> <form action="db.php" method="post"> name: <input type="text" name="name"> age:<input type="text" name="age"> <input type="submit"> </form> </body> </html>
and db.php file
<?php mysql_connect("localhost","noha","noha"); @mysql_select_db(nk) or die( "unable select database"); $name=$_post['name']; $age=$_post['age']; $result=mysql_query("select * players"); $num=mysql_numrows($result); mysql_close(); echo "<b><center>database output</center></b><br><br>"; $i=0; while ($i < $num) { $name=mysql_result($result,$i,"name"); $age=mysql_result($result,$i,"age"); echo "<b>$name $age</b><br>"; $i++; } mysql_close(); ?>
i'm not sure meaning , i'm guessing. page reloads , show php code , php client not set yet. have checked mysql , apache server running?
a way
echo 'something'; mysql_connect("localhost","noha","noha");
and see whether code execute
by way $num=mysql_numrows($result); $num=mysql_num_rows($result);
so have server online, maybe should check mysql_select_db syntax
and try use mysqli since mysql deprecated
Comments
Post a Comment