Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 2nd Mar 2016, 08:15 AM   #1
Warrior Member
 
Join Date: 2014
Posts: 21
Thanks: 1
Thanked 0 Times in 0 Posts
Arrow
What the hell!.Help me Please.
Share on: 
fb share twitter share gplus share more share

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.

smsabbir480 is offline  
Unread 3rd Mar 2016, 12:00 PM   #2
VIP Warrior
War Room Member
 
Join Date: 2006
Location: , , USA.
Posts: 1,795
Thanks: 70
Thanked 287 Times in 259 Posts
Default
Re: What the hell!.Help me Please.
Share on: 
fb share twitter share gplus share more share

And that error would be?
KirkMcD is offline  
The Following User Says Thank You to KirkMcD For This Useful Post:
Unread 6th Mar 2016, 03:03 AM   #3
Active Warrior
 
Duc Aaron's Avatar
 
Join Date: 2016
Posts: 36
Thanks: 3
Thanked 5 Times in 5 Posts
Default
Re: What the hell!.Help me Please.
Share on: 
fb share twitter share gplus share more share

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

Duc Aaron is offline  
Unread 10th Mar 2016, 04:29 PM   #4
Warrior Member
 
Join Date: 2016
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default
Re: What the hell!.Help me Please.
Share on: 
fb share twitter share gplus share more share

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
belyas is offline  
Closed Thread


Bookmarks

Tags
hellhelp


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 04:45 AM.