Reply to Issues with array counts

Your name:

Reply:


Posted by PSI_Orion on 06/23/06 16:37

I have a table set up which has 4 columns. However, when I use the sizeof()
function on the array, it always returns DOUBLE the number of columns. Here
is an extract of my code...

function createDefaults($tableName,$userName,$configName,$dateModified)
{
$query="SELECT * FROM ".$tableName." WHERE id='0';";
$result = mysql_query($query);
if(!$result)
die("ERROR RETRIEVING DEFAULT DATA FROM '".$tableName."");
$dataArray = mysql_fetch_array($result);

$query="INSERT INTO ".$tableName." VALUES
('0','$userName','$configName','$dateModified'";
$colCount = sizeof($dataArray) / 2; <*************** this is where
it's returning double the column count, hence the / 2
for($count = 0; $count < $colCount - 4; $count++) // the -4 is a
standard set of columns put in each table
{
$query .= ",DEFAULT";
}
$query .= ");";
$result = mysql_query($query);
if(!$result)
die("ERROR SAVING DEFAULT DATA IN
'".$tableName."'<br>".mysql_error()."</p>");
}

Can anyone explain why?

Oh, if I do a print out of the array for each entry returned by sizeof(ie: 8
for 4 columns) it does say it's an empty or undefined index.

One side note, where I'm doing a lot of testing and I'm using auto increment
on the ID field, how can I restet the values so it starts from, lets say, 2
instead of 50?

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация