running PHP in HTML

Discussion in 'HTML & Website Design' started by aru211285, Jul 5, 2011.

  1. #1
    Dear friends,

    I have created a html page with dynamic select boxes and included the below line in the form
    <form action="sqlpage.php"target="_blank" method="post">
    HTML:
    . The mentioned sqlpage.php contains some php code with head,body and html tags which connects to MySQL DB and search for queries and displays the results on a webpage.

    But when i run the html page and enter search terms in the query box and click search it directs to this sqlpage and i don't see any results but the php code is displayed as it is on the page. But when i run the page as http:localhost/sqlpage.php it gives perfect results. I guess there is some misinterpretation between html and php.

    I would be thankful if someone help me in this matter.

    Thanks in advance.

    Kind Regards
    Aravind
     
    aru211285, Jul 5, 2011 IP
  2. masterofweb

    masterofweb Greenhorn

    Messages:
    46
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #2
    can i see your that problem on online?????????????
     
    masterofweb, Jul 5, 2011 IP
  3. karthimx

    karthimx Prominent Member

    Messages:
    4,959
    Likes Received:
    127
    Best Answers:
    2
    Trophy Points:
    340
    #3
    is your hosting support php?
     
    karthimx, Jul 5, 2011 IP
  4. AndrewStarlike

    AndrewStarlike Peon

    Messages:
    25
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Check if your server has PHP with:
    
    <?php
    phpinfo();
    ?>
    
    PHP:
     
    AndrewStarlike, Jul 5, 2011 IP
  5. jackburd

    jackburd Active Member

    Messages:
    396
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    73
    #5
    you should also check the .html in localhost/ server
     
    jackburd, Jul 5, 2011 IP
  6. aru211285

    aru211285 Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Dear All,

    Thanks for the replies. I am using WAMP so it coems with Apache, PHP and MySQL and i even checked with Phpinfo() and i have php. Could soem one tell me how to check for html also and i saw in lot of forums they speak about .htaccess file and i couldn't find it.

    Here is the output that my results page displays:
    "; $link = mysql_connect('localhost','root'); if (!$link) { die('Could not connect to MySQL database ' . mysql_error()); } echo 'Connected to the Database. Please scroll down for the results'. "
    "; mysql_select_db("Human-Mouse") or die(mysql_error()); // Query statement with Inner join if ($subject == NULL && $subclass != "All") { $result = mysql_query("SELECT * FROM differences d INNER JOIN `references` r on d.reference = r.reference WHERE class = '$class' AND subclass LIKE '%$subclass%'") or die (mysql_error()); } else if($subclass == "All" && $subject != NULL) { $result = mysql_query("SELECT * FROM differences d INNER JOIN `references` r on d.reference = r.reference WHERE class = '$class' AND subject LIKE '%$subject%' OR human LIKE '%$subject%' OR mouse LIKE '%$subject%'") or die (mysql_error()); } else if($subclass == "All" && $subject == NULL) { $result = mysql_query("SELECT * FROM differences d INNER JOIN `references` r on d.reference = r.reference WHERE class = '$class'") or die (mysql_error()); } else { $result = mysql_query("SELECT * FROM differences d INNER JOIN `references` r on d.reference = r.reference WHERE class ='$class' AND subclass LIKE '%$subclass%' AND subject LIKE '%$subject%' OR human LIKE '%$subject%' OR mouse LIKE '%$subject%'") or die(mysql_error()); } if (mysql_num_rows($result)==0 ) { die('Sorry. No results could be found with your query. Please try with other keywords.' . mysql_error()); } echo ''; echo ''; // Columns names of the table echo ''; echo ''; while($row = mysql_fetch_array($result)) { // linking the reference key to its url $hyperlink = ''.$row[6].''; // start of a new row echo ''; //loop through elements (ie td's) echo ""; echo "
    "; echo ''; } echo '
    Class Subclass Subject Human Mouse Reference
    $row[1] $row[2] $row[3] $row[4] $row[5] $hyperlink
    '; mysql_free_result($result); ?>


    This is the PHP code searching in the MySQL db and it is printed as it is on the webpage.

    NOTE: My webpage has not been published yet. It is only on my PC
     
    aru211285, Jul 6, 2011 IP
  7. aru211285

    aru211285 Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    thanks to aall for trying.....i have solved the problem......its due to error in the installation and configuaration of PHP and HTML details in the WAMP server......now its running as i expected.....
     
    aru211285, Jul 8, 2011 IP