Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*** mysql hostname ***/
- $hostname = 'localhost';
- /*** mysql username ***/
- $username = 'root';
- /*** mysql password ***/
- $password = '';
- $dbname = 'test';
- $link = connect($hostname, $username,$password);
- function connect($hostname, $username, $password){
- $link = @mysql_connect($hostname, $username, $password);
- if (!$link)
- die("Could not connect: ".mysql_error());
- else{
- $db = mysql_select_db('test');
- if(!$db)
- die("Could not select database: ".mysql_error());
- else return $link;
- }
- }
- $result = mysql_query("SELECT * FROM stalkers",$link);
- function getContent($result){
- $final = array();
- while($row = mysql_fetch_array($result)) {
- $final[] = $row;
- }
- return $final;
- }
- echo json_encode(getContent($result));
- ?>
Add Comment
Please, Sign In to add comment