Jump to content

Cell0518

Members
  • Posts

    36
  • Joined

  • Last visited

    Never

Everything posted by Cell0518

  1. [!--quoteo(post=375642:date=May 21 2006, 12:09 PM:name=jeremywesselman)--][div class=\'quotetop\']QUOTE(jeremywesselman @ May 21 2006, 12:09 PM) [snapback]375642[/snapback][/div][div class=\'quotemain\'][!--quotec--] There are many different ways that you could go about this. Here is one way to work how you have it set up. [code]<?php // include the layout file include 'layout.php'; // include the config file include 'config.php'; //Get Page Content class get_page_content { var $p; var $p_title; function get_page_content() { $this->p = $_REQUEST['p']; if ($this->p == "") {$this->p = "main"; } $this->p_title = "ChrisLoveOnline : ".ucfirst($this->p);} function disp_incl(){     myheader("$this->p_title");     include "./include/$this->p.inc";     } } $p_content = new get_page_content(); $p_content->disp_incl(); ?>[/code] [/quote] Well, It works, to a degree. To get it to totally work, I had to remove $_REQUEST['p'] from new get_page_contents and changed $this->p = $p to $_REQUEST['p']; [b]Another Question...[/b] How to check to see if $_REQUEST['p'].inc exists, and if not, change $p to something like error (change unavailable/bad .inc file to error.inc)? Thanks, Chris
  2. [!--quoteo(post=375620:date=May 21 2006, 10:55 AM:name=jeremywesselman)--][div class=\'quotetop\']QUOTE(jeremywesselman @ May 21 2006, 10:55 AM) [snapback]375620[/snapback][/div][div class=\'quotemain\'][!--quotec--] If you have already declared the variables you wish to use within the class, you do not need to pass them to the method inside the class. You can access them like you are, with $this. But if you are using a method in the class that requires variables to be passed to it, that is when you declare them with the method. [!--coloro:#990000--][span style=\"color:#990000\"][!--/coloro--]Jeremy[!--colorc--][/span][!--/colorc--] [/quote] If I'm understanding you, I don't need this: [code] var $p; var $p_title; [/code] Is that correct? I'm still getting an error on line 15 (as mentioned above) Thanks, CL
  3. Hi, I'm trying to make a class in PHP4 to do: [a href=\"http://www.domain.com/?p=pagename\" target=\"_blank\"]http://www.domain.com/?p=pagename[/a] [Pagename displayed] [code]<?php // include the layout file include 'layout.php'; // include the config file include 'config.php'; $p=$_GET['p']; //Get Page Content class get_page_content { var $p; var $p_title; function get_page_content() { if ($p == "") {$p = "main"; } $this->p = "$p"; $this->p_title = "ChrisLoveOnline : ".strtoupper($p);} function disp_incl($this->p,$this->p_title){     myheader("$this->p_title");     include "./include/$this->p.inc";     } } $p_content = new get_page_content(); $p_content->disp_incl($p); ?>[/code] Parse error: parse error, expecting `')'' in 'file' on line 15. From what I can tell, it's complaining about the , between variables in the function. I'm new to classes. I'm also looking at how I can show an error page if the page isn't found. $p = pagename and $p.inc is include file. Thanks, Chris
  4. Thanks all, I used an example from an article, and it makes sense. Thanks again, Chris
  5. Thanks for the quick reply. I know that's probably an "over asked" question, but I just couldn't seem to locate an answer. I guess I wasn't generalizing enough. (is that spelled right? [img src=\"http://www.phpfreaks.com/forums/style_images/1/folder_post_icons/icon1.gif\" border=\"0\" alt=\"IPB Image\" /] ) I'll take a look into it. Thanks again, Chris
  6. Can a PHP form write information to a config.php file, or is there a special extension? Thanks, Chris
  7. I would say this whole thread is a blank screen. LOL! :( I didn't place thread, just commenting on "What?" happened...
  8. Example (from Gallery 2) $urlGenerator->makeUrl($path)); for this "->", does it mean something like this? $variable "execute and set return value = to $variable" makeURL(to "$path variable" in this case)? Just trying to understand some of the more complicated code in Gallery. Thanks, Chris
  9. [!--quoteo(post=353564:date=Mar 10 2006, 06:57 PM:name=lessthanthree)--][div class=\'quotetop\']QUOTE(lessthanthree @ Mar 10 2006, 06:57 PM) [snapback]353564[/snapback][/div][div class=\'quotemain\'][!--quotec--] You CAN enter manually enter data into an auto_increment field but the data MUST be unique. [/quote] Well, with the code above, I did try and it seemed to fail. Do you see anything that would cause it to fail?
  10. [!--quoteo(post=353552:date=Mar 10 2006, 06:17 PM:name=lessthanthree)--][div class=\'quotetop\']QUOTE(lessthanthree @ Mar 10 2006, 06:17 PM) [snapback]353552[/snapback][/div][div class=\'quotemain\'][!--quotec--] If your story number field is a primary key (and set to auto increment?) there's a high chance that when you're trying to change it mysql won't let you either because b) the field is set as auto increment at which point you should not need to manually enter a number [/quote] This is the case. I just wanted to be able to change them, if the need arose. If this isn't possible, I understand. Can someone clarify this?
  11. Hi, I've been using PHP / MySQL for a couple of months, off and on, to update my news section on my site. I am trying to change the "primary key", to move a story up to the top. It pulls from the database, the story_number (news story number). It pastes 2 times, one to a disabled input box, and 1 to an "update" input box that I can edit. It keeps telling me "can't add to table" , which means the query is not good. I tried putting the query, with data, in PHPMyAdmin and it works fine. I can't figure out what is wrong. Thanks, Chris Clip from 1 php file Sorry this is SO BIG... :( EDIT: Should this be in the MySQL forum?? [code] //EDIT elseif ($action == "edit"){ require "../config.php"; $search_story_number = $_POST['story_number']; $conn = mysql_connect("$location","$username","$password"); if (!$conn) die ("Could not connect MySQL"); mysql_select_db($database,$conn) or die ("Could not open database"); //Query for Story $query  = "SELECT * FROM dslr_news WHERE story_number=$search_story_number LIMIT 1"; $result = mysql_query($query); //Display Story echo "<body style=\"text-align: center\"> <table width=\"800\" height=\"600\" align=\"center\" border=\"0\" id=\"standard-inner\" class=\"BLANK\">\n"; while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { stripslashes($row['short_news']); stripslashes($row['main_news']); echo "<form method=\"post\" action=\"./?action=update\">Edit News<br />"; echo "Original Story Number<br /><input type=\"text\" name=\"orig_story_number\" id=\"orig_story_number\" value=\""; echo $row['story_number']; echo "\" disabled><br />\n"; echo "New Story Number<br /><input type=\"text\" name=\"new_story_number\" id=\"new_story_number\" value=\""; echo $row['story_number']; echo "\"><br />\n"; echo "News Title<br /><input type=\"text\" name=\"news_title\" id=\"news_title\" value=\""; echo $row['news_title']; echo "\"><br />\n"; echo "Short Title<br /><input type=\"text\" name=\"news_title_short\" id=\"news_title_short\" value=\""; echo $row['news_title_short']; echo "\"><br />\n"; echo "Date<br /><input type=\"text\" name=\"news_date\" id=\"news_date\" value=\""; echo $row['news_date']; echo "\"><br />\n"; echo "Short Date<br /><input type=\"text\" name=\"news_date_short\" id=\"news_date_short\" value=\""; echo $row['news_date_short']; echo "\"><br />\n"; echo "Short Excerpt<br /><textarea name=\"short_news\" id=\"short_news\" cols=\"55\" rows=\"5\">"; echo $row['short_news']; echo "</textarea><br />"; echo "Main News<br /><textarea name=\"main_news\" id=\"main_news\" cols=\"55\" rows=\"10\">"; echo $row['main_news']; echo "</textarea><br />"; echo "<input type=\"submit\" value=\"Edit News\"> <p />\n"; } echo "</table>"; footer_main(); } //ALTER elseif ($action == "update"){ require "../config.php"; $conn = mysql_connect("$location","$username","$password");if (!$conn) die ("Could not connect MySQL");mysql_select_db($database,$conn) or die ("Could not open database"); $orig_story_number = $_POST['orig_story_number']; $new_story_number = $_POST['new_story_number']; $news_title = $_POST['news_title']; $news_title_short = $_POST['news_title_short']; $news_date = $_POST['news_date']; $news_date_short = $_POST['news_date_short']; $short_news = $_POST['short_news']; $main_news = $_POST['main_news']; $query = "UPDATE `dslr_news` SET `story_number` = '$new_story_number', `news_title` = '$news_title', `news_title_short` = '$news_title_short', `news_date` = '$news_date', `news_date_short` = '$news_date_short', `short_news` = '$short_news', `main_news` = '$main_news' WHERE `story_number` = $orig_story_number LIMIT 1";     mysql_query($query) or die ("Could not add data to the table"); echo "<body style=\"text-align: center\"> Action Completed <p /><a href=\"./?action=choose-edit\">Edit More News</a>";[/code]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.