Error 500 caused by connecting to the mysql database

Hi everyone … I am creating an internal search engine to search for articles, only going to connect my php file to the mysql database once I visit the page gives me error 500 the page does not work … I leave you the code and the link to the page.
this is the code: Nov 04 4:45 PM - Codeshare

Search Bar using PHP Search


also in other all browsers… why? what i must do resolve?

I didn’t post that article for mistake, plz read it.


$con mysql_connect("","epiz_24872058","plz censor","");

should be:

$con = mysqli_connect("","epiz_24872058","plz censor","database name must be entered");

The error that he show is Parse error : syntax error, unexpected ‘mysql_connect’ (T_STRING) in /home/vol6_5/ on line 21
But i don’t understand what is error of syntax, (i think the lines 21 is righ)

updated my post.

Edit: you must use PDO connection instead of mysqli ones because your codes are PDO related.


sorry but where i can find the database name?

from Cpanel->Phpmyadmin


this? epiz_24872058_hardquestions

if exists yes.

just one thing off the topic, what does this mean? Fatal error: Uncaught Error: Call to undefined method mysqli_stmt :: setFetchMode () in /home/vol6_5/ Stack trace: # 0 {main} thrown in / home / vol6_5 / / epiz_24872058 / htdocs / try / ggg.php on line 28

sorry if I’m bothering you too much but I’m new to this field :sweat_smile::disappointed_relieved:

np, it’s ok to ask and learn

It’s because you’re connecting with mysqli, but the rest of functions only work with pdo. I’ll fix the code:

<!DOCTYPE html>
	<title>Search Bar using PHP</title>

<form method="post">
<input type="text" name="search">
<input type="submit" name="submit">



$con = new PDO(";dbname=epiz_24872058_hardquestions",'epiz_24872058','your password');
//$con mysql_connect("","epiz_24872058","...");

if (isset($_POST["submit"])) {
	$str = $_POST["search"];
	$sth = $con->prepare("SELECT * FROM `search` WHERE Name = '$str'");

	$sth->setFetchMode(PDO:: FETCH_OBJ);
	$sth -> execute();

	if($row = $sth->fetch())
				<td><?php echo $row->Name; ?></td>
				<td><?php echo $row->Description;?></td>

			echo "Name Does not exist";



Thanks so much, thanks, thanks thanks and thanks :wink:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.