My program is skipping a function in PHP -


my php script written send email , sms when new information entered in front end members in database. email code , sms code working individually, when put code not getting executed.

the code in fact skipped. tried making deliberate error in called function did not recognize it. why?

<?php     error_reporting(e_all ^ e_notice);      define('include_check', true);      require 'functions.php';     include ("generatesms.php");     include ("class.phpmailer.php");     include ("../sendsmsv3.5/sendsmsv3.5/curlprocess.php");     include ("../sendsmsv3.5/sendsmsv3.5/way2sms.php");     include ("class.smtp.php");      // above files can included if include_check defined     $host     = "localhost"; // host name     $username = "root";      // mysql username     $password = "";          // mysql password     $db_name  = "test";      // database name     $tbl_name = "mails";     // table name      // connect server , select database.     mysql_connect($host, $username, $password) or die("cannot connect");     mysql_select_db($db_name)or die("cannot select db");      // values form     $subject  = $_post['subject'];     $email    = $_post['email'];     $phone    = $_post['phone'];     //$dept   = $_post['dept'];     $content  = $_post['content'];     $month    = $_post['birthday-mm'];     $day      = $_post['birthday-dd'];     $year     = $_post['birthday-yyyy'];     $date_eve = "$year-$month-$day";     $dept     = $_post['branch'];      if (empty($dept)) {         echo("you didn't select depeartments.");     } else {         $n = count($dept);          for($i=0; $i < $n; $i++) {                echo $dept[$i]; echo "<br>";             $dep = $dept[$i];              // insert data mysql            $sql = "insert $tbl_name(subject, body, dept, phone, email, date_eve) values ('$subject', '$content', '$dep', '$phone', '$email', '$date_eve')";             $result = mysql_query($sql);             // if insert data database, displays message "successful".            if ($result) {                echo "successful";                echo "<br>";                newssender($dept, $content, $subject);                generatesms($dept,$date_eve,$subject);                 echo "<a href='index.php'>back main page</a>";            } else {                echo "error";            }        }     }      // close connection     mysql_close(); 

firstly have big problem of sql. shouldn't use mysql_* functions deprecated , you're not sanitizing inputs leaving exposed vulnerabilities. (http://www.tizag.com/mysqltutorial/mysql-php-sql-injection.php)

if pose newssender() function code can give detailed/specific answer in meantime give general solution goes through debugging processes other users.

if have code this:

myfunction1(); myfunction2(); 

and myfunction1() run myfunction2() not, can try commenting out // myfunction1() (which sounds did) , @ point if myfunction2() runs problem resides in myfunction1(). here things for:

  1. fatal errors. make sure have errors , notices turned on find syntax or other errors in code
  2. look die or exit may exist in code. end script , no more code executed.

a quick way test #2 this:

myfunction1(); echo 'i made here!'; 

if don't see "i made here!" on screen code didn't far, meaning code ended before returned myfunction1()

i hope helps!


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -