Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.

Thread Tools Display Modes
Share |
Old 03-02-2016, 07:35 AM
smsabbir480 smsabbir480 is offline
Junior Member
Join Date: 03-19-14
Posts: 23
iTrader: 0 / 0%
Thumbs down Help me with this code

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.
Reply With Quote



Old 03-02-2016, 10:38 AM
TechWizard's Avatar
TechWizard TechWizard is offline
v7n Mentor
Join Date: 07-26-07
Location: Georgia
Posts: 6,156
iTrader: 2 / 100%
Not coming at this as there is a coding problem, as you said it works fine on localhost If the problem only occurs when you are on your live web server then I would be looking at a few things...

login credentials of your on server database
account naming convention (how the server handles your personal accounts login and access) not sure if this is a shared account etc but that is where I am going with it...

The answer is probably better explained by your web hosting support since it is there that the problem occurs. What errors do you get from mysql or PHP?

Again, if the code works as expected without error locally and it doesn't when you take it to the server then it is a server access type error and not a coding error (that is except for the code that creates the access to the server) In that case there is no way for anyone to offer you a direct answer or solution other than to tell you where you should be looking and your server support are the ones equipped to offer the direct solution and answer
Reply With Quote
Old 03-02-2016, 12:16 PM
HTMLBasicTutor's Avatar
HTMLBasicTutor HTMLBasicTutor is offline
Join Date: 10-29-07
Location: Canada
Posts: 26,707
iTrader: 5 / 100%
~moved to coding section~
Reply With Quote
Old 03-03-2016, 12:01 AM
Dan Williamson Dan Williamson is offline
The Controversial Coder
Join Date: 05-01-06
Location: Manchester; UK
Posts: 2,710
iTrader: 0 / 0%
What is the MySQL error message?
Reply With Quote
Old 03-03-2016, 06:22 AM
ScriptMan's Avatar
ScriptMan ScriptMan is online now
Super Moderator
Join Date: 02-10-07
Location: Central Kentucky
Posts: 14,023
iTrader: 4 / 100%
Originally Posted by Dan Williamson View Post
What is the MySQL error message?
Dan has the right question.
Reply With Quote
Old 03-03-2016, 02:30 PM
Dan Williamson Dan Williamson is offline
The Controversial Coder
Join Date: 05-01-06
Location: Manchester; UK
Posts: 2,710
iTrader: 0 / 0%
Originally Posted by ScriptMan View Post
Dan has the right question.
You make me blush with this praise.

Just had a very quick look through the code and found one quick error:

PHP Code:
$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)); 
There's some whitespace in the query, it should be:

PHP Code:
$query=mysqli_query($connect,"INSERT INTO menu (pagetitle, pagebody, pageorder, keyword, metadescription, parent_id) VALUES('$title','$content','$order','$keyword','$metadescription','$parentid')") or die(mysqli_error($connect)); 
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Code you add to youtube embed code? chillspike Web Design Lobby 2 05-10-2012 07:14 AM
the code:HTML BB Code sagemore48 Coding Forum 3 12-29-2010 12:19 AM
add code for font size under php echo code newphpcoder Coding Forum 3 11-12-2010 10:26 AM
Google Analytics old code vs new code m42 Google Forum 0 03-29-2008 12:04 AM

V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory

All times are GMT -7. The time now is 01:36 PM.
Powered by vBulletin
Copyright 2000-2014 Jelsoft Enterprises Limited.
Copyright © 2003 - 2018 VIX-WomensForum LLC