Jump to content

Firebird query to update MYSQL - Loop


radagast

Recommended Posts

Hello

 

I am hoping someone can PLEASSSSSSE help me :confused:

 

I am trying to do the following php Script..

 

 

//Getting Information for firebird database from supplier/distributor

 

try {

    $dbh = new PDO($dsndb, $userdb, $passdb);

 

    $sth = ("SELECT * from order WHERE account_number = 'abc123'");

 

 

  foreach ($dbh->query($sth) as $row)

     

// If I do print $row['order_number'].' - '. $row['customer_ref'] . '<br />'; returns all data..

    {

    $row['order_number'];

$row['customer_ref'];

      }

 

} catch (PDOException $e) {

  echo 'You have the following error : ' . $e->getMessage() . "<br/>";

  die();

}

 

$on = $row['order_number'];

$ref =  $row['customer_ref'];

 

// Need to update MYSQL Database but not sure how to create loop??????

 

 

 

        mysql_connect("localhost", "user", "password") or die(mysql_error());

mysql_select_db("xoccoza_online") or die(mysql_error());

 

$sql = "UPDATE customer SET customer_ref = '$ref' WHERE order_number = '$on' and customer_ref IS NULL";

$result=mysql_query($sql) or die(mysql_error());

 

 

Any and all help will be greatly appreciated

Link to comment
Share on other sites

Hi Thorpe

 

Thanks for responding.

 

I tried many different scenarios to retrieve the data from the Firebird Database and the select seems to be the only one to work.

 

If you have another method that will work please let me know.

 

Thanks

Link to comment
Share on other sites

Ok, it wasn't clear from your post that the SELECT was selecting data from a different database.

 

On to your issue. You already have the loop, you just need to move your mysql UPDATE code into it.

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.