Jump to content

TomTees

Members
  • Posts

    187
  • Joined

  • Last visited

    Never

Posts posted by TomTees

  1. You thought wrong.

     

    A leading slash always represents your web servers root (in html, in php (or file system paths) it would represent your OS's root).

     

    So when would you use...

     

    /SomeFile.php

     

    as opposed to...

     

    SomeFile.php

     

    OR

     

    /MyFolder/SomeFile.php

     

    as opposed to...

     

    MyFolder/SomeFile.php

     

     

    TomTees

     

     

  2. This is the code that works...

     

    <!-- TINYMCE CODE -->

    <script type="text/javascript" src="tiny_mce/tiny_mce.js"></script>

     

    Because the tiny_mce directory is obviously in the same directory as your calling page not the web servers root as you had used previously.

     

    I thought you needed a "/" to go into a directory?

     

     

     

    TomTees

     

     

  3. unless the tiny_mce/ directory is at the root of the drive.

     

    Its a client side address, so the first / points to the web servers document root. But yeah, its likely the path is incorrect.

     

    Yep, its the same pain-in-the-arse as the Rel thingy in HTML...

     

    This is the code that works...

     

    <!-- TINYMCE CODE -->

    <script type="text/javascript" src="tiny_mce/tiny_mce.js"></script>

     

    Don't ask me why?!  :shrug:

     

    Also, I tried adding some text that I added formatting to, and while the entry was saved in my database, none of the formatting was captured so I'm not sure what the issue with that is?!  :confused:

     

     

    TomTees

     

     

     

     

  4. I'm betting this is a path issue. I don't think this should have the leading slash, unless the tiny_mce/ directory is at the root of the drive.

     

    src="/tiny_mce/tiny_mce.js"

     

    Paths really screw me up in PHP.  (Particularly with this author and his procedural style...)

     

    In my Web Root (in NetBeans), my main file is "index.php"

     

    (Then the series of includes starts)

     

    Index.php includes footer.html in the "includes" directory.

     

    Footer.html has this code...

     

    	<li><a href="add_page.php" title="Add a Page">Add Page</a></li>

     

    "add_page.php" is in the Web Root, and it apparently appears as part of index.php by way of footer.html.  (Convoluted if you ask me.)

     

    In the Web Root I have the "tiny_mce" directory.  In that directory is "tiny_mce.js" which is supposed to run everything.

     

    In "add_page.php" I have this..

     

    <!-- TINYMCE CODE -->
    <script type="text/javascript" src="../tiny_mce/tiny_mce.js"></script>

     

    I also tried this...

     

    <!-- TINYMCE CODE -->
    <script type="text/javascript" src="../tiny_mce/tiny_mce.js"></script>

     

    I *thought* I understood navigating paths pretty well, but I know that

    rel=...

    in HTML always screws me up because it doesn't work like regular paths.  It works from the parent file's perspective and not the file the actual code is in.  *Maybe* that is the issue with this JavaScript code which I know nothing about??

     

     

     

    TomTees

     

     

  5. What it says is that Firefox is currently in offline mode. Did you try going to the File menu and unchecking the Work Offline option at the bottom of the list?

     

    You're pretty smart.

     

    Someday maybe they'll make you a Global Moderator or something?!  ;)

     

    Thanks,

     

     

    TomTees

     

     

  6. i use MAMP on Mac Pro without internet connection no problem. haven't used netbeans, but don't know why your standalone MAMP web server would need an internet connection to run.

     

    by the way: how do you know MAMP isn't running? Will it not start up? does it show apache/mysql as down?

     

    I am in my motel room right now.

     

    If I disconnect from the Internet (i.e. turn off my Internet Connection), and then fire up MAMP, instead of getting the splash page, I get...

     

    URL: http://localhost/MAMP/?language=English

     

    Webpage:

    Offline mode

    Firefox is currently in offline mode and can't browse the Web.

        *  Uncheck "Work Offline" in the File menu, then try again.

     

    If I then open up NetBeans and try to execute a PHP script, I get the same message as above.

     

    So that says to me, that without MAMP (likely Apache) having Internet access, it acts all retarded and refuses to serve up PHP pages?!  ::)

     

    That makes no sense, because all of my files are local, so even though I'm use a webserver (i.e. MAMP/Apache), it shouldn't need any Internet access.

     

    (I think I asked this question a few years ago, and someone mentioned something about a "Loop-Back Issue"??)  :shrug:

     

    Regardless, this is a real pain, because it means that with a live Internet connection, I can't do any development/testing (e.g. on a plane, at work, etc)

     

    Any ideas what the deal is???

     

     

     

    TomTees

     

     

  7. Here is the HTML output from my PHP script...

     

     

    <!DOCTYPE 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">
    
    	<!-- HTML HEADER -->
    	<head>
    		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    		<title>
    			Add a Site Content Page			</title>
    		<link rel="stylesheet" href="css/styles.css" type="text/css" />
    	</head>
    
    	<!-- END OF HTML HEADER -->
    
    	<!-- HTML BODY -->
    	<body>
    		<!-- WRAPPER -->
    		<div id="wrap">
    			<!-- PAGE HEADING -->
    			<div class="header">
    				<h1><a href="index.php">Some Title Here</a></h1>
    
    				<h2>A Tagline Goes Here</h2>
    			</div>
    			<!-- END OF PAGE HEADING -->
    
    			<!-- TAB NAVIGATION -->
    			<div id="nav">
    				<ul>
    					<li><a href="index.php"><span>Home</span></a></li><li><a href="about.php"><span>About</span></a></li><li><a href="contact.php"><span>Contact</span></a></li><li><a href="register.php"><span>Register</span></a></li>					</ul>
    
    			</div>
    			<!-- END OF TAB NAVIGATION -->
    
    			<!-- PAGE BODY -->
    			<div class="page">
    				<!-- MAIN CONTENT -->
    				<div class="content">
    
    
    <!-- END OF HEADER -->
    <h3>Add a Site Content Page</h3>
    
    <form action="add_page.php" method="post" accept-charset="utf-8">
    <fieldset>
    	<legend>Fill out the form to add a page of content:</legend>
    	<p>
    		<label for="title"><strong>Title</strong></label><br />
    		<input type="text" name="title" id="title" />		</p>
    
    	<p>
    
    		<label for="category"><strong>Category</strong></label><br />
    		<select name="category"
    			 >
    			<option>Select One</option>
    			<option value="3">Category 1</option>
    <option value="5">Category 2</option>
    <option value="1">Category 3</option>
    <option value="4">Category 4</option>
    
    <option value="2">Category 5</option>
    		</select>
    				</p>
    
    	<p>
    		<label for="description"><strong>Description</strong></label><br />
    		<textarea name="description" id="description" rows="5" cols="75"></textarea>		</p>
    
    	<p>
    		<label for="content"><strong>Content</strong></label><br />
    		<textarea name="content" id="content" rows="5" cols="75"></textarea>		</p>
    
    	<p>
    		<input type="submit" name="submit_button"
    					 class="formbutton" id="submit_button"  value="Add This Page" />
    	</p>
    </fieldset>
    
    </form>
    
    <!-- TINYMCE CODE -->
    <script type="text/javascript" src="../tiny_mce/tiny_mce.js"></script>
    <script type="text/javascript">
    tinyMCE.init({
    	// General options
    	mode : "exact",
    	elements : "content",
    	theme : "advanced",
    	width : 800,
    	height : 400,
    	plugins : "advlink,advlist,autoresize,autosave,contextmenu,fullscreen,iespell,inlinepopups,media,paste,preview,safari,searchreplace,visualchars,wordcount,xhtmlxtras",
    
    	// Theme options
    	theme_advanced_buttons1 : "cut,copy,paste,pastetext,pasteword,|,undo,redo,removeformat,|,search,replace,|,cleanup,help,code,preview,visualaid,fullscreen",
    	theme_advanced_buttons2 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,|,bullist,numlist,|,outdent,indent,blockquote,|,sub,sup,cite,abbr",
    	theme_advanced_buttons3 : "hr,|,link,unlink,anchor,image,|,charmap,emotions,iespell,media",
    	theme_advanced_toolbar_location : "top",
    	theme_advanced_toolbar_align : "left",
    	theme_advanced_statusbar_location : "bottom",
    	theme_advanced_resizing : true,
    
    	// Example content CSS (should be your site CSS)
    	content_css : "/css/styles.css",
    
    });
    </script>
    <!-- END TinyMCE code -->
    
    <!-- START OF FOOTER -->
    				</div>
    				<!-- END OF MAIN CONTENT -->
    
    				<!-- SIDEBAR -->
    
    				<div class="sidebar">
    					<!-- SIDEBAR ACCOUNT SECTION -->
    
    							<div class="title">
    								<h4>Manage Your Account</h4>
    							</div>
    							<ul>
    								<li><a href="renew.php" title="Renew Your Account">Renew Account</a></li>
    								<li><a href="change_password.php" title="Change Your Password">Change Password</a></li>
    
    								<li><a href="favorites.php" title="View Your Favorites">Favorites</a></li>
    								<li><a href="recommendations.php" title="View Your Recommendations">Recommendations</a></li>
    								<li><a href="logout.php" title="Logout">Logout</a></li>
    							</ul>
    
    								<div class="title">
    									<h4>Administration</h4>
    								</div>
    
    								<ul>
    									<li><a href="add_page.php" title="Add a Page">Add Page</a></li>
    									<li><a href="add_pdf.php" title="Add a PDF">Add PDF</a></li>
    									<li><a href="#" title="Blah">Blah</a></li>
    								</ul>
    														<!-- END OF SIDEBAR ACCOUNT SECTION -->
    
    					<!-- SIDEBAR CONTENT -->
    
    					<div class="title">
    						<h4>Content</h4>
    					</div>
    					<ul>
    						<li><a href="category.php?id=3" title="Topic 1">Topic 1</a></li>
    						<li><a href="category.php?id=5" title="Topic 2">Topic 2</a></li>
    
    						<li><a href="category.php?id=1" title="Topic 3">Topic 3</a></li>
    						<li><a href="category.php?id=4" title="Topic 4">Topic 4</a></li>
    						<li><a href="category.php?id=2" title="Topic 5">Topic 5</a></li>
    						<li><a href="pdfs.php" title="Topic 6">Topic 6</a></li>
    					</ul>
    					<!-- END OF CONTENT SIDEBAR -->
    				</div>
    
    				<!-- END OF SIDEBAR -->
    
    				<!-- FOOTER -->
    				<div class="footer">
    					<p>
    						<a href="site_map.php" title="Site Map">Site Map</a> |
    						<a href="policies.php" title="Policies">Policies</a>
    						  © |
    					</p>
    				</div>
    				<!-- END OF FOOTER -->
    
    			</div>
    			<!-- END OF PAGE BODY -->
    
    		</div>
    		<!-- END OF WRAPPER -->
    
    	</body>
    	<!-- END OF HTML BODY -->
    
    </html>
    

     

    Like I said in my original post, the Javascript editor I tried to add to the comments box doesn't even appear...

     

     

     

    TomTees

  8. I am using MAMP on my MacBook and don't understand why MAMP and my code in NetBeans will not run if I am offline?

     

    If I am trying to execute PHP files locally on my laptop, why should MAMP or Apache of NetBEans care if I do not have an Internet connection?!  :shrug:

     

    I wanted to show someone something at work where there is no Internet access, but that won't work as it currently stands.  :(

     

     

     

    TomTees

     

     

  9. Have you tried looking at the TinyMCE documentation itself?

     

    Already did that.

     

     

    I believe they have a wiki.

     

    It is kind of lame.

     

     

    Also, try implementing the editor in waves.  Try the bare bones editor, followed by the various options you want, one at a time.  That way you can pinpoint exactly where/when it breaks.

     

    Debugging 101 - when in doubt, read documentation straight from the source, and always try the most basic use case/functionality before getting fancy.

     

    There is no editor, so that is pretty bare bone...

     

    It must be something simple.

     

     

    TomTees

     

     

  10. I am reading a book that shows you how to use TinyMCE so that you have an editor to use in a TextArea in the webpage.

     

    I am followed the example in the book but it isn't working.

     

    My book told me to place this code after my <form>...

     

    <!-- TINYMCE CODE -->
    <script type="text/javascript" src="/tiny_mce/tiny_mce.js"></script>
    <script type="text/javascript">
    tinyMCE.init({
    	// General options
    	mode : "exact",
    	elements : "content",
    	theme : "advanced",
    	width : 800,
    	height : 400,
    	plugins : "advlink,advlist,autoresize,autosave,contextmenu,fullscreen,iespell,inlinepopups,media,paste,preview,safari,searchreplace,visualchars,wordcount,xhtmlxtras",
    
    	// Theme options
    	theme_advanced_buttons1 : "cut,copy,paste,pastetext,pasteword,|,undo,redo,removeformat,|,search,replace,|,cleanup,help,code,preview,visualaid,fullscreen",
    	theme_advanced_buttons2 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,|,bullist,numlist,|,outdent,indent,blockquote,|,sub,sup,cite,abbr",
    	theme_advanced_buttons3 : "hr,|,link,unlink,anchor,image,|,charmap,emotions,iespell,media",
    	theme_advanced_toolbar_location : "top",
    	theme_advanced_toolbar_align : "left",
    	theme_advanced_statusbar_location : "bottom",
    	theme_advanced_resizing : true,
    
    	// Example content CSS (should be your site CSS)
    	content_css : "/css/styles.css",
    
    });
    </script>
    <!-- END TinyMCE code -->
    

     

    The form with TextArea appears like it should in the main page but there is no editor.

     

    What am I doing wrong?

     

     

    TomTees

     

     

  11. It is part of your question, since apparently you have them enclosed in php tags without echoing them into the html of the page. If they are intended as HTML comments, they need to be echoed like all of the other HTML. They cannot be used as php comments. If you rename .html files to .php extensions, the only thing that will be interpreted by php is what is inside <?php ?> tags. Everything else is ignored, and sent directly as output to the browser.

     

    So when you are building a website, is there any logical reason to name a file as HTML?

     

    (It seems to me that it would be easier to name HTML, HTML+PHP, and PHP files just as .php for simplicity?!)

     

     

    TomTees

     

     

  12. You can call the file html htm or php and it will still act the same on the web. The only parts that matter are the coding of the page.

     

    Okay, but to be more correct - as I found out last week - you can have 100% HTML in a PHP file and it ill run okay, but if you have any PHP in an HTML (by your webserver default) the PHP won't run.

     

    Right?

     

     

    Also to comment in php you would use

    <?php */ Comment */ ?>

     

    That works only in between the  php start and ends. The normal html comments with the

    <!-- -->

    will work fine outside of the php tags even if on a php page.

     

    Same if it is an HTML file.

     

    That is where I screwed up.  (Of course it didn't help that NetBeans tricked my into thinking I could do this...

     

    <?php
    <!-- Comment grayed out in NetBeans but invalid when code runs!! -->
    ?>
    

     

     

    However if your doing all this just so you can read your code easier, I have no comment to that. Its just kinda well.... ya no comment.

     

    Yeah, GOD FORBID someone actually tried to make their code WELL-DOCUMENTED and READABLE!!  (What w-a-s I thinking?!)  ::)

     

     

     

    TomTees

     

     

  13. I have a file ("header.html") that predominately has HTML in it.

     

    This may sound silly, but I would like to rename it as a .php file so that when I add comments next to my PHP, my IDE will shade them gray.

     

    I just changed all of my PHP comments from

     

    // Some PHP comment

     

    to

     

    <!-- New and Improved PHP comment -->

     

    only to realize that PHP freaks out and doesn't treat them as comments - like NetBeans falsely does - but treats them as erroneous code.

     

    (Now I have to go back and fix all of my files back to the way they were?!)  >:(

     

    If I could change my file from "header.html" to "header.php" then all of my // Comments would be grayed out in my PHP blocks and make my code easier to read.

     

    To achieve that end, is it okay to rename a file from .html to .php even if most of the content is HTML and only a little is PHP?

     

    (BTW, could you have a file that has 100% html content saved as a .php file and still have it work properly?!)

     

    Thanks,

     

     

    TomTees

     

  14. Hmm. I missed the "(true)" in that call to session_regenerate_id.

     

    I lied. It will not overwrite data, but that's only because you specifically told the function that it should not preserve existing information. (By default it does.)

     

    So, does the code I originally posted look okay?

     

    Does it safely regenerate the session id without the risk of losing the user's session information?

     

    If they are an admin, the code regenerates the session id but then should assign the same information the session originally had, so as far as I can see there is nothing to be lost.  :shrug:

     

    The author's code may not be the most efficient, but it looks okay.

     

    I just wanted some second opinions.

     

    Thanks,

     

     

    TomTees

     

     

  15. Try to follow the code yourself. You assign values for the two session variables, then later (maybe) assign two values to the same two session variables.

     

    Yes. It will overwrite. However it will overwrite using the same values as before.

     

    Well I knew that.  What I meant was, is it a problem that it overwrites the values if the person is an admin?

     

    Maybe there is a better way to write the code than the author did?

     

    I'm just not overly familiar with sessions or this session_regenerate_id function...

     

    Thanks,

     

     

    TomTees

     

     

  16. I am trying to implement session_regenerate_id but am a little uncertain about the code from my book.

     

    	// Check for match.
    	if (mysqli_num_rows($r) == 1){
    		// User found.
    		// Fetch User info.
    		$row = mysqli_fetch_array($r, MYSQLI_NUM);
    
    		// Note A
    		$_SESSION['user_id'] = $row[0];						// Assign UserID to Session.
    		$_SESSION['username'] = $row[1];					// Assign Username to Session.
    
    		/* ORIGINAL CODE
    		if ($row[2] == 'admin'){
    			$_SESSION['user_admin'] = true;					// Assign to Session.
    		}
    
    		if ($row[3] == 1){
    			$_SESSION['user_not_expired'] = true;		// Assign to Session.
    		}
    		*/
    
    		// NEW CODE
    		if ($row[2] == 'admin'){
    			// Call before storing any session data, because passing "true" as
    			// the 1st argument causes any existing session data to be destroyed.
    			session_regenerate_id(true);
    			$_SESSION['user_admin'] = true;					// Assign to Session.
    
    			// Will this over-write any data from above (see Note A)??
    			$_SESSION['user_id'] = $row[0];						// Assign UserID to Session.
    			$_SESSION['username'] = $row[1];					// Assign Username to Session.
    		}
    
    		if ($row[3] == 1){
    			$_SESSION['user_not_expired'] = true;		// Assign to Session.
    		}
    	} else {
    

     

    My question is...

     

      // Will this over-write any data from above (see Note A)??

     

    It is nested in the code above along with "Note A".

     

    Thanks,

     

     

     

    TomTees

     

     

     

  17. Just use:

     

    '/[a-zA-Z\'.-]{2,20}$/'

     

    I just noticed you are using a dash ('-') is should be a comma, as far as I know

     

    UGH!!!  What a freshman mistake!!

     

    (Looks like my elderly eyes failed me at nearly 2:00am last night!!)    :shy:

     

    Thanks for the catch!!!

     

     

    TomTees

     

     

  18. Another bizzare thing that stopped working all of a sudden...

     

    I have a registration form and this code no longer works...

    	// Check for First Name.
    	// Allow letters, space, period, apostrophe, and hyphen.
    	if (preg_match('/^[A-Z\'.-]{2-20}$/i', $_POST['first_name'])){
    		$fn = mysqli_real_escape_string($dbc, $_POST['first_name']);
    	} else {
    		// Add error-message to array.
    		$reg_errors['first_name'] = 'Please enter your first name!';
    	}
    

     

    All day when I typed in a two letter answer - to speed up typing and testing - things worked fine, but now I get a built-in error message off to the side of the input box.

     

    I typed 'ee' and that always worked before but no luck now.

     

    The Reg Ex hasn't changed.

     

    Could it be that there is a database connectivity issue that is screwing up my RegEx??

     

    If I comment out all of the RegEx stuff then it works and my INSERT works - thanks to AlexWD  ;D

     

     

    TomTees

     

     

  19. Looks like you have an extra ) here:

     

    ADDDATE(NOW()), INTERVAL 1 MONTH)

     

    Shouldn't that be:

     

    ADDDATE(NOW(), INTERVAL 1 MONTH)

    ?

     

    Yep, that fixed it!

     

    Bizzare-o...

     

    I didn't touch that code all evening and when I went to run a different module - the error is in "Registration" and I was working on "Log In" - things broke?!

     

    Only thing I can think is that I was toggling between the code I downloaded from my book and maybe my code was broken and I didn't catch it...

     

    THANKS!!

     

    BTW, what exactly does that code do??

     

    ADDDATE(NOW(), INTERVAL 1 MONTH)

     

    I guess it adds one month to the current time-date stamp?

     

     

    TomTees

     

     

  20. My application just broke about 2 hours ago and for the life of me I don't know what I did to it?!  :'(  (I was coding a different file, and when I tried to run the main - unrelated index.php - things stopped working?!)

     

    Here is a snippet of the suspect code...

    		if ($rows == 0){
    			// Email and Username are available.
    			// Add User to the database.
    			$q = "INSERT INTO users(username, email, pass, first_name, last_name, date_expires)
    						VALUES('$u', '$e', '" . get_password_hash($p)
    										. "', '$fn', '$ln', ADDDATE(NOW()), INTERVAL 1 MONTH))";
    			$r = mysqli_query($dbc, $q);
    

     

    When I step through my code in NetBeans, the INSERT is failing and I don't know why because I haven't touched this code since this morning and it was working all day...

     

    Please help!

     

     

     

    TomTees

     

     

  21. Well, to be precise, the one starting with ./ is an absolute path and the other is relative.

     

    They both however point to the same location.

     

    ps: These have nothing to do with php per say either. The are part of your OS's file system.

     

    Okay.

     

    So, back to an earlier thread...

     

    How would I say, "The current directory."??

     

    How would I say, "The Web Root."??

     

     

    TomTees

     

×
×
  • 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.