Jump to content

[SOLVED] $data =implode("','",$dbquery); ???


djdellux

Recommended Posts

i am having trouble with a specific line of code and have been emersed in my A+ cert over the last 2 wks so any help to bring me back to the world of php would be great heres the rest of 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  $dbquery) {

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

$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)

?>

Link to comment
https://forums.phpfreaks.com/topic/137035-solved-data-implodedbquery/
Share on other sites

implode() takes an array and converts to a string. Is your variable an array?

foreach ($dbinfo as  $dbquery) {
    $data =implode("','",$dbquery);
    print_r($dbquery);

 

Also lose the ' in the implode separator

$data = implode(",",$dbquery);

my whole intention is to insert info into the $dbquery variable

 

new code after tweking

does it look like this is accomplished

 

<?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  $dbquery);
{

   // $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 ($dbquery)";
   echo($dbquery);
    
}
           sqlite_close($dbvoip)

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.