PHP Programming with MySQL
- Why do I get the following error and how do I connect to my database. Looks like I might need to use mysqli instead of mysql but I dont know how to do that or what to change. I appreciate it is you fixed anything that needs to be re-written.
Fatal error: Uncaught Error: Call to undefined
function mysql_connect() in
/Applications/XAMPP/xamppfiles/htdocs/Week9/VerifyLogin.php:12
Stack trace: #0 {main} thrown in
/Applications/XAMPP/xamppfiles/htdocs/Week9/VerifyLogin.php
on line 12
Line 12: $DBConnect = @mysql_connect("localhost", "root", "");
Here is my code for VerifyLogin.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<title>Verify Intern Login</title>
</head>
<body>
<h1>College Internship</h1>
<h2>Verify Intern Login</h2>
<?php
{
$errors = 0;
$DBConnect = @mysql_connect("localhost", "root", "");
if ($DBConnect === FALSE) {
echo "
<p>
Unable to connect to the database
server. " . "Error code " . mysql_errno() . ": " . mysql_error() . "
</p>\n";
++$errors;
} else {
$DBName = "internships";
$result = @mysql_select_db($DBName, $DBConnect);
if ($result === FALSE) {
echo "
<p>
Unable to select the database. " . "Error code " . mysql_errno($DBConnect) . ": " . mysql_error($DBConnect) . "
</p>\n";
++$errors;
}
}
}
{
$TableName = "interns";
if ($errors == 0) {
$SQLstring = "SELECT internID, first, last FROM
$TableName" . " where email='" . stripslashes($_POST['email']) . "' and password_md5='" . md5(stripslashes($_POST['password'])) . "'";
$QueryResult = @mysql_query($SQLstring, $DBConnect);
if (mysql_num_rows($QueryResult) == 0) {
echo "
<p>
The e-mail address/password " . " combination entered is not valid.
</p>\n";
++$errors;
} else {
$Row = mysql_fetch_assoc($QueryResult);
$InternID = $Row['internID'];
$InternName = $Row['first'] . " " . $Row['last'];
echo "
<p>
Welcome back, $InternName!
</p>\n";
}
}
}
{
if ($errors > 0) {
echo "
<p>
Please use your browser's BACK button
to return " . " to the form and fix the errors
indicated.
</p>\n";
if ($errors > 0) {
echo "
<p>
Please use your browser's BACK button
to return " . " to the form and fix the errors
indicated.
</p>\n";
}
}
}
?>
</body>
</html>
As far as your code is concern, Everything is fine and working fine in my device.
Check if you have turned on the mysql server.
If you still getting the same error, The error is because of improper installation of php. Better reinstall php with sql support correctly.
And make sure you are using php version less than 7.* to make sure mysql_* functions work properly.
Hope your problem solved.
Feel free to ask doubts in comment section below.
PHP Programming with MySQL - Why do I get the following error and how do I...
My 2nd Try asking the same "PHP Programming with MySQL question. When I run my code, I get the following messages: Notice: Undefined index: email in /Applications/XAMPP/xamppfiles/htdocs/Week9/VerifyLogin.php on line 71 Notice: Undefined index: password in /Applications/XAMPP/xamppfiles/htdocs/Week9/VerifyLogin.php on line 71 Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in /Applications/XAMPP/xamppfiles/htdocs/Week9/VerifyLogin.php on line 75 The e-mail address/password combination entered is not valid. Please use your browser's BACK button to return to the form and fix the errors indicated. Please use...
I am having an issue. When i press submit to test the code, it goes to a blank screen. Please, will some one assist me? Thanks! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Sign Guest Book</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> </head> <body> <?php if (empty($_POST['?rst_name']) || empty($_POST['last_name'])) echo "<p>You must enter your ?rst and last name! Click your browser's Back button to return to the Guest Book form.</p>"; else { $DBConnect = @mysql_connect("localhost", "root", ""); ...
MySQL 8 Create a PHP program that will read in each table of the database you created in Assignment 8 and display the values into a good looking table. When I run it, I'm having this error " Parse error: syntax error, unexpected '$dbName' (T_VARIABLE) in C:\xampp\htdocs\assignment9\includes\dbh.inc.php on line 6' Here is my index.php <?php include_once 'includes/dbh.inc.php'; ?> <!DOCTYPE html> <html> <head> <title></title> </head> <body> <?php $sql = "SELECT * FROM comic_book.books;"; $result = mysqli_query($conn, $sql);...
PHP Programming In this project, you will create a Web page that allows visitors to your site to sign a guest book that is saved to a database. Create a new document in your text editor and type the <!DOCTYPE> declaration, <html> element, document head, and <body> element. Use the strict DTD and “Guest Book” as the content of the <title> element. Add the following text and elements to the document body: <h2>Enter your name to sign our guest book</h2>...
How can I convert $num_rows to PDO? See errors below code ** (PHP, MySQL, HTML) $sql = "SELECT testN, testG from testTab"; $res = $db -> query($sql); ** if ($res-> $num_rows >0) { while($row = $result-> fetch_assoc()) { echo "". $row["testN"] ."". $row["testG"]. ""; if($row['testG'] < 60) { echo "". "F" .""; } elseif($row['testG'] >= 60 and $row['testG']<=69) { echo "". "D" .""; } } echo ""; } else { echo("0 Result"); } ** Notice: Undefined variable: result...
C programming How to get rid of the below error. I do not know why is this happening and how can I correct it. Please help. typedef struct circleroute{ char* name; } Circle; Circle* circlemalloc(int nroutes); //error free Circle* readRoute(FILE* fin); //error free int main(int argc, char* argv[]){ if(argc < 2){ if(argv[1] != NULL){ FILE *fin = fopen(argv[1], "r"); if(fin == NULL){ printf("Unable to open file %s!\n", argv[1]); return EXIT_FAILURE; } int routes; fscanf(fin, "%d", &routes); Circle* c1= circlemalloc(routes); for(int...