Jump to content

Rebelrebellious

Members
  • Posts

    78
  • Joined

  • Last visited

    Never

Everything posted by Rebelrebellious

  1. That is it precisely. All of the arguments are optional. If no arguments are provided a barebones html header is used. The headerfile/func_get_arg(0) is a regular html file that works properly. Title/func_get_arg(1) is a string that should be placed between the title tags, replacing the original title. The third optional argument changes the class of the opening body tag. In my php, I am creating this header then printing it. After that I print some other stuff and end by printing the closing body and html tags. If there is an error in the php, I intend to simply grab the entire contents of the html file and print them. At runtime this is the call. (SAFE is False) if(SAFE == True) {print get_header_contents();} else {print get_header_contents(HTMLPAGE, TITLE);} this is the output: <body class="default">YPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <link media="print" rel="stylesheet" type="text/css" href="npprint.css" /> <link media="screen" rel="stylesheet" type="text/css" href="npscreen.css" /> <title>The original unmodified title</title> </head> <body class="default"> So the the header is getting put in, the title is not gettng changed. The default body is being used twice, and one of the times is in the wrong place. I thought that the problem may have been due to the way I am using the if statements but now I think that the problem likely lies with the string replace. Honestly, I wasn't here to look at the script yesterday, otherwise I may have found the solution by now. I will be working on it again today, and I figured that it didn't hurt to ask for help again. I appreciate that you are looking into this with me.
  2. I'm bumping this up again, maybe a fresh set of eyes can see what I am missing. Thanks,
  3. Some thoughts: trim the whitespace seperate by ' (' before the ( for each: find the position of the ')' = pos1 find the position of the last occurrance of AND or OR = pos2 if pos2 is < pos1 then the whole thing is one element ==> so add it to an array of your elements else rtrim the and or or trm the white space find the position of and or or = pos2 if pos2 < pos1 then the remaining string is one element ==> so add it to an array of your elements else we need to deal with a number seperate the string by the ')' after the ) then add the two parts to the array of your elements now that array is still populated with ANDs ORs (s and )s for each trim whitespace trim AND; trim OR; search for ( or ) - if none are found then each number is a seperate element replace ands and ors with commas then pull the elements out of the comma seperated list trim the whitespace off of these elements add the element to your final array if parenthesis were found trim ( and trim ) each remaining element has one of the following structures: N AND N AND N, N OR N OR N, [ N AND N OR N ] search for and count ANDs search for and count ORs If the last case is even possible -The last case is special - if both ands and ors exist then you should divide the string into two parts at the position of the OR and add both parts to this array that is being processed if it got this far, the element is all set for placement in your final array. Hope this helps.
  4. How many result rows are there? If you want to debug it \, it may help to try something in the spirit of : echo mysql_num_rows($query); also, it will work better if you say $row = mysql_fetch_array($query); while($row != False) { //your actions then $row = mysql_fetch_array($query); }
  5. If you look at my initial post you will see that the example scenario has the same structre as the actual problem. I want all of the if statements to be tested, even if the previous if was true. My intention was to take the least verbose approach. My suspicion is that there may be a problem with the str_replace or the argcount test. No luck so far, but I'll keep trying to figure it out. Thanks,
  6. <?php if($pages>'1'){ $i='1'; $x='0'; ?> <a href='?skip=0&Title=<? //This tag should begin <?php echo $Title; ?> '> <?php echo $i; ?> </a> <?php while($i<$pages){ $x=$i*$groupSize; $i++; echo ' | ' ; // don't forget this semicolon ?> // it is unnecessary to close this <?php // since you open it again right away. if( $x=$skipSize ) : ?> // if you want to test if $x is equal you should use == // This will get your strong tags working. <a href='?skip=<?php echo $x; ?>&Title=<?php echo $Title; ?>'><strong><?php echo $i; ?></strong></a> <?php else : ?> <a href='?skip=<?php echo $x; ?>&Title=<?php echo $Title; ?>'><?php echo $i; ?></a> <?php endif; ?> <?php } } ?> Apart from that, I recomment seperating your code from your html more. I had a hard time reading that.
  7. function get_header_contents(/* [$headerfile], [$title], [$bodyclass] */) { $argcount = func_num_args(); if($argcount == 0) { announce('Using the default header.'); $header = '<html><head><title>'.TITLE.'</title></head>'; } else { announce('Getting the header.'); $actualcontents = file_get_contents(func_get_arg(0)); $strlen = strpos($actualcontents, '<body>'); $header = substr($actualcontents, 0, $strlen); } if($argcount > 1) { announce('Setting the title.'); $beginning = strpos($header, '<title>') + 7; $strlen = strpos($header, '</title>') - $beginning; $oldtitle = substr($header, $beginning, $strlen); $newtitle = func_get_arg(1); $header = str_replace($oldtitle, $newtitle, $header); } if($argcount > 2) { announce('Setting the body class.'); $header .= '<body class="'. func_get_arg(2) .'">'; } else { announce('Using the default body class.'); $header .= '<body class="default">'; } return $header; } Can you spot the error then? My header is coming out somewhat garbled. My intention is to get the header and the opening body tag and optionally modify them a bit. Thank you.
  8. Can if statements be used one after another wihout an else? For example. Are the following two examples equivelant? if(A == 0) { $a = 'A1False'; } else { $a = 'B'; if(A > 1) { $a .= '2'; if(A > 2) { $a .= 'True'; } else { $a .= 'False'; } } else { $a .= 'False'; } } return $a; if(A == 0) {$a = 'A1';} else {$a = 'B';} if(A > 1) {$a .= '2';} if(A > 2) {$a .= 'True';} else {$a .= 'False';} return $a; possible outcomes : A1False, BFalse, B2True, B2False
  9. I have seen those arrows in other places, but I don't know what to call them. What are they used for? What do they mean? I don't really need an explaination, just a name or a resource where I can educate myself would be great. The arrows I am referring to look like this -> As per the example. echo $e->getMessage() Also, is throw new Exception pseudo code? Sorry, and thanks.
  10. So they are both GMT, but date is english only. Thank you.
  11. I should say it better. Add these comments to your newspage source: <!--BEGINNING THE FEATURED NEWS ARTICLES --> <!--ENDING THE FEATURED NEWS ARTICLES --> in your other php page include: <?php $newspage = file_get_contents('newspage.html'); $beginning = strpos($newspage, '<!--BEGINNING THE FEATURED NEWS ARTICLES -->') + 44; $strlen = strpos($newspage, '<!--ENDING THE FEATURED NEWS ARTICLES -->') - $beginning; $featurednews = substr($newspage, $beginning, $strlen); ?> <html>... ...<?php echo $featurednews; ?>... ...</html> <?php die(); ?> That should do it. If you want each of the news articles in a seperate variable then you should put the comment before and after each article you want to include then modify the php to be as follows: <?php $newspage = file_get_contents('newspage.html'); $articlecount = 1; while(strpos($newspage, '<!--BEGINNING THE FEATURED NEWS ARTICLES -->') != False) { $beginning = strpos($newspage, '<!--BEGINNING THE FEATURED NEWS ARTICLES -->') + 44; $ending = strpos($newspage, '<!--ENDING THE FEATURED NEWS ARTICLES -->'); $strlen = $ending - $beginning; $featurednews$articlecount = substr($newspage, $beginning, $strlen); $articlecount++; $amounttocutoff = $ending + 41; $remainderofnewspage = strlen($newspage) - $amounttocutoff; $newspage = substr($newspage, $amounttocutoff, $remainderofnewspage); } ?> <html>... ...<?php echo $featurednews1; ?>... ...<?php echo $featurednews2; ?>... ...<?php echo $featurednews3; ?>... ...<?php echo $featurednewsN; ?>... ...</html> <?php die(); ?> I have not tested this code, but I think it should work.
  12. Modify this a bit: function get_body_contents($bodyfile) { $actualcontents = file_get_contents($bodyfile); $beginning = strpos($actualcontents, '<body>') + 6; $strlen = strpos($actualcontents, '</body>') - $beginning; $body = substr($actualcontents, $beginning, $strlen); return $body; } Find the first pair of <span></span> and save it to a variable. Then take evrything after that </span> and save it to your $actualcontents variable, removing the first chunk. Repeat twice. Throw away the hacked up $acualcontents and use your three new span contents variables.
  13. Since they can't see the database, couldn't you save the html with the variables assigned then redisplay it when you need it with a browser? $dynamiccontent = whatever; $page = ''; $page .= '<exampletag>Some whatnot</exampletag>'; $page .= $dynamiccontent; $page .= <morehtml>...</morehtml> echo $page; $query = "INSERT INTO `yourtable` (`pagedisplay`) VALUES ('$PAGE')"; $result = mysql_query($query); die()
  14. How are you sending back the error message? Working with what you have said, I can only guess about what is causing the problem. Perhaps you are trying to send the error message back in place of the message and it is not displaying correctly.
  15. Holy buckets! I will need to read about reflection again later. There is a lot of potential there. Too much for me to worry about today. Thanks again.
  16. Thanks for the heads up. That does seem like an ideal approach. ------------------------------------------------------------------ Is there any way for a script to read its own comments that are written with // or /* */ ? Would it need to be done with file_get_contents($SERVER['PHP_SELF']) ? If so, I imagine the comment would need to self identify the subject of the comment. This is probably not the best way of doing things. I was just thinking about the possibility of doing something like: trigger_error(get_correct_comments(), E_USER_NOTICE); or maybe: get_last_comment() Even as I tpye this, I am thinking that the usefullness of such a function would be limited once the program was near completion. But it doesn't hurt to ask.
  17. Thank you very much. I really should have come here right away. Now I can get on with my project. What type should I use if I want to have the option of storing really long lists of text? text files and such Have a great day. ---update--- You must have been reading my mind.
  18. Wow. ... Thank you. Is there any recommended maximum for the VARCHAR? Do I need to keep the ` marks as I have them?
  19. I am pretty new to programming, but I have been making announcement functions in my programs that output debug messages to screen, log files, wherever. (I also include a means of enabling or disabling the output.) As a result, aside from section headings I have been announcing my line by line comments. This helps me at runtime when debugging and it serves double as in-code commenting. I am curious what anyone reading this thinks about my strategy. Is there a negative consequence to such a strategy? Is this common?
  20. I also wanted to add that the ENUM choices for the letsmeetupdateswitch column hould preferrably be simply Left or Right. If that in't possible, then I would like to use 0 or 1. Also, the letsmeet prefix was somehing I added to try to get around this error. Aside from the table prefix I don't see any value in having the prefix on each of the columns. Thanks, -Jesse
  21. I have tried every reconfiguration of ' ` and " marks that I could imagine. This is only the latest failed attempt. What am I doing wrong? The most frequent error I have been seeing is: #1064 - 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 'NULL, `letsmeetfreetimeinminutes` INT NOT NULL, `letsmeetupdateswitch` ENUM ( ' at line 7 I understand this is due to a conflict with the reserved words. I would like to stick with descriptive column names if it is possible. Maybe the problem has to to with my use of ENUM, I really don't know. Please help. CREATE TABLE letsmeet_Jesse__calendar ( `letsmeetdate` INT( 2 ) NOT NULL, `letsmeetmonth` ENUM( 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ) NOT NULL, `letsmeetyear` INT NOT NULL, `letsmeetdayname` ENUM ( 'Mon`day`', 'Tues`day`', 'Wednes`day`', 'Thurs`day`', 'Fri`day`', 'Satur`day`', 'Sun`day`' ) NOT NULL, `letsmeeteventlist` VARCHAR NULL, `letsmeetfreetimeinminutes` INT NOT NULL, `letsmeetupdateswitch` ENUM ( 'onefoot', 'twofoot', 'threefoot' ) NULL, `letsmeetupdatefootstep` INT NOT NULL, `letsmeetprimarykey` INT NOT NULL AUTO_INCREMENT, PRIMARY KEY( `letsmeetprimarykey` ) ) And I just read that you will want this: Server version: 5.0.45-community Protocol version: 10 Server: Localhost via UNIX socket
  22. If I don't get any replies should I mark this as answered? How do I do that exactly?
×
×
  • 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.