Forums

OnSubmit EventLoop Seems to cause Internal Server Error.

Kaphene 02 Jun, 2014
Hopefully somebody can help because what's happening makes no sense to me at all. I have an eventswitcher in onsubmit that evaluates if a field is already in the DB or not and it returns fail if it is already in the database and returns success if it's not already in the database. If while testing the form I put in information that will make it succeed I have no problems. However, if I put in information that will make it fail I just get an internal server error, which I suppose is better than it saving to the DB, but I'd rather have it reload and show a tiny error message.

<?PHP

$mysqli = new mysqli("00.00.00.00", "username", "password", "DB");

$SQL = "SELECT * FROM Kaphene_Teams";

if ($result = $mysqli->query("SELECT * FROM Kaphene_Teams WHERE TeamName = $form->data['TeamName'])) 
{
return fail;
}
else
{
return success;
}


The event switcher titles are Success and Fail and since I've just been trying to get it to work literally all I have is the default eventloop under fail. I think it's really odd that it will work if it's success but error 500 if it's fail. any thoughts?
GreyHead 02 Jun, 2014
HI Kapene,

Please debug your code, the first $SQL = . . . line does nothing; the second query line is almost certainly missing quotes around the $form->data['TeamName']

I'd also recommend that you you use the Joomla! database methods here.

Bob
This topic is locked and no more replies can be posted.