Jump to content

get it going mates


djdellux

Recommended Posts

how do i combine these to start a viewer for VoIP phone call data

 

<?php
        $dbvoip = sqlite_open('voip.sqlite');

        if ($dbvoip == false)
        {
                die ('Unable to open database');
        } else {
                echo 'Database created.';
        }
        $dbquery = 'INSERT INTO voip () VALUES ()';

        $dbresult = sqlite_query($dbvoip, $dbquery);

        sqlite_close($dbvoip)

?>


<?PHP
$dbinfo=file("master.csv");

foreach ($dbinfo as $value)
{
  echo  $value . "<br />";
}
?>

Link to comment
Share on other sites

here is an example of the excel/csv tbl

 

C0 number1 number2 type number3 linetype c1 dial c2 date1

 

date2 date3 c3 c4 anw DOCUMENTATION unix C17

                            18005673786 15867569100 internal 18005673786 SIP/PTIline1-08f109b8 IAX2/rapidvox-5145 Dial IAX2/rapidvox/15867569100,,T 11/13/2008 14:20 11/13/2008 14:20 11/13/2008 14:20 18 5 ANSWERED DOCUMENTATION 1226586019

PTIline1 s default PTIline1 IAX2/atl-its02-14375 11/13/2008 14:22 11/13/2008 14:22 11/13/2008 14:22 1 0 ANSWERED DOCUMENTATION 1226586152

PTIline1 1517 internal "PTIline1" <PTIline1> SIP/PTIline1-08f109b8 IAX2/atl-its02-14375 Dial SIP/CSEline4,,D(1517) 11/13/2008 14:22 11/13/2008 14:22 11/13/2008 14:22 3 2 ANSWERED DOCUMENTATION 1226586152

PTIline1 1517 internal "PTIline1" <PTIline1> SIP/PTIline1-08f109b8 IAX2/atl-its02-3090 Dial SIP/CSEline4,,D(1517) 11/13/2008 14:25 11/13/2008 14:25 11/13/2008 14:25 3 2 ANSWERED DOCUMENTATION 1226586343

PTIline1 1517 internal "PTIline1" <PTIline1> SIP/PTIline1-08f109b8 IAX2/atl-its02-10920 Dial SIP/CSEline4,,D(1517) 11/13/2008 14:27 11/13/2008 14:27 11/13/2008 14:27 3 2 ANSWERED DOCUMENTATION 1226586431

PTIline1 s default PTIline1 IAX2/atl-its02-7470 11/13/2008 14:27 11/13/2008 14:27 11/13/2008 14:27 1 0 ANSWERED DOCUMENTATION 1226586464

PTIline1 1517 internal "PTIline1" <PTIline1> SIP/PTIline1-08f23418 IAX2/cse-its04-11584 Dial SIP/CSEline4,,D(1517) 11/13/2008 14:27 11/13/2008 14:27 11/13/2008 14:27 3 2 ANSWERED DOCUMENTATION 1226586464

PTIline1 s default PTIline1 IAX2/atl-its02-12742 11/13/2008 14:29 11/13/2008 14:29 11/13/2008 14:29 1 0 ANSWERED DOCUMENTATION 1226586570

PTIline1 1517 internal "PTIline1" <PTIline1> SIP/PTIline1-08f23418 IAX2/cse-its04-12179 Dial IAX2/cse-its04/1517,20,tTg 11/13/2008 14:29 11/13/2008 14:29 11/13/2008 14:29 10 9 ANSWERED DOCUMENTATION 1226586570

 

 

 

 

excuse th crudeness im really busy and multitaskin like a mad man sorry guys

 

Link to comment
Share on other sites

