| | #1 |
| Warrior Member Join Date: 2014
Posts: 21
Thanks: 1
Thanked 0 Times in 0 Posts
|
Hello Guys, I am very depressed with this problem but i hope i will get a solution from you guys.Here is the problem.I have developed a school website in php and i have used many functions to make my work simple & it works perfectly in localhost but in live server it is not responding correctly Because when i want to insert a function by giving arguments in it, it is not inserting it into database.How to solve it?. Here is my code.I am using switch statement method. //For New menu Input Form function addmenuform() { include('connect_to_database.php'); $query=mysqli_query($connect,"SELECT * FROM menu WHERE showing='1' ORDER BY id ASC") or die(mysqli_error($connect)); $list=''; while($row=mysqli_fetch_array($query)) { $id=$row['id']; $pagetitle=$row['pagetitle']; $list.="<option value=".$id.">".$pagetitle."</option>"; } $inputform='<center><form action="index.php?op=savemenu" method="post"> <h1>Insert New menu</h1> Menu Title:<input name="pagetitle" style="width:600px" type="text" required><br/><br/> Page Content:<br/><textarea name="pagebody" cols="80" rows="25" required></textarea><br/><br/> Page Order:<input style="width:600px" name="pageorder" type="text"><br/><br/> Keyword For SEO:<input style="width:565px" name="keyword" type="text"><br/><br/> Meta description For SEO:<br/><textarea name="metadescription" cols="80" rows="5"></textarea><br/><br/> Select A Parent Id to Make Dropdown Menu:<select name="parent_id"> <option selected value="0">No Parent</option> '.$list.' </select><br/><br/> <input name="submit" type="submit" value="Create Menu"> <input name="reset" type="reset" value="Reset"> </form></center><br/><br/>'; echo $inputform; } //For Inserting The Menu In The Database function menusave() { include('connect_to_database.php'); $title=trim($_POST['pagetitle']); $content=trim($_POST['pagebody']); $order=trim($_POST['pageorder']); $keyword=trim($_POST['keyword']); $metadescription=trim($_POST['metadescription']); $parentid=trim($_POST['parent_id']); $query=mysqli_query($connect,"INSERT INTO menu (pagetitle, pagebody, pageorder, keyword, metadescription, parent_id) VALUES('$title','$content','$order','$keyword','$m etadescription','$parentid')") or die(mysqli_error($connect)); if($query) { echo "Successfully Inserted.<a href='index.php?op=addmenu'>Back.</a>"; echo '<meta http-equiv="refresh" content="2 index.php?op=addmenu"/>'; }else{ echo "Please Try Again.<a href='index.php?op=addmenu'>Back.</a>"; echo '<meta http-equiv="refresh" content="2 index.php?op=addmenu"/>'; } exit(); } Now i want to insert this function through textarea by writing it <?php newsticker('Top news');?> And when i submit to save it mysql gives error but this code works in my localhost perfectly.How to overcome this problem?.I am waiting for your reply. Thank's in advance. |
| | |
| |
| | #2 |
| VIP Warrior War Room Member Join Date: 2006 Location: , , USA.
Posts: 1,795
Thanks: 70
Thanked 287 Times in 259 Posts
|
And that error would be?
|
| |
| The Following User Says Thank You to KirkMcD For This Useful Post: |
| | #3 |
| Active Warrior Join Date: 2016
Posts: 36
Thanks: 3
Thanked 5 Times in 5 Posts
|
Can you show sql error detail? If your code run ok in localhost, you can check mysql permission for configuration account. Sure that, this account have CRUD permission to your database |
| | |
| |
| | #4 |
| Warrior Member Join Date: 2016
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
Hi @smsabbir480, First of all, the code is hard to debug and analyze , so instead of using procedural programming use OOP , it's more cleaner and easier to debug, anyway, check your insert query et ,'$keyword','$m etadescription', this is should be ,'$keyword','$metadescription', as you can see there's a space between $m and the rest of the variable, hope this solve the problem |
| |
|
| Bookmarks |
| Tags |
| hellhelp |
| |