im a beginner and also a diploma student... i trying to update my mysql database but there is some error... please help me solve it...
this is my error:
Fatal error: Uncaught Error: Call to undefined function mysql_select_db() in C:\xampp\htdocs\SLR\Update S110 PC01.php:17 Stack trace: #0 {main} thrown in C:\xampp\htdocs\SLR\Update S110 PC01.php on line 17
this is my code:
<html>
<body>
</br>
</br>
<center>
<div align="center">
</br>
</br>
</br>
<?php
include("dbconnect.php");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("s110_pc01", $con);
$sql = "UPDATE SET soft_name='$_POST[soft_name]', installed_date='$_POST[installed_date]', expiry_date='$_POST[expiry_date]', product_key='$_POST[product_key]' WHERE soft_id='$_POST[soft_id]'";
$retval=mysql_query($sql);
if(! $retval )
{
die('Could not Update data: ' . mysql_error());
}
echo "Successfully updated
";
mysql_close($con);
?>
<input type="button"value="Finish"onclick="window.location.href='managerhome.php'">
</form>
</table>
</div>
</body>
</html>
All of the mysql_*
functions are deprecated and have been removed from PHP 7. DO NOT USE THESE FUNCTIONS! Instead use either the mysqli functions or the PDO functions.
Vist http://php.net/manual/en/book.mysqli.php for more..
<?php
//Connect mysql database
$mysqli = new mysqli("example.com", "user", "password", "database");
//Catch error if your script failed to connect
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
//you can run any query like this
$query = "Your update or any sql query ...";
$mysqli->query($query)
//For example
//this will drop table if exist, create new table and insert a row
if (!$mysqli->query("DROP TABLE IF EXISTS test") ||
!$mysqli->query("CREATE TABLE test(id INT)") ||
!$mysqli->query("INSERT INTO test(id) VALUES (1)")) {
echo "Table creation failed: (" . $mysqli->errno . ") " . $mysqli->error;
}
?>
you can use this..
<?php
$hostname = "localhost";
$database = "yourdatabase";
$username = "root";
$password = "";
$db = mysql_pconnect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database, $db);
session_start();
$colum_name = $POST[''];
$colum_name = $POST[''];
$colum_name = $POST[''];
$qry = "UPDATE FROM table WHERE $column_name = ''";
$result = mysql_query($qry);
?>