aeafisme23 Posted August 8, 2006 Share Posted August 8, 2006 [b]SQL DUMP: [/b][url=http://www.kindervision.org/anthonydwayne/sql.txt]http://www.kindervision.org/anthonydwayne/sql.txt[/url][font=Verdana][color=red]Any advice would rock!!! Thanks all that read![/color][/font][b]Error Message:[/b][code]Fatal error: Allowed memory size of 18388608 bytes exhausted (tried to allocate 11520 bytes) in /home2/admin/etc-www/etc/etc.php on line 12[/code][b]Problem:[/b]When clicking submit I add infinite enteries to the database.I need to find a way to insert from my form to how my database is setup so that it adds correct enteries and id's. Note the form has 3 sql queries because each input updates to a different table in the database. Once populated the chained select will show all enteries. I have provided a picture of the database tables, the first few enteries were manually entered in mySQL and works, but if i do it through a form it loops. I will produce codes to both the form and the chained select. I understand that the DB structure is jank and need a know how to setup correctly. I believe that the default 0 should go but i know it wont solve problem completely in its entirety.[img]http://loonar.net/table.jpg[/img][b]Code:[/b] (ADD.php) This is the form[code]<?phpif ($submit) { // process form$db = mysql_connect("www.domain.org", "user", "pass");mysql_select_db("database_org",$db);// Write the queries$sql = "INSERT INTO make (make_id, make) VALUES ('$make_id','$make')";$sql2 = "INSERT INTO model (model_id, model) VALUES ('$model_id','$model')";$sql3 = "INSERT INTO submodel(model_id, submodel) VALUES ('$model_id','$submodel')";// Execute the queriesmysql_query($sql) or die(mysql_error());mysql_query($sql2) or die(mysql_error());mysql_query($sql3) or die(mysql_error()); $result = mysql_query($sql); $result = mysql_query($sql2); $result = mysql_query($sql3); require("add.php"); echo('thank you for your add');} else{ ?> <table width="720" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000"> <tr> <td valign="top" bgcolor="ffffff"><FORM NAME=submit method="post" action="<?php echo $PHP_SELF?>"> <TABLE> <tr> <td width="140"><LABEL><b>Make:</b></LABEL></td> <td width="550"><INPUT TYPE=text NAME="make" ID="make" SIZE="35" MAXLENGTH="60"></td> <td width="10"> </td> </tr> </TABLE> <TABLE> <tr> <td width="140"><LABEL><b>Model:</b></LABEL></td> <td width="550"><INPUT TYPE=text NAME="model" ID="model" SIZE="35" MAXLENGTH="60"></td> <td width="10"> </td> </tr> </TABLE> <TABLE> <tr> <td width="140"><LABEL><b>Sub-Model:</b></LABEL></td> <td width="550"><INPUT TYPE=text NAME="submodel" ID="submodel" SIZE="35" MAXLENGTH="60"></td> <td width="10"> </td> </tr> </TABLE> <TABLE> <tr> <td width="140"> </td> <td width="550"><INPUT TYPE="Submit" NAME="submit" VALUE="Submit"></td> <td width="10"> </td> </tr> </TABLE></form><?php} // end if?>[/code][b]Chained Select[/b][code]<?php$dbservertype='mysql';$servername='localhost';// username and password to log onto db server$dbusername='user';$dbpassword='pass';// name of database$dbname='domain_org';////// DONOT EDIT BELOW /////////connecttodb($servername,$dbname,$dbusername,$dbpassword);function connecttodb($servername,$dbname,$dbuser,$dbpassword){global $link;$link=mysql_connect ("$servername","$dbuser","$dbpassword");if(!$link){die("Could not connect to MySQL");}mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error());}?><html><head><title>Year/Make/Model Multiple DD - Populated from Form</title><SCRIPT language=JavaScript>function reload(form){var val=form.make.options[form.make.options.selectedIndex].value; self.location='dd3.php?make=' + val ;}function reload3(form){var val=form.make.options[form.make.options.selectedIndex].value; var val2=form.model.options[form.model.options.selectedIndex].value; self.location='dd3.php?make=' + val + '&submodel=' + val2 ;}</script></head><body><?///////// Getting the data from Mysql table for first list box//////////$quer2=mysql_query("SELECT DISTINCT make,make_id FROM make order by make"); ///////////// End of query for first list box/////////////////// for second drop down list we will check if category is selected else we will display all the subcategory///// $cat=$HTTP_GET_VARS['make']; // This line is added to take care if your global variable is offif(isset($make) and strlen($make) > 0){$quer=mysql_query("SELECT DISTINCT model,model_id FROM model where make_id=$make order by model"); }else{$quer=mysql_query("SELECT DISTINCT model,model_id FROM model order by model"); } ////////// end of query for second subcategory drop down list box ////////////////////////////////// for Third drop down list we will check if sub category is selected else we will display all the subcategory3///// $cat3=$HTTP_GET_VARS['submodel']; // This line is added to take care if your global variable is offif(isset($submodel) and strlen($submodel) > 0){$quer3=mysql_query("SELECT DISTINCT submodel FROM submodel where model_id=$submodel order by submodel"); }else{$quer3=mysql_query("SELECT DISTINCT submodel FROM submodel order by submodel"); } ////////// end of query for third subcategory drop down list box ///////////////////////////echo "<form method=post name=f1 action='retrieve.php'>";////////// Starting of first drop downlist /////////echo "<select name='make' onchange=\"reload(this.form)\"><option value=''>Select Make</option>";while($noticia2 = mysql_fetch_array($quer2)) { if($noticia2['make_id']==@$make){echo "<option selected value='$noticia2[make_id]'>$noticia2[make]</option>"."<br>";}else{echo "<option value='$noticia2[make_id]'>$noticia2[make]</option>";}}echo "</select><br><br>";////////////////// This will end the first drop down list ///////////////////// Starting of second drop downlist /////////echo "<select name='model' onchange=\"reload3(this.form)\"><option value=''>Select Model</option>";while($noticia = mysql_fetch_array($quer)) { if($noticia['model_id']==@$submodel){echo "<option selected value='$noticia[model_id]'>$noticia[model]</option>"."<br>";}else{echo "<option value='$noticia[model_id]'>$noticia[model]</option>";}}echo "</select><br><br>";////////////////// This will end the second drop down list ///////////////////// Starting of third drop downlist /////////echo "<select name='submodel' ><option value=''>Select Submodel</option>";while($noticia = mysql_fetch_array($quer3)) { echo "<option value='$noticia[submodel]'>$noticia[submodel]</option>";}echo "</select><br><br>";////////////////// This will end the third drop down list ///////////echo "<input type=submit value=Submit>";echo "</form>";?>[/code] Link to comment https://forums.phpfreaks.com/topic/16923-mysql-fatal-error-php-infinite-loopneed-advice/ Share on other sites More sharing options...
aeafisme23 Posted August 11, 2006 Author Share Posted August 11, 2006 I am just refreshing this item, I will make sure this is the last so others have a chance as well, just seeing if anyone has any input today it would be much appreciated :) Link to comment https://forums.phpfreaks.com/topic/16923-mysql-fatal-error-php-infinite-loopneed-advice/#findComment-73113 Share on other sites More sharing options...
sasa Posted August 11, 2006 Share Posted August 11, 2006 you require("add.php"); in add.php Link to comment https://forums.phpfreaks.com/topic/16923-mysql-fatal-error-php-infinite-loopneed-advice/#findComment-73139 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.