You need to put your $dbquery and $dbresult inside your foreach loop.  You need to put your column names in the first () in your $dbquery.  You also need to take the $value in your foreach loop and explode it and then implode it into a comma separated list of values (don't forget to put quotes around them).  Then you will put that in the second () of your $dbquery.  Make sure your list of values are in the same order as your columns like so:

 

insert into voip (column1, column2, column3, etc.. values (value1, value2, value3, etc...)

 

 

Link to comment
Share on other sites

ok well im a little off with the explode\implode stuff

 

heres what i have so far

 

 

<?php
        $dbvoip = sqlite_open('voip.sqlite');

        if ($dbvoip == false)
        {
                die ('Unable to open database');
        } else {
                echo 'Database created.';
        }

$dbinfo=file("master.csv");

foreach ($dbinfo as  $line) {
    echo $line;
}
        $dbquery = 'INSERT INTO voip (C0, number1, number2, type, number3, linetype, c1, dial, c2, date1, date2,
date3, c3, c4, anw, DOCUMENTATION, unix, C17)
VALUES (' . $var1 . ',' . $var2 . ',' . $var3 . ',' . $var4 . ',' . $var5 . ',' . $var6 . ',	' . $var7 . ',' . $var8 . '	,' . $var9 . '
,' . $var10 . ',' . $var11 . ',' . $var12 . ',' . $var13 . ',' . $var14 . ',' . $var15 . ',' . $var16 . ',' . $var17 . ',' . $var18 . ')';



        $dbresult = sqlite_query($dbvoip, $dbquery);

        sqlite_close($dbvoip)

?>

 

 

i know thats what i should use but im not sure how

Link to comment
Share on other sites

any input on this code criticism is always welcome

 

<?php
        $dbvoip = sqlite_open('voip.sqlite');

        if ($dbvoip == false)
        {
                die ('Unable to open database');
        } else {
                echo 'Database created.';
        }

$dbinfo=file("master.csv");

foreach ($dbinfo as  $line) {
    echo $line;
}
$dbquery = explode(" ", $var);
    for($i = 0; $i < count($var); $i++){
echo "$i = $var[$i] <br />";

        $dbquery = 'INSERT INTO voip (C0, number1, number2, type, number3, linetype, c1, dial, c2, date1, date2,
date3, c3, c4, anw, DOCUMENTATION, unix, C17)
VALUES (' . $var1 . ',' . $var2 . ',' . $var3 . ',' . $var4 . ',' . $var5 . ',' . $var6 . ',	' . $var7 . ',' . $var8 . '	,' . $var9 . '
,' . $var10 . ',' . $var11 . ',' . $var12 . ',' . $var13 . ',' . $var14 . ',' . $var15 . ',' . $var16 . ',' . $var17 . ',' . $var18 . ')';

}
        sqlite_close($dbvoip)

?>

Link to comment
Share on other sites

  foreach ($dbinfo as  $line) {
    echo $line;

$dbquery = explode(" ", $line);
$data = "'" . implode("','",$dbquery) . "'";

   $dbquery = "INSERT INTO voip (C0, number1, number2, type, number3, linetype, c1, dial, c2, date1, date2,
   date3, c3, c4, anw, DOCUMENTATION, unix, C17)
   VALUES ($data)";
   // ^ just creates the query string.  You need to actually insert it into db with mysql_query or whatever function for the db you're using
}

 

Link to comment
Share on other sites

wow wtf is goin on....

 

 

im getting this error

 

Database created.

Notice: Undefined variable: data in c:\program files\Apache\htdocs\csv2.php on line 15

 

Warning: implode() [function.implode]: Bad arguments. in c:\program files\Apache\htdocs\csv2.php on line 19

 

Warning: implode() [function.implode]: Bad arguments. in c:\program files\Apache\htdocs\csv2.php on line 19

 

Warning: implode() [function.implode]: Bad arguments. in c:\program files\Apache\htdocs\csv2.php on line 19

 

Warning: implode() [function.implode]: Bad arguments. in c:\program files\Apache\htdocs\csv2.php on line 19

 

 

 

 

heres the code

 

 

<?php
        $dbvoip = sqlite_open('voip.sqlite');

        if ($dbvoip == false)
        {
                die ('Unable to open database');
        } else {
                echo 'Database created.';
        }

$dbinfo=file("master.csv");


foreach ($dbinfo as  $line) {

    $data = "'" . implode("','",$dbquery) . "'";
    
    //print_r($dbquery);


$dbquery = "INSERT INTO voip (C0, number1, number2, type, number3, linetype, c1, dial, c2, date1, date2,
   date3, c3, c4, anw, DOCUMENTATION, unix, C17)
   VALUES ($data)";
   
    
}
           sqlite_close($dbvoip)

?>

 

 

its driving my nuts help a newbie out man

Link to comment
Share on other sites

Dude come on, I understand you may be a "newbie" to php, but you need to try harder, use some logic.  Use some common sense.  Look at the error message.  It says your implode has a bad argument.  So look at the arguments in your implode().

 

"','" and $dbquery

 

If you look at implode in the manual, you will see that the first argument is a string that will act like glue, and the 2nd argument is an array to glue together.  Since a string can be anything, chances are the bad argument is your $dbquery. 

 

So look at $dbquery.  Where is it coming from? Look at your code.  You don't assign anything to $dbquery before that implode.  Therefore, you are passing a bad argument.  Why did you take this line...

 

$dbquery = explode(" ", $line);

 

... out from the code?  That takes the current line in your foreach loop and explodes it into an array: the array you need for the implode. 

 

And even after all that is done, your code still will only generate a query string.  It's not actually inserting it into your database.  Read the documentation. 

 

I promise you, I don't mean to sound harsh.  But if you're wanting to do this in an effort to learn php in general, I suggest you put this project on hold and back up a few steps and start with the basics.  Syntax, etc... If you're just trying to do this in an effort to get a project done for your boss or something, and don't really have a desire to learn php in general, I suggest you consider just forking over a few bucks and having someone else do it for you, because (again, nothing personal) you're trying to work at level B when you haven't really learned level A.  Even if you do manage to bluff your way through it, you're not going to understand what's going on and that can potentially be a very, very bad thing.  I mean, you're struggling with just getting it to work.  You probably haven't even considered how to make it secure, so someone doesn't come along and wtfpwn your database.

 

 

Link to comment
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.