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
link: https://hard-questions.com/try/ggg.php
also in other all browsers… why? what i must do resolve?
I didn’t post that article for mistake, plz read it.
also:
$con mysql_connect("sql300.epizy.com","epiz_24872058","plz censor","");
should be:
$con = mysqli_connect("sql300.epizy.com","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/epizy.com/epiz_24872058/htdocs/try/ggg.php 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/epizy.com/epiz_24872058/htdocs/try/ggg.php:28 Stack trace: # 0 {main} thrown in / home / vol6_5 / epizy.com / epiz_24872058 / htdocs / try / ggg.php on line 28
sorry if I’m bothering you too much but I’m new to this field ![]()
![]()
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>
<html>
<head>
<title>Search Bar using PHP</title>
</head>
<body>
<form method="post">
<label>Search</label>
<input type="text" name="search">
<input type="submit" name="submit">
</form>
</body>
</html>
<?php
$con = new PDO("mysql:host=sql300.epizy.com;dbname=epiz_24872058_hardquestions",'epiz_24872058','your password');
//$con mysql_connect("sql300.epizy.com","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())
{
?>
<br><br><br>
<table>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
<tr>
<td><?php echo $row->Name; ?></td>
<td><?php echo $row->Description;?></td>
</tr>
</table>
<?php
}
else{
echo "Name Does not exist";
}
}
?>
Thanks so much, thanks, thanks thanks and thanks ![]()