FRIHOSTFORUMSSEARCHFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Php while array problem

 


flatliner
hey every1 ok here is my problem, I have a task in which I need to tranfer information from one mysql database to another (on my frih account actually), on a regular basis. here is the script I have made and it did work fine for the frist few test runs, but now its not work properly. What happens is only some of the row's get inputted. I have played around with it for ages and cant find the problem, I belive its somthing to do with the variable I am using to while out the query code. $i

Code:
<?php
// Make a MySQL Connection
$con = mysql_connect("host", "user", "pass") or die(mysql_error());
$con2 =  mysql_connect("host", "user", "pass) or die(mysql_error());

mysql_select_db( "db", $con )or die(mysql_error());
mysql_select_db( "db", $con2 )or die(mysql_error());


$result = mysql_query("SELECT * FROM oakstown WHERE emailed = 'no'", $con)
or die(mysql_error());

$total_to_be_emailed = mysql_num_rows($result);

While($row = mysql_fetch_array( $result ))
{

array ($doc[]                       = "$row[id]");
array ($date2[]                 = "$row[date]");     
array ($tick[]                     = "$row[tick]");                     
array ($invoice_name2[]           = "$row[invoice_name]" );
array ($invoice_address2[]          = "$row[invoice_address]" );
array ($telephone12[]             = "$row[telephone1]" );
array ($telephone22[]             = "$row[telephone2]" );
array ($fax2[]                     = "$row[fax]" );
array ($delivery_name2[]            = "$row[delivery_name]" );
array ($delivery_address2[]         = "$row[delivery_address]" );
array ($telephone32[]               = "$row[telephone3]" );
array ($digger_driver2[]            = "$row[digger_drivers]" );
array ($price2[]                    = "$row[price]" );
array ($payment2[]                  = "$row[payment]" );
array ($system2[]                   = "$row[system]" );
array ($distribution_box22[]        = "$row[distibution_box]" );
array ($cable2[]                    = "$row[cable]" );
array ($commission2[]               = "$row[comission]" );
array ($size2[]                     = "$row[size]" );
array ($type_of_lids2[]             = "$row[type_of_lid]" );
array ($wall_size2[]                = "$row[wall_sizes]" );
array ($wall_quantity2[]            = "$row[wall_quantity]" );
array ($facility_to_off_load2[]     = "$row[facility_to_off_load]" );
array ($facility_for_artic2[]       = "$row[facility_for_delivery]" );
array ($date_of_delivery2[]         = "$row[date_of_delivery]" );
array ($am_or_pm2[]                 = "$row[am_or_pm]" );
array ($directions2[]               = "$row[direction]" );
      
   
      };

      $i = 0;
      
While($i < $total_to_be_emailed)
{


$i = $i+1;   

   
mysql_query("INSERT INTO oakstown
( id, date, tick, invoice_name, invoice_address, telephone1, telephone2, fax, delivery_name, delivery_address, telephone3, digger_driver, price, payment, system, distribution_box, cable, commission, size, distribution_box2, lid_types, l_wall_size, l_wall_quantity, facility_to_off_load, facility_for_artic, date_of_delivery, time_am_or_pm, directions, emailed, sold ) VALUES
('$doc[$i]', '$date2[$i]', '$tick[$i]',  '$invoice_name2[$i]', '$invoice_address2[$i]', '$telephone12[$i]', '$telephone22[$i]', '$fax2[$i]', '$delivery_name2[$i]', '$delivery_address2[$i]', '$telephone32[$i]' , '$digger_driver2[$i]', '$price2[$i]', '$payment2[$i]', '$system2[$i]', '$distribution_box2[$i]', '$cable2[$i]', '$commission2[$i]', '$size2[$i]', '$distribution_box22[$i]', '$type_of_lids2[$i]', '$wall_size2[$i]', '$wall_quantity2[$i]', '$facility_to_off_load2[$i]', '$facility_for_artic2[$i]', '$date_of_delivery2[$i]', '$am_or_pm2[$i]', '$directions2[$i]', '$no[$i]', '$no[$i]')", $con2)
or die(mysql_error());


};

?>
woodenbrick
Im not an expert but it seems to me that:
Code:
$i=$i+1;

should go under your insert query. It looks like you are missing all the array[0] because of this.[/code]
flatliner
I cannot belive I didnt see that, oh jas. thanks very much, it always seems to be the small litte things I miss that make big problems. That did it alright, but the one thing I cant understand was that it was just leaving out array[0] , it would leave out like every secound one, it was really wierd. Thanks very much again Very Happy
Related topics

A PHP problem !
How To : Improve Your PHP Programming
PHP login/logout problem
[PHP] Problem with Dynamic Sig's Font Color
php array() problem

PHP login script problem
PHP Array, explode, count , access array problem.
PHP include code problem
PHP homepage recreation problem
Problem with PHP

Problem Help out
php multidimension array question
PHP Form Sending problem
PHP page turning problem
PHP Form Processing Problem
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.