+ 1
How to use mysql queries in php
mysql
3 Respostas
+ 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.
+ 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
+ 1
please koi easy example bataiye