+ 1

How to use mysql queries in php

mysql

10th Nov 2016, 1:06 PM
Sanchit Srivastava
3 Answers
+ 2
I upvoted your answer and I am doing a humble request, please add i after MySQL like mysqli. because mysql is deprecated in PHP 5 and removed from PHP7.
10th Nov 2016, 2:30 PM
Aditya kumar pandey
Aditya kumar pandey - avatar
+ 1
Like this (in php5): <?php if (!$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')) { echo 'Could not connect to mysql'; exit; } if (!mysql_select_db('mysql_dbname', $link)) { echo 'Could not select database'; exit; } $sql = 'SELECT foo FROM bar WHERE id = 42'; $result = mysql_query($sql, $link); if (!$result) { echo "DB Error, could not query the database\n"; echo 'MySQL Error: ' . mysql_error(); exit; } while ($row = mysql_fetch_assoc($result)) { echo $row['foo']; } mysql_free_result($result); ?> See more info on: http://php.net/manual/en/function.mysql-db-query.php Aditya kumar pandey: thx for the correction
10th Nov 2016, 3:11 PM
dopi
+ 1
please koi easy example bataiye
10th Nov 2016, 8:54 PM
Sanchit Srivastava