Last active
March 30, 2016 10:39
-
-
Save ashumeow/fe39b0f61f0354cb96839d9f2e737e1f to your computer and use it in GitHub Desktop.
Connecting to MySQL database via PHP script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$host = '127.0.0.1'; | |
$user = 'abc'; | |
$pwd = 'abc'; | |
$db = 'xyz'; | |
$con = mysql_connect($host, $user, $pwd) or die("connection failed"); | |
mysql_select_db($db,$con) or die("db selection failed"); | |
$r=mysql_query("select * from class",$con); | |
while($row=mysql_fetch_array($r)) | |
{ | |
$cls[]=$row; | |
} | |
print(json_encode($cls)); | |
mysql_close($con); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment