What the hell!.Help me Please.

5 replies
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">&nbsp;&nbsp;<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.
#hellhelp
  • Profile picture of the author KirkMcD
    And that error would be?
    {{ DiscussionBoard.errors[10569318].message }}
    • Profile picture of the author Duc Aaron
      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
      {{ DiscussionBoard.errors[10573007].message }}
      • Profile picture of the author belyas
        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
        {{ DiscussionBoard.errors[10581033].message }}

Trending Topics