
malma
Members-
Posts
19 -
Joined
-
Last visited
malma's Achievements

Newbie (1/5)
0
Reputation
-
Thanks for quick reply, unfotunately all error functions are turned on and I can't turn them off These are the codes where I declared both $sel-subject and $sel_page. <?php function mysql_prep($value) { $magic_quotes_active = get_magic_quotes_gpc(); $new_enough_php = function_exists( "mysql_real_escape_string"); // i.e PHP >= v4.3.0 if ($new_enough_php) { // PHP v4.3.0 or higher // undo any magic quotes effects so mysql_real_escape_string // can do the work if( $magic_quotes_active) { $value = stripslashes ( $value);} $value = mysql_real_escape_string( $value); } else {// before PHP v4.3.0 // if magic quotes aren't already on then add slashes manually if (!$magic_quotes_active) {$value = addslashes($value);} // if magic quotes aren't active, the the slashes already exist } return $value; } function redirect_to($location = NULL) { if ($location != NULL) { header("Location: {$location}"); exit; } } function confirm_query($result_set) { if(!$result_set) { die("Database query failed: " . mysql_error()); } } function get_all_subjects() { global $connection; $query = "SELECT * FROM subjects ORDER BY position ASC"; $subject_set = mysql_query($query, $connection); confirm_query($subject_set); return $subject_set; } function get_all_pages_for_subject($subject_id) { global $connection; $query = "SELECT * FROM pages WHERE subject_id={$subject_id} ORDER BY position ASC"; $page_set = mysql_query($query,$connection); confirm_query($page_set); return $page_set; } function get_subject_by_id($subject_id) { global $connection; $query = " SELECT * FROM subjects WHERE id = $subject_id LIMIT 1"; $result_set = mysql_query($query, $connection); confirm_query($result_set); // REMEMBER: // if no rows are returned, fetch_array will return false if($subject = mysql_fetch_array($result_set)) { return $subject; } else { return NULL; } } function get_page_by_id($page_id) { global $connection; $query = " SELECT * FROM pages WHERE id = $page_id LIMIT 1"; $result_set = mysql_query($query, $connection); confirm_query($result_set); // REMEMBER: // if no rows are returned, fetch_array will return false if($page = mysql_fetch_array($result_set)) { return $page; } else { return NULL; } } function find_selected_page() { global $sel_subject; global $sel_page; if (isset($_GET['subj'])) { $sel_subject = get_subject_by_id($_GET['subj']); $sel_page = null; } elseif (isset($_GET['page'])) { $sel_subject = null; $sel_page = get_page_by_id($_GET['page']); } else { $sel_subject = null; $sel_page = null; } } function navigation($sel_subject, $sel_page) { $output= "<ul class=\"subjects\">"; $subject_set = get_all_subjects(); while($subject = mysql_fetch_array($subject_set)){ $output .= "<li"; if ($subject['id'] ==$sel_subject['id']) { $output .= "class=\"selected\""; } $output .= "><a href=\"edit_subject.php?subj=" . urlencode($subject["id"]) ."\">{$subject['menu_name']}</a></li> "; $page_set = get_all_pages_for_subject($subject['id']); $output .= "<ul class=\"pages\">"; while($page = mysql_fetch_array($page_set)) { $output .= "<li"; if ($page["id"]==$sel_page['id']) { $output .= "class=\"selected\""; } $output .= "><a href=\"content.php?page=" . urlencode($page["id"]). "\">{$page['menu_name']} </a></li>"; } $output .= "</ul>"; } $output .= "</ul>"; return $output; } ?>
-
My page_form is not working, it show errors. I have been trying to solve this problem but I have failed now i'm asking help from experts. These are the errors <br /><b>Notice</b>: Undefined variable: sel_page in <b>C:\wamp\www\widget\page_form.php</b> on line <b>6</b><br /> <?php // this page is included by new_page.php and edit_page.php ?> <?php if (!isset($new_page)) {$new_page = false;} ?> <p>Page name: <input type="text" name="menu_name" value="<?php echo $sel_page['menu_name']; ?>" id="menu_name"/></p> <p>Select Position: <select name="position"> <?php if (!$new_page) { $page_set = get_pages_for_subject($sel_page['subject_id']); $page_count = mysql_num_rows($page_set); } else { $page_set = get_pages_for_subject($sel_subject['id']); $page_count = mysql_num_rows($page_set) +1; } for ($count=1; $count <= $page_count; $count++) { echo "<option value=\"{$count}\""; if ($sel_page['position'] == $count) { echo "selected"; } echo ">{$count}</option>"; } ?></p> </select></p> <p>Visible: <input type="radio" name="visible" value="0"<?php if($sel_page['visible'] ==0) { echo "checked"; } ?> />No <input type="radio" name="visible" value="1" <?php if ($sel_page['visible'] ==1) { echo "checked";} ?> />Yes <input type="submit" value="Submit" /> </form> <br /> <a href="content.php">Cancel</a> </p> <p>Content: <br/> <textarea name"content" rows"20" cols="80"><?php echo $sel_page['content']; ?> </textarea> </p> I wonder why $sel_page gives me errors yet &sel_subject does not!!
-
Thank you very much for the help, i have seen what I had done wrong now it works
-
Yes I can read and that but my problem is that I'm very new to php, i can't seem able to find the right way of defining that function, can you please help me to point out how I can do it
-
I'm using PHP 5.3.0 version, now i'm trying to escape quotes but I'm getting error which I don't know how solve. I'm very new to php and this is my first atempt to learn it. I'm asking for your help please. These are my codes. Fatal error: Call to undefined function get_magic_quotes_gps() in C:\wamp\www\widget\include\functions.php on line 4 function mysql_prep($value) { $magic_quotes_active = get_magic_quotes_gps(); $new_enough_php = function_exists( "mysql_real_escape_string"); // i.e PHP >= v4.3.0 if ($new_enough_php) { // PHP v4.3.0 or higher // undo any magic quotes effects so mysql_real_escape_string // can do the work if( $magic_quotes_active) { $value = stripslashes ( $value);} $value = mysql_real_escape_string( $value); } else {// before PHP v4.3.0 // if magic quotes aren't already on then add slashes manually if (!$magic_quotes_active) {$value = addslashes($value);} // if magic quotes aren't active, the the slashes already exist } return $value; }
-
I'm sorry to have posted the same post similar to this but I'm seeing my problem is extarctly like galvin's. Anyone with solution please your help will be appreciated.
-
I'm using php 5.5.12, this vassion doesn't have "magic_quotes_gpc" in it but i'm trying to put the codes anyway. The problem is that I'm getting an error Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given in C:\wamp\www\widget\includes\functions.php on line 16 Here are my codes. function mysqli_prep($value) { $magic_quotes_active = get_magic_quotes_gpc(); $new_enough_php = function_exists("mysqli_real_escape_string"); // i.e PHP >= v4.3.0 if ($new_enough_php) {// PP v4.3.0 or higher //undo any magic quotes effects so mysqli_real_escape_string if( $magic_quotes_active) {$value = stripslashes($value);} $value = mysqli_real_escape_string( $value ); } else {// before PHP v4.3.0 // if magic quotes aren't already on then add slashes manually if (!$magic_quotes_active) {$value = addslashes($value);} // if magic quotes are active, then the slashes already exist } return $value; } function redirect_to($location) { if($location) { header("Location: {$location}"); exit; } } Please go through my codes and tell me what is wrong
-
I'm having problem with pulling pages content from database
malma replied to malma's topic in PHP Coding Help
Thank you so much Joel24 for your advice but still not working, I just copped and paste the all php code as you wrote it. -
I think now i'm becoming a familier with asking endlessly but please don't get tired of me. Right now i'm having another problem; I am to make the pages content from database appear on my localhost website but I don't know if i'm making mistakes somewhere. Please take a look on my codes. >>>>>>>>CONTENT AREA>>>>>>>>>>> <?php require_once("includes/connection.php"); ?> <?php require_once("includes/functions.php"); ?> <?php find_selected_page(); ?> <?php include("includes/header.php"); ?> <table id="structure"> <tr> <td id="navigation"> <?php echo navigation($sel_subject, $sel_page); ?> <br/> <a href="new_subject.php">+ Add a new subject</a> </td> <td id="page"> <?php if (!is_null($sel_subject)) {//subject selected ?> <h2><?php echo $sel_subject['menu_name']; ?></h2> <?php } elseif (!is_null($sel_page)) { // page selected ?> <h2><?php echo $sel_page['menu_name']; ?></h2> <div class="page-content"> <?php echo $sel_page['content']; ?> </div> <?php } else { // nothing selected ?> <h2>Select a subject or page edit</h2> <?php }?> </td> </tr> </table> <?php require("includes/footer.php"); ?> >>>>>>>>>FUNCTION<<<<<<<<<<<< function get_pages_for_subject($subject_id){ global $connection; $query = "SELECT * FROM pages WHERE subject_id = ($subject_id ) ORDER BY position ASC"; $page_set = mysqli_query( $connection, $query); confirm_query($page_set); return $page_set; } function get_subject_by_id($subject_id) { global $connection; $query = " SELECT * "; $query .= " FROM subjects "; $query .= " WHERE id=" . $subject_id ." "; $query .= " LIMIT 1"; $result_set = mysqli_query($connection, $query); confirm_query($result_set); if($subject = mysqli_fetch_array($result_set)){ return $subject; }else { return NULL; } } function get_page_by_id($page_id) { global $connection; $query = " SELECT * "; $query .= " FROM pages "; $query .= " WHERE id=" . $page_id ." "; $query .= " LIMIT 1"; $result_set = mysqli_query($connection, $query); confirm_query($result_set); //REMEMBER: // if no rows are returned, fetch_array will return false //** return $page;** on line 58 was bring error instead if($subject = mysqli_fetch_array($result_set)){ }else { return NULL; } } function find_selected_page(){ global $sel_subject; global $sel_page; if (isset($_GET['subj'])) { $sel_subject = get_subject_by_id($_GET['subj']); $sel_page = NULL; } elseif (isset($_GET['page'])) { $sel_subject = NULL; $sel_page = get_page_by_id($_GET['page']); } else { $sel_subject = NULL; $sel_page = NULL; } } The underlined <div class="page-content> is not working, maybe I mased up my codes somewhere. Thanks for your help.....
-
The first advice a got was that I should use visited instead of .selected a {...} infact i was using ' .selected ' without 'a' but after removing visited and adding a as you adviced me it work. Thanks a lot
-
Thank you very much for your help, it has finally worked. I really appreciated your help guys
-
>>>>They do go to another link, i'm still using tutorials in my learning. This is exactly how it is in the tutorials but it happens not to work ( .selected a {....... ) Is there another way I can posibly go around this?
-
I want when you click on the link to become bold
-
Yes I'm trying to bond a link with <li> tag
-
Yes exactly that is what I want to do. I have done the changes but still it won't work #navigation {width: 150px; padding: 1em 2em; color: #D4E6FA; background: #8D0D19; } #navigation a {color: #D4E6FA; text-decoration: none; } ul.subjects {padding-left: 0; list-style: none;} ul.pages {padding-left: 2em; list-style: square;} a:visited {font-weight: bold;} Thanks for your help..