Hi,

A couple of weeks ago I installed XAMPP according to a DreamWeaver book I had, and it was all really simple. Download the thing and run it. However, now that I'm understanding PHP and Apache more I want to move past Dreamweaver and see how it actually works.

So I downloaded Crimson Editor and made a simple Database program:

<html>
<head>
<title>Test Page</title>
</head>

<body>
<?php
	$dbhost = 'localhost';
	$dbuser = 'Denis';
	$dbpass = 'denis';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');

$dbname = 'petstore';
mysql_select_db($dbname);
?>
</body>
</html>

However, whenever I try and preview it in my browser (FireFox3) from Crimson Editor (by clicking Alt-😎 it doesn't work, i get the following non-sense directory path:

file:///D:/xampp/htdocs/LEARNI~1/LEARNI~1.PHP

I thought this might have been an error on my part with the database, so I went through the declaring a database steps in Dreamweaver and it worked fine, however in Crimson Editor like it said it doesn't work. I went looking through some websites and they all have massively varying ways of installing XAMPP, could you guys help me to get Crimson Editor to work and explain how it works?

If you think this issue is something other than my XAMPP/myPhpAdmin installation (i hope it is!) then can you also help me out

Thanks

EDIT: Forgot to say what happens when I launch page through Dreamweaver. It works fine with the correct directory path:

http://localhost/BeginningPhp/learning1.php

    Crimson editor just sends the browser the file path to open, in this case D:/xampp/htdocs/... etc.

    Opening a PHP file directly in the browser means that it isn't parsed by PHP, and the script is just output at plaintext.

    What you'd need to do is tell crimson editor that anything in D:/xampp/htdocs is actually at http://127.0.0.1/, but as far as I know there isn't a feature in the software to do this.

      Had a look, fun little hack around:

      Make a script htdocs called run.php, and put this in it:

      <?php
      if (isset($_GET['loc'])) {
        header('Location: ' . str_replace('D:\\xampp\\htdocs\\','',stripslashes($_GET['loc'])));
      }
      ?>
      

      Then open crimson editor, click Tools -> conf. user tools.
      Click an empty one, and name the menu text what you like, for example: Run.
      Command should be set to C:\Program Files\Mozilla Firefox\firefox.exe, or whatever the path of your browser is.
      Set argument to "http://localhost/run.php?loc=$(FilePath)", which will send the script path to the script up there.
      And then set the shortcut under hot-key.

      That should emulate the functionality of dreamweaver. It could be done using the inbuilt macro functionality, however I don't have the time to learn how to use it, so I figured forwarding it to a script would be easier.

      (XAMPP appears to be installed fine, in case you were wondering, it's an editor issue)

        thanks, that really helped 🙂

        It's connecting to the database now, however I have a slight problem. When it runs it runs with the following filepath:

        http://localhost/BeginningPhp[/B]createmovie.php

        And that causes an error because it is meant to go to: /createmovie.php instead. Is there a way to fix this?

        Also, would you know how to do the same thing to NotePad++
        Just I've been playing around with different editors and this one has a very handy auto-complete which is sadly a function that Crimson Editor doesnt have

          Haha, it's funny you say that, because once I posted that, I made it for notepad++ and fixed the backward slash issue.

          header('Location: ' . str_replace(array('d:\\xampp\\htdocs\\','\\'),array('','/'),strtolower(stripslashes($_GET['loc']))));
          

          To add it in Notepad++:

          Press F5 (or go to Run -> Run...) and type into the box:

          firefox "http://localhost/run.php?loc=$(FULL_CURRENT_PATH)"

          And then click save, and save it as you wish.

            Hey,

            I'm still getting the following error:

            http://localhost/BeginningPhp\createmovie.php

            The backwards slash...

              It shouldn't be if you changed the PHP code of run.php, as it does a str_replace and replaces '\' (escaped backslash) with '/' (forward slash).

              It is only a quick hack, and you should be able to modify run.php to take the path that it is given by the editor, and manipulate it how you want before forwarding to whatever page it is you need.

                Hey, the hack for Crimson Editor works fine, but Notepad++ doesn't work. All I did was add the:

                firefox "http://localhost/run.php?loc=$(FULL_CURRENT_PATH)"

                , i didn't do anything with the run thing for Notepad++.

                Sorry bout this 🙁

                Also, would you know if it is possible to make Notepad++ do what Crimson Editor does by highlighting the whole line. Just I'm used to that from VisualBasic and DarkBasic (via Darkedit) and it's kinda a thing of habit.

                Thanks

                  Zend Studio highlights lines. 😉

                    uh, so does Crimson Editor. But NotePad++ has the possibilty to be an awesome FREE, auto completing, highlighting coding environment... that is if I can get some help with fixing the backwards slash issue (pretty please madwormer2)

                      In the run.php file, replace the code with

                      <?php
                      if (isset($_GET['loc'])) {
                        header('Location: ' . str_replace(array('d:\\xampp\\htdocs\\', '\\'), array('', '/'), strtolower(stripslashes($_GET['loc'])))); 
                      }
                      ?> 
                      

                      If that doesn't work, let me know what the error is.

                      I'm not sure what you both mean by "highlight lines"? It's sort of ambigous.

                        madwormer2;10880689 wrote:

                        I'm not sure what you both mean by "highlight lines"? It's sort of ambigous.

                        See attached.

                          From what I can see, Crimson Editor lacks this feature also. He must mean something different.

                            Yes, I mean the same thing as in Crimson Editor.

                            Like when you are typing in line 3 of the editor it highlights the whole row, so you can differentiate that row from everything else.

                            Like this:[ATTACH]3613[/ATTACH]

                            EDIT - Thanks php database files now run, thanks heaps 🙂

                              Not to worry I fixed NotePad++, and it looks awesome now 🙂

                              Just for other people who might be interested, everything in NotePad++ is customisable to your liking. To change just about anything go to:

                              Settings>Styler Configurator>Global Styles (This affects everything)

                              From there you can edit the Current Line Background to make it highlight the current line, as well as just about anything else. You can change language specific highlighting by choosing the language you want to use.

                              Thanks all for helping me with this 🙂 (particularily you mad 😉)

                                Your welcome.

                                I was thinking that was what you meant, but then you said that notepad++ didn't have it, and it threw me completely because I have that feature enabled, and am pretty sure it came enabled.

                                If all is well, you can "Mark thread resolved" under thread tools.

                                  Write a Reply...