raptor30506090 Posted September 7, 2011 Share Posted September 7, 2011 Hi im having problems with this can any one point me the right way please if(isset($_GET['pageID'])){ $id = $_GET['pageID']; } ?> <?php if(isset($_POST['submit'])){ $title = $_POST['title']; $keywords = $_POST['keywords']; $description = $_POST['description']; $menu = $_POST['menu']; $content = $_POST['content']; $query = mysql_query("UPDATE 'page' SET title='$title', keywords='$keywords', description='$description', menu='$menu', content='$content' WHERE 'pageID'= $id"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/246657-mysql-help-please/ Share on other sites More sharing options...
Maq Posted September 7, 2011 Share Posted September 7, 2011 Remove the single quotes from your table names. Quote Link to comment https://forums.phpfreaks.com/topic/246657-mysql-help-please/#findComment-1266555 Share on other sites More sharing options...
raptor30506090 Posted September 7, 2011 Author Share Posted September 7, 2011 Hi do you mean page? Quote Link to comment https://forums.phpfreaks.com/topic/246657-mysql-help-please/#findComment-1266556 Share on other sites More sharing options...
raptor30506090 Posted September 7, 2011 Author Share Posted September 7, 2011 tryed that did not work remove quotes from page Quote Link to comment https://forums.phpfreaks.com/topic/246657-mysql-help-please/#findComment-1266559 Share on other sites More sharing options...
Maq Posted September 7, 2011 Share Posted September 7, 2011 tryed that did not work remove quotes from page Post your new query. You did this right? $query = mysql_query("UPDATE page SET title='$title', keywords='$keywords', description='$description', menu='$menu', content='$content' WHERE pageID= $id"); If that didn't work add or die(mysql_error()); to the end of the mysql_query call to figure out the exact errors. Quote Link to comment https://forums.phpfreaks.com/topic/246657-mysql-help-please/#findComment-1266561 Share on other sites More sharing options...
raptor30506090 Posted September 7, 2011 Author Share Posted September 7, 2011 if(isset($_GET['pageID'])){ $id = $_GET['pageID']; } ?> <?php if(isset($_POST['submit'])){ $title = $_POST['title']; $keywords = $_POST['keywords']; $description = $_POST['description']; $menu = $_POST['menu']; $content = $_POST['content']; $query = mysql_query("UPDATE page SET title='$title', keywords='$keywords', description='$description', menu='$menu', content='$content' WHERE 'pageID'= $id"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/246657-mysql-help-please/#findComment-1266562 Share on other sites More sharing options...
raptor30506090 Posted September 7, 2011 Author Share Posted September 7, 2011 This is the error ( ! ) Notice: Undefined variable: id in C:\wamp\www\pageUpdate\inc\updatePage.php on line 21 Call Stack # Time Memory Function Location 1 0.0005 374576 {main}( ) ..\updatePage.php:0 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/246657-mysql-help-please/#findComment-1266564 Share on other sites More sharing options...
TOA Posted September 7, 2011 Share Posted September 7, 2011 Same problem as before...take the single quotes off the column and add it to the value (which would be $id) in the where clause. $query = mysql_query("UPDATE page SET title='$title', keywords='$keywords', description='$description', menu='$menu', content='$content' WHERE pageID= '$id'") Back ticks are for tables and columns, single quotes are for values. You did it right on the rest of them as you can see Quote Link to comment https://forums.phpfreaks.com/topic/246657-mysql-help-please/#findComment-1266566 Share on other sites More sharing options...
raptor30506090 Posted September 7, 2011 Author Share Posted September 7, 2011 sorry about this but still getting same error driving me mad Quote Link to comment https://forums.phpfreaks.com/topic/246657-mysql-help-please/#findComment-1266567 Share on other sites More sharing options...
TOA Posted September 7, 2011 Share Posted September 7, 2011 Where do you define $id? Quote Link to comment https://forums.phpfreaks.com/topic/246657-mysql-help-please/#findComment-1266568 Share on other sites More sharing options...
raptor30506090 Posted September 7, 2011 Author Share Posted September 7, 2011 Sorry very new at this the $id iv just used $_get['pageID'] Quote Link to comment https://forums.phpfreaks.com/topic/246657-mysql-help-please/#findComment-1266569 Share on other sites More sharing options...
jasonc Posted September 7, 2011 Share Posted September 7, 2011 Can you supply the full code or at best what is on line 21 also try changing your if statement to this... if(isset($_GET['pageID'])){ $id = $_GET['pageID']; } else { $id = "dummy"; } Quote Link to comment https://forums.phpfreaks.com/topic/246657-mysql-help-please/#findComment-1266570 Share on other sites More sharing options...
iStriide Posted September 7, 2011 Share Posted September 7, 2011 <?php $query = mysql_query("UPDATE 'page' SET title='$title', keywords='$keywords', description='$description', menu='$menu', content='$content' WHERE 'pageID'= $id"); // Should Be $query = mysql_query("UPDATE `page` SET title='$title', keywords='$keywords', description='$description', menu='$menu', content='$content' WHERE `pageID`= $id"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/246657-mysql-help-please/#findComment-1266573 Share on other sites More sharing options...
raptor30506090 Posted September 7, 2011 Author Share Posted September 7, 2011 This is the full code on this page apart from connection it also says Undefined variable: id [cod]if(isset($_GET['pageID'])){ $id = $_GET['pageID']; } ?> <?php if(isset($_POST['submit'])){ $title = $_POST['title']; $keywords = $_POST['keywords']; $description = $_POST['description']; $menu = $_POST['menu']; $content = $_POST['content']; $query = mysql_query("UPDATE `page` SET title='$title', keywords='$keywords', description='$description', menu='$menu', content='$content' WHERE `pageID`= $id") or die(mysql_error()); } ?>[/cod] Quote Link to comment https://forums.phpfreaks.com/topic/246657-mysql-help-please/#findComment-1266577 Share on other sites More sharing options...
Maq Posted September 7, 2011 Share Posted September 7, 2011 That means pageID doesn't exist. Show us the URL you're using. Quote Link to comment https://forums.phpfreaks.com/topic/246657-mysql-help-please/#findComment-1266578 Share on other sites More sharing options...
raptor30506090 Posted September 7, 2011 Author Share Posted September 7, 2011 <?php $query = mysql_query("SELECT * FROM page"); while($row = mysql_fetch_assoc($query)){ ?> <ul> <li><a href="main.php?pageID=<?php echo $row['pageID']; ?>"><?php echo $row['menu']; ?></a></li> </ul> <?php } ?> </div> <form action="inc/updatePage.php" method="POST"> <fieldset id="field"> <legend class="legend">CMS MANAGEMENT UPDATE PAGE </legend> <label for="title">Title</label> <br/> <input type="text" name="title" value="<?php if(isset($_GET['pageID'])){ $pageID = $_GET['pageID']; $query = mysql_query("SELECT * FROM page WHERE pageID= $pageID"); $result = mysql_fetch_assoc($query); echo $result['title']; } else{ // if $_GET is not set throw out Home page content $name = mysql_query("SELECT * FROM page"); $row = mysql_fetch_assoc($name); echo $row['title']; } ?> <?php if (isset($_GET['pageID'])){ echo $result['title']; } ?>"/> <br/> <label for="keywords">Keywords</label> <br/> <input type="text" name="keywords" id="" value="<?php if(isset($_GET['pageID'])){ $pageID = $_GET['pageID']; $query = mysql_query("SELECT * FROM page WHERE pageID= $pageID"); $result = mysql_fetch_assoc($query); echo $result['keywords']; } else{ // if $_GET is not set throw out Home page content $name = mysql_query("SELECT * FROM page"); $row = mysql_fetch_assoc($name); echo $row['keywords']; } ?> <?php if (isset($_GET['pageID'])){ echo $result['keywords']; } ?>"/> <br/> <label for="description">Description</label> <br/> <input type="text" name="description" id="" value="<?php if(isset($_GET['pageID'])){ $pageID = $_GET['pageID']; $query = mysql_query("SELECT * FROM page WHERE pageID= $pageID"); $result = mysql_fetch_assoc($query); echo $result['description']; } else{ // if $_GET is not set throw out Home page content $name = mysql_query("SELECT * FROM page"); $row = mysql_fetch_assoc($name); echo $row['description']; } ?> <?php if (isset($_GET['pageID'])){ echo $result['description']; } ?>"/> <br/> <label for="menu">Menu</label> <br/> <input type="text" name="menu" id="" value="<?php if(isset($_GET['pageID'])){ $pageID = $_GET['pageID']; $query = mysql_query("SELECT * FROM page WHERE pageID= $pageID"); $result = mysql_fetch_assoc($query); echo $result['description']; } else{ // if $_GET is not set throw out Home page content $name = mysql_query("SELECT * FROM page"); $row = mysql_fetch_assoc($name); echo $row['description']; } ?> <?php if (isset($_GET['pageID'])){ echo $result['description']; } ?>"/> <br /> <label for="maincontent">Main Content</label> <br /> <textarea name="content" rows="20" cols="70" id=""><?php if(isset($_GET['pageID'])){ $pageID = $_GET['pageID']; $query = mysql_query("SELECT * FROM page WHERE pageID= $pageID"); $result = mysql_fetch_assoc($query); // echo $result['content']; } else{ // if $_GET is not set throw out Home page content $name = mysql_query("SELECT * FROM page"); $row = mysql_fetch_assoc($name); echo $row['content']; } ?> <?php if (isset($_GET['pageID'])){ echo $result['content']; } ?></textarea> <br /><br /> <input type="submit" name="submit" value="UPDATE PAGE" class="button"/> <input type="reset" name="reset" value="reset" class="reset"/> </fieldset> </form> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/246657-mysql-help-please/#findComment-1266579 Share on other sites More sharing options...
raptor30506090 Posted September 7, 2011 Author Share Posted September 7, 2011 <?php $query = mysql_query("SELECT * FROM page"); while($row = mysql_fetch_assoc($query)){ ?> <ul> <li><a href="main.php?pageID=<?php echo $row['pageID']; ?>"><?php echo $row['menu']; ?></a></li> </ul> <?php } ?> </div> <form action="inc/updatePage.php" method="POST"> <fieldset id="field"> <legend class="legend">CMS MANAGEMENT UPDATE PAGE </legend> <label for="title">Title</label> <br/> <input type="text" name="title" value="<?php if(isset($_GET['pageID'])){ $pageID = $_GET['pageID']; $query = mysql_query("SELECT * FROM page WHERE pageID= $pageID"); $result = mysql_fetch_assoc($query); echo $result['title']; } else{ // if $_GET is not set throw out Home page content $name = mysql_query("SELECT * FROM page"); $row = mysql_fetch_assoc($name); echo $row['title']; } ?> <?php if (isset($_GET['pageID'])){ echo $result['title']; } ?>"/> <br/> <label for="keywords">Keywords</label> <br/> <input type="text" name="keywords" id="" value="<?php if(isset($_GET['pageID'])){ $pageID = $_GET['pageID']; $query = mysql_query("SELECT * FROM page WHERE pageID= $pageID"); $result = mysql_fetch_assoc($query); echo $result['keywords']; } else{ // if $_GET is not set throw out Home page content $name = mysql_query("SELECT * FROM page"); $row = mysql_fetch_assoc($name); echo $row['keywords']; } ?> <?php if (isset($_GET['pageID'])){ echo $result['keywords']; } ?>"/> <br/> <label for="description">Description</label> <br/> <input type="text" name="description" id="" value="<?php if(isset($_GET['pageID'])){ $pageID = $_GET['pageID']; $query = mysql_query("SELECT * FROM page WHERE pageID= $pageID"); $result = mysql_fetch_assoc($query); echo $result['description']; } else{ // if $_GET is not set throw out Home page content $name = mysql_query("SELECT * FROM page"); $row = mysql_fetch_assoc($name); echo $row['description']; } ?> <?php if (isset($_GET['pageID'])){ echo $result['description']; } ?>"/> <br/> <label for="menu">Menu</label> <br/> <input type="text" name="menu" id="" value="<?php if(isset($_GET['pageID'])){ $pageID = $_GET['pageID']; $query = mysql_query("SELECT * FROM page WHERE pageID= $pageID"); $result = mysql_fetch_assoc($query); echo $result['description']; } else{ // if $_GET is not set throw out Home page content $name = mysql_query("SELECT * FROM page"); $row = mysql_fetch_assoc($name); echo $row['description']; } ?> <?php if (isset($_GET['pageID'])){ echo $result['description']; } ?>"/> <br /> <label for="maincontent">Main Content</label> <br /> <textarea name="content" rows="20" cols="70" id=""><?php if(isset($_GET['pageID'])){ $pageID = $_GET['pageID']; $query = mysql_query("SELECT * FROM page WHERE pageID= $pageID"); $result = mysql_fetch_assoc($query); // echo $result['content']; } else{ // if $_GET is not set throw out Home page content $name = mysql_query("SELECT * FROM page"); $row = mysql_fetch_assoc($name); echo $row['content']; } ?> <?php if (isset($_GET['pageID'])){ echo $result['content']; } ?></textarea> <br /><br /> <input type="submit" name="submit" value="UPDATE PAGE" class="button"/> <input type="reset" name="reset" value="reset" class="reset"/> </fieldset> </form> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/246657-mysql-help-please/#findComment-1266580 Share on other sites More sharing options...
jasonc Posted September 7, 2011 Share Posted September 7, 2011 You need to following to allow the query to run for both conditions, that the pageID was not set and for when it is set. if(isset($_GET['pageID'])){ $id = $_GET['pageID']; } else { $id = "dummy"; } Quote Link to comment https://forums.phpfreaks.com/topic/246657-mysql-help-please/#findComment-1266582 Share on other sites More sharing options...
raptor30506090 Posted September 7, 2011 Author Share Posted September 7, 2011 <?php $query = mysql_query("SELECT * FROM page"); while($row = mysql_fetch_assoc($query)){ ?> <ul> <li><a href="main.php?pageID=<?php echo $row['pageID']; ?>"><?php echo $row['menu']; ?></a></li> </ul> <?php } ?> </div> <form action="inc/updatePage.php" method="POST"> <fieldset id="field"> <legend class="legend">CMS MANAGEMENT UPDATE PAGE </legend> <label for="title">Title</label> <br/> <input type="text" name="title" value="<?php if(isset($_GET['pageID'])){ $pageID = $_GET['pageID']; $query = mysql_query("SELECT * FROM page WHERE pageID= $pageID"); $result = mysql_fetch_assoc($query); echo $result['title']; } else{ // if $_GET is not set throw out Home page content $name = mysql_query("SELECT * FROM page"); $row = mysql_fetch_assoc($name); echo $row['title']; } ?> <?php if (isset($_GET['pageID'])){ echo $result['title']; } ?>"/> <br/> <label for="keywords">Keywords</label> <br/> <input type="text" name="keywords" id="" value="<?php if(isset($_GET['pageID'])){ $pageID = $_GET['pageID']; $query = mysql_query("SELECT * FROM page WHERE pageID= $pageID"); $result = mysql_fetch_assoc($query); echo $result['keywords']; } else{ // if $_GET is not set throw out Home page content $name = mysql_query("SELECT * FROM page"); $row = mysql_fetch_assoc($name); echo $row['keywords']; } ?> <?php if (isset($_GET['pageID'])){ echo $result['keywords']; } ?>"/> <br/> <label for="description">Description</label> <br/> <input type="text" name="description" id="" value="<?php if(isset($_GET['pageID'])){ $pageID = $_GET['pageID']; $query = mysql_query("SELECT * FROM page WHERE pageID= $pageID"); $result = mysql_fetch_assoc($query); echo $result['description']; } else{ // if $_GET is not set throw out Home page content $name = mysql_query("SELECT * FROM page"); $row = mysql_fetch_assoc($name); echo $row['description']; } ?> <?php if (isset($_GET['pageID'])){ echo $result['description']; } ?>"/> <br/> <label for="menu">Menu</label> <br/> <input type="text" name="menu" id="" value="<?php if(isset($_GET['pageID'])){ $pageID = $_GET['pageID']; $query = mysql_query("SELECT * FROM page WHERE pageID= $pageID"); $result = mysql_fetch_assoc($query); echo $result['description']; } else{ // if $_GET is not set throw out Home page content $name = mysql_query("SELECT * FROM page"); $row = mysql_fetch_assoc($name); echo $row['description']; } ?> <?php if (isset($_GET['pageID'])){ echo $result['description']; } ?>"/> <br /> <label for="maincontent">Main Content</label> <br /> <textarea name="content" rows="20" cols="70" id=""><?php if(isset($_GET['pageID'])){ $pageID = $_GET['pageID']; $query = mysql_query("SELECT * FROM page WHERE pageID= $pageID"); $result = mysql_fetch_assoc($query); // echo $result['content']; } else{ // if $_GET is not set throw out Home page content $name = mysql_query("SELECT * FROM page"); $row = mysql_fetch_assoc($name); echo $row['content']; } ?> <?php if (isset($_GET['pageID'])){ echo $result['content']; } ?></textarea> <br /><br /> <input type="submit" name="submit" value="UPDATE PAGE" class="button"/> <input type="reset" name="reset" value="reset" class="reset"/> </fieldset> </form> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/246657-mysql-help-please/#findComment-1266583 Share on other sites More sharing options...
raptor30506090 Posted September 7, 2011 Author Share Posted September 7, 2011 iv tryed to post all the code with no luck Quote Link to comment https://forums.phpfreaks.com/topic/246657-mysql-help-please/#findComment-1266591 Share on other sites More sharing options...
jasonc Posted September 8, 2011 Share Posted September 8, 2011 Please attach the file called updatePage.php mask out any personal info that may be in it i.e. database info using asterisk. Quote Link to comment https://forums.phpfreaks.com/topic/246657-mysql-help-please/#findComment-1266716 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.