I want to ensure that the correct file is loaded depending on whether the GET parameter site is present or not. Can someone tell me what I am doing wrong or how to get this right?
I need also an MakeStatement function. The parameters are: $query and $array is there anything to improve about this code? Thanks!
Can anyone help me to complete my code or write it correctly?
function getSite($site) {
if(isset($_GET['site'])) {
include_once($_GET['site']);
} else {
include_once($site);
}
}
function makeStatment($query, $array = null)
{
$stmt = $con->prepare($query);
$stmt->execute($array);
return $stmt;
}
Roki007 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1
try using this
function getSite($site)
{
if(isset($_GET['site']))
{
include_once('site/'.$_GET['site'].'.php');
}
else
{
include_once('site/'.$site.'.php');
}
}
function makeStatment($query, $array = null)
{
try
{
global $con;
$stmt = $con->prepare($query);
$stmt->execute($array);
return $stmt;
}
catch (Exception $e)
{
return $e;
}
}
KraffenboeckF is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.