HomerTheDragoon Posted June 17, 2007 Share Posted June 17, 2007 Problem: Alright, heres the problem. I have a form that is sending to the same script info that is uploaded onto the mysql server(err inserted into a table). Its for the news of my site. (www.GGleague.net) It works when i put a shot amount of info most of the time. Some times i can type alot of nonsence and it works too. But when i put in coherent sentences with a few lines it doesnt insert into the table. This goes for inserting and updateing. Any reason why? heres the script that gets included for this area.(uses tabs.) This script get included from the main file which is admin.php <?if (isset($_GET['action'])) { $action=$_GET['action']; } $n_id=$_GET['id']; if ($action=="delete") {$query="DELETE FROM league_news WHERE id='$n_id'"; mysql_query($query); } if ($action=="edit") { $q = mysql_query("SELECT * FROM league_news WHERE id='$n_id'"); $row = mysql_fetch_array($q); $loadcontent=$row['content']; } $newpost=$_POST['newpost']; $ttitle=$_POST['title']; $aid=$_POST['aid']; $content=$_POST['content']; if ($newpost==1) { echo "Post Successful<br/>"; $query = "INSERT INTO league_news VALUES ('','$ttitle','$content','$username','$date')"; mysql_query($query); }else if ($newpost==2) {$ttitle=$_POST['title']; echo "Edit Successful<br/>"; $content=$_POST['content']; $aid=$_POST['aid']; if ( isset( $_POST ) ) $postArray = &$_POST ; // 4.1.0 or later, use $_POST else $postArray = &$HTTP_POST_VARS ; // prior to 4.1.0, use HTTP_POST_VARS foreach ( $postArray as $sForm => $value ) { /*if ( get_magic_quotes_gpc() ) $content = htmlspecialchars( stripslashes( $value ) ) ; else $content = htmlspecialchars( $value ) ;*/ $content = $value; echo $content; if ($content!="1" && $content!="2" && $content!="3" && $content!=$n_id && $content!=$aid) $query = "UPDATE league_news SET title = '$ttitle', content = '$content' WHERE id = '$aid'"; } mysql_query($query); } ?> <ul id="maintab4" class="shadetabs"> <li><a href="#" rel="league2">League_1</a></li> <li class="selected"><a href="#" rel="league3">League_2</a></li> <li class="selected"><a href="#" rel="news">News</a></li> </ul> <div class="tabcontentstyle3"> <div id="league3" class="tabcontent"> More league stuff </div> <div id="league2" class="tabcontent"> <br /> <?//make it grab files and display here ?> <ul id="maintab3" class="shadetabs"> <? if ($handle = opendir("./admin/league/")) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && strstr($file,".php") && !strstr($file,"main") && !strstr($file,"index")) {$file=str_replace(".php","",$file); ?> <li><a href="#" rel="<?echo$file?>"><?echo$file?></a></li> <? } } closedir($handle); } ?> </ul> <div class="tabcontentstyle2"> <? if ($handle = opendir("./admin/league/")) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && strstr($file,".php") && !strstr($file,"main") && !strstr($file,"index")) {$file=str_replace(".php","",$file); ?> <div id="<?echo$file?>" class="tabcontent"> <br /> <iframe width="100%" frameborder="0" height="100%" src ="admin/league/<?echo $file.".php";?>" > </iframe><br /> </div> <? } } closedir($handle); } ?> <script type="text/javascript"> //Start Tab Content script for UL with id="maintab" Separate multiple ids each with a comma. initializetabcontent("maintab3") </script> </div> </div> <?//NEWS PANEL//?> <div id="news" class="tabcontent"> <br /> <?//make it grab files and display here ?> <ul id="maintab5" class="shadetabs"> <li><a href="#" rel="news2">Post News</a></li> <? /* if ($handle = opendir("./admin/news/")) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && strstr($file,".php") && !strstr($file,"main") && !strstr($file,"index")) {$file=str_replace(".php","",$file); ?> <li><a href="#" rel="<?echo$file?>"><?echo$file?></a></li> <? } } closedir($handle); }*/ ?> </ul> <div class="tabcontentstyle4"> <? /* if ($handle = opendir("./admin/news/")) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && strstr($file,".php") && !strstr($file,"main") && !strstr($file,"index")) {$file=str_replace(".php","",$file); ?> <div id="<?echo$file?>" class="tabcontent"> <br /> <iframe width="100%" frameborder="0" height="100%" src ="admin/news/<?echo $file.".php";?>" > </iframe><br /> </div> <? } } closedir($handle); } */ ?> <div id="news2" class="tabcontent"> <? if ($action=="edit") {?> <form method="POST" action="admin.php"> <p>News Title:<b> </b> <input type="text" name="title"></p> <p>Content:<br/> <input type="hidden" name="newpost" value="2"> <input type="hidden" name="aid" value=<?echo $n_id;?> <?php include("admin/news/newseditor/fckeditor.php") ; $oFCKeditor = new FCKeditor('FCKeditor1') ; $oFCKeditor->BasePath = "admin/news/newseditor/" ; $oFCKeditor->Value = "$loadcontent" ; $oFCKeditor->Create() ; ?></p> <p><input type="submit" value="Edit News"></p> </form> <?}else{?> <form method="POST" action=""> <p>News Title:<b> </b> <input type="text" name="title"></p> <p>Content:<br/> <?php ?></p><textarea name="content" rows="10" cols="20"></textarea> <input type="hidden" name="newpost" value="1"> <p><input type="submit" value="Post News"><input type="reset" value="Reset" name="B2"></p> </form><?}?> <br/> <br/> <br/> <table border="1" width="100%"> <? $q = mysql_query("SELECT * FROM league_news ORDER BY id DESC"); while($row = mysql_fetch_array($q)) { ?> <tr> <td width="200"><?echo $row['title'];?></td> <td width="100"><?echo $row['author'];?></td> <td align="right" width="60"><?echo $row['date'];?></td> <td width="50"> <p align="right"><a href="admin.php?action=delete&id=<?echo $row['id'];?>"><img border="0" title="Delete" src="images/delete.gif"></a></td><td width="50"><a title="Edit" href="admin.php?action=edit&id=<?echo $row['id'];?>">Edit</a></td> </tr> <? } ?> </table> </div> </div> <script type="text/javascript"> //Start Tab Content script for UL with id="maintab" Separate multiple ids each with a comma. initializetabcontent("maintab5") </script> </div> </div> <script type="text/javascript"> //Start Tab Content script for UL with id="maintab" Separate multiple ids each with a comma. initializetabcontent("maintab4") </script> Quote Link to comment https://forums.phpfreaks.com/topic/55952-form-to-mysql-problem/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.