Hello
My host has just changed the mysql version from 4.x to 5.x and most of my code has stopped working 🙁 If I do a really simple call to the database then I can retreive records. However, most of my code is rather less than simple and I have no idea where to start with fixing it. Before I completely panic, can someone please take a look at this relatively simple piece of code and suggest why it may not be working and hopefully I will learn something that will help me start to fix the rest of it.
This handles an email newsletter form with a single field called "em" and should just insert it into the database (providing the format is correct). But even though the email is correct format I always get the error, "Your email address is not correct", and so nothing is inserted into the database.
<?php
require_once ('../mysql_connect.php');
$status = "OK"; // setting the flag to check the status
$msg=""; // setting the variable for message
if (!stristr($em,"@") OR !stristr($em,".")) {
$msg="Your email address is not correct<BR>";
$status= "NOTOK";}
echo "<br><br>";
if($status=="OK"){// Now the email is valid and we can add to our database
$query=("INSERT INTO nl_subscribe (em,status) VALUES ('$em','subscribe')");
$result=mysql_query($query);
echo "<center>THANK YOU <br>Thanks for subscribing to our newsletter and any time you can unsubscribe by clicking a link in your newsletter</center>";
}
else {echo "<center>$msg </center>";} // this will display the error message if email address is not valid one.
?>
Thanks for any help!