I have a wireless card called a WiFly RN-XV that I am using to to send data to a PHP script on my drupal server. The script currently writes that data to an HTML file on the server.

     $rtc_sec=$rtc_val % 60; $rtc_val/=60;
     $rtc_min=$rtc_val % 60; $rtc_val/=60;
     $rtc_hr =$rtc_val % 24; $rtc_val/=24;
     echo "Got data " . $data . " " . $rtc;
     $dataf=fopen($file_name, 'w') or die();
     flock($dataf, 2) or die();
     fputs($dataf,"<head>\n<title>User Data</title></head>\n");
     fputs($dataf,"Id:   " . $id   . "<br>");
     fputs($dataf,"Mac:  " . $mac  . "<br>");
     fputs($dataf,"Data: " . $data . "<br>");
     fputs($dataf,"RTC:  " . $rtc  . "<br>");
     fputs($dataf,"ID:   " . $id   . "<br>");
     fputs($dataf,"BSS:  " . $bss  . "<br>");
     fputs($dataf,"Bat:  " . $bat  . "<br>");
     fputs($dataf,"IO:   " . $io   . "<br>");
     fputs($dataf,"Wake: " . $wake . "<br>");
     fputs($dataf,"Seq:  " . $seq . "<br>");

Since I am not that familiar with PHP, I was wondering if anyone knows a better way to import data using PHP in to Drupal. I only really need to import in to one page, view, or block.

I have also tried Feeds using an XPATH HTML parser, but am having problems filtering out the HTML from the actual data.

Any help would be greatly appreciated.


VM’s picture

per: https://drupal.org/node/643758 please edit the opening post and move this thread to a more appropriate forum. As you have code, the most appropriate forum would be the module development and code questions forum.

coffeenmusic’s picture

Well I figured out how to add this information in to a database (see below), but I am still at a loss for how to take the database information and graph it. Does any one have an idea of how to pull database values in to Views or straight in to a chart/graph? I have tried the data module, which I was able to pull database info but cannot see it in Views. I can't seem to find a chart module that pulls directly from a database.

PHP file to get WiFly module data in to my database:


$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);

if (!$link){
    die('Could not connect:' . mysql_error());

$db_selected = mysql_select_db(DB_NAME, $link);

    die('Can\'t use ' . DB_NAME . ': ' . mysql_error());

echo 'Connected Successfully!';

$channel2hexshift=str_pad($channel2hex, 5, "0", STR_PAD_RIGHT);    

$sql = "INSERT INTO wifly (CH2) VALUES ('$channel2millivoltage')";

    die('Error: ' . mysql_error());

Jaypan’s picture

What does this have to do with Drupal? Your code is for a non-Drupal script.

I will soon be leaving the Drupal forums permanently. To understand why, please see this thread.

coffeenmusic’s picture

My question is Drupal related, I am using this on my Drupal site, and I was hoping to help anyone else with similar issues out in the future.