Jump to content

Recommended Posts

I am a newbie and I am in need of some help.  Currently, I have a email being piped to a program via cpanel "forwarder" advance tap. The parsing seeems to be doing its function but I cannot get it to insert the data into the table.  HEre is hte code prior to insert.  Can someone help me understand how to write this correct.  The idea is that for every new alert extract the date, then insert in to the table.  yOU help would be appreciated!

 

$sql = "INSERT INTO `LOG_TABLE` (`Type`, `Symbol`, `Score`, `Timestamp`) VALUES ";

foreach($alerts as $alert) {
    preg_match("!^Alert[1-9]+ \((MRI|QT)\):<br />(.*?)$!i", trim($alert), $m);
    $stocks = explode(", ", trim($m[2]));
    foreach($stocks as $stock) {
        list($symbol, $score) = explode(":", $stock);
        $sql .= "('".$m[1]."', '".$symbol."', '".$score."', FROM_UNIXTIME(now()), ";
    }
}
    $sql = trim($sql, " ,");


if ( ! empty($sql) )
    mysqli_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS);
    mysqli_select_db(DB);
    mysqli_query($sql)or die(mysql_error());

}

exit(0);
 

Link to comment
https://forums.phpfreaks.com/topic/280914-newbie-needs-help/
Share on other sites

The first thing you should have to learn after writting the script is how to debug it?

 

So, as a newbie read these articles, then re-write your script, give us all errors that you'll get and come back again.

 

1. Debugging: A Beginner's guide

 

2. How To Ask Questions The Smart Way

 

3. Php security tutorial

Link to comment
https://forums.phpfreaks.com/topic/280914-newbie-needs-help/#findComment-1443809
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.