unistake Posted October 25, 2010 Share Posted October 25, 2010 Hi all, I have a simple script that does not work! I think it may be to do with $num = mysqli_num_rows($result) and $row = mysqli_assoc_result($result). I have tried echoing the value which works if I put it above the include("cxn.php");. The code is: <?php include("cxn.php"); $sql = "SELECT * FROM table WHERE email='$_POST[email]'"; $result = mysqli_query($cxn,$sql) or die("Cant execute query!"); $num = mysqli_num_rows($result); $row = mysqli_fetch_assoc($result); if ($num > 0) { $to = "$_POST[email]"; $subj = "from the website"; $mess = "Your value is".$row['value']; $mailsend = mail($to,$subj,$mess,$headers); echo "email sent to $_POST['email']"; } else { echo "email not found!";} ?> Quote Link to comment Share on other sites More sharing options...
revraz Posted October 25, 2010 Share Posted October 25, 2010 Any errors? What doesn't work? You have a $headers variable, but nothing is in it. Quote Link to comment Share on other sites More sharing options...
unistake Posted October 25, 2010 Author Share Posted October 25, 2010 That is all the php page, it does not show any errors. Quote Link to comment Share on other sites More sharing options...
revraz Posted October 25, 2010 Share Posted October 25, 2010 Maybe it is working but it's being filtered as Junk Mail. Did you check the server log to see if it's getting sent? Quote Link to comment Share on other sites More sharing options...
unistake Posted October 25, 2010 Author Share Posted October 25, 2010 I am not getting the email and the echo after the email is not showing. Quote Link to comment Share on other sites More sharing options...
revraz Posted October 25, 2010 Share Posted October 25, 2010 Check your server log, do you have a SMTP server setup? Quote Link to comment Share on other sites More sharing options...
unistake Posted October 25, 2010 Author Share Posted October 25, 2010 Yes the email from the site works fine and I have checked the SMTP, I have another script from which I copied and pasted the email part of this script above. if I put echo $_POST['email'] after the $result = mysqli_query($cxn,$sql) or die("Cant execute query!"); it does not work. Any ideas? Quote Link to comment Share on other sites More sharing options...
unistake Posted October 25, 2010 Author Share Posted October 25, 2010 anyone? Quote Link to comment Share on other sites More sharing options...
mentalist Posted October 25, 2010 Share Posted October 25, 2010 I have tried echoing the value which works if I put it above the include("cxn.php");. Sounds like there's an error in cxn.php... Also if 'die' is reached and executed, then there is no more execution, so if it works before but not after then it must be between. Logicalsss Quote Link to comment Share on other sites More sharing options...
unistake Posted October 25, 2010 Author Share Posted October 25, 2010 ofcourse! but there is not a problem with it. I use the same include("cxn.php") for the rest of the site. The webpages are in the same directory. Quote Link to comment Share on other sites More sharing options...
unistake Posted October 25, 2010 Author Share Posted October 25, 2010 This works.. <?php include("cxn.php"); $sql = "SELECT * FROM Members WHERE email='$_POST[email]'"; $result = mysqli_query($cxn,$sql) or die("Cant execute query!"); $row = mysqli_fetch_assoc($result); echo $row['field']; ?> the script does not work when I include the $num = mysqli_num_rows($result) and also the email part of the script. Quote Link to comment Share on other sites More sharing options...
mentalist Posted October 25, 2010 Share Posted October 25, 2010 When you say "does not work", please give the actual details otherwise were guessing... Quote Link to comment Share on other sites More sharing options...
unistake Posted October 25, 2010 Author Share Posted October 25, 2010 got it to work somehow! I started to write it again and it works?! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.