|
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?
Navigation:
[Reply to this message]
|