Jump to content

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


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)

?>

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.