SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Thread: newbie

  1. #1
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    newbie

    i have been learning php recently, but just to ask a novice question, i have a prototype website in xhtml, just thinking if i change the file name to .php, what should be the outcome(though i have done that, it came back with nothing, can u please give me a technical reason, and what do you advise)

  2. #2
    SitePoint Zealot
    Join Date
    Jan 2011
    Location
    Portland
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    do you have php installed?

  3. #3
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    70 Post(s)
    Tagged
    0 Thread(s)
    If PHP is installed correctly, Apache will send the file to the PHP parser for parsing, then do whatever it would normally do with HTML.

  4. #4
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    yes, i have php instaled, but did not give anything back, could it be because of the doc type declared
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

  5. #5
    Non-Member
    Join Date
    Mar 2010
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    get the PHP installer and then you can easily change the domain name with .php

  6. #6
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    70 Post(s)
    Tagged
    0 Thread(s)
    "Did not give anything back"? As in a white screen of nothingness?

    This is what PHP developers call "I've got an error but i've got display_errors disabled".

  7. #7
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Just to say that if you DO have PHP running, with Apache, then one can tell apache to process all .html files as PHP - or any file-type, eg .asp.

    Most of my sites are .htm to the naked eye but act and behave as .php files*

    I am not saying this is your best option, just throwing it out there for anyone else reading this - in case you did not want to risk upsetting the SEO gods.

    Off Topic:

    At a very large site I converted from asp to php we used the same trick and it was with great satisfaction we watched all the script-kiddy probes continue to target known .asp frailties.

  8. #8
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    actually, i did some spelling mistakes, which i have corrected in the mark up, but i am having the error , database query failed , here is my mark up below.
    Code PHP:
    error_reporting(E_ALL); 
    ini_set('display_errors',1);
    <?php
    	//1.create database connection
    	$connection = mysql_connect("localhost","root","password");
    	if (!$connection) {
    		die("Database connection failed: " . mysql_error());
    		}
    		//2 select database to use
    	$db_select = mysql_select_db("reacheasy","connection");
    	if ($db_select) {
    		die("Database selection failed: " . mysql_error());
    		}
    		?>
    <?php require_once("include/functions.php"); ?>
    <?php include("include/header.php"); ?>
    <div id="navigation">
    <ul>
    <li>
     
        <?php
    	//3. perform database querry
    	$result = mysql_query("SELECT * FROM subjects", $connection);
    	if (!$result) {
    		die("Database query failed: " . mysql_error());
    		}
    		//4 use returned data
    	while($row = mysql_fetch_array($result)) {
    		echo $row["menu_name"]." ".$row["position"]."<br />";
    		}
    		?>
    	</li>	
    </ul>
    </div> <!--end of navigation div -->
    <div id="bodycontent">
    <h3> content area</h3>
    <p> i hope this works. </p>
    </div>
    <?php include("include/footer.php"); ?>
    <?php
    	//5. close connection
    	mysql_close($connection);
    	?>
    did you notice any wrong thing, i have checked my database and subjects is there

  9. #9
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    PHP Code:
        $db_select mysql_select_db("reacheasy",$connection); 
    PHP: mysql_select_db - Manual

  10. #10
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    actually , i have found where the problem is
    if ($db_select) {
    die("Database selection failed: " . mysql_error());
    its suppose to be
    (!$db_select)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •