this is what my server dude said
"As for the out of memory, you are using too many variables in your PHP script for the server to handle. There is an 8MB Memory allowance for each instance of a script, it will cause workload issues on the server if we allow any more memmory, so we can not increase the limit."
Im not the server admin, so I dont have access to shut down any programs or add memory. However my code does not have verymany variables...
What it does is open up a csv file and takes the records and then inserts them into a database, depending if its in there already.. it also links it to a category which has previously been entered into the database.. heres the code
PHP Code:
<?php
include "vars.php3";
$db =mysql_pconnect("localhost", "$mysql_username", "$mysql_password")
or die("Unable to connect".mysql_error());
mysql_select_db("$database",$db)
or die("lINE 6".mysql_error());
$fp = fopen("upload.csv", "r")
or die("error");
while (!feof($fp))
{
$fp2 = fgetcsv($fp, 200, ",");
$uid++;
$name = $fp2[0];
$address = $fp2[1];
$phone = $fp2[2];
$subcat[1]= $fp2[4];
$subcat[2]= $fp2[5];
$subcat[3]= $fp2[6];
$subcat[4]= $fp2[7];
$result=mysql_query("select * from users where name= '$name' AND address='$address'")
or die ("error occured line 120, the last name enttered was $name".mysql_error());
$test = mysql_affected_rows();
if ($test == 0)
{
$result=mysql_query("insert into users values ($uid, '$name','$phone','$address','','','0','','')")
or die(mysql_error());
echo"$name ($uid) <br>";
}
$y=0;
while ($y < 5)
{
$y++;
$result=mysql_query("select * from users, category, lookup WHERE users.uid = lookup.uid AND category.cid=lookup.cid AND users.name='$name' AND category.value='$subcat[$y]'");
$test=mysql_affected_rows();
if ($test == 0)
{
$result = mysql_query("select * from category where value='$subcat[$y]'");
$row=mysql_fetch_array($result);
$cid=$row[cid];
$result=mysql_query("insert into lookup values ($uid, $cid)");
}
}
}
3 tables are involved
users, which contains information like names, phone numbers and such
category wich has to collums cid and value
then lookup, whcih links the two primary keys together
lookup(uid, cid) //user id and category id
is my code really unefficient... its only getting through about 100 or so rows in hte csv before it dies on line
PHP Code:
$result=mysql_query("select * from users where name= '$name' AND address='$address'")
or die ("error occured line 120, the last name enttered was $name".mysql_error());
Bookmarks