running PHP in HTML

Discussion in 'PHP' 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. kevydesigns

    kevydesigns Well-Known Member

    Messages:
    1,209
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    125
    #2
    maybe "sqlpage.php" the connection to your db is wrong.
     
    kevydesigns, Jul 5, 2011 IP
  3. aru211285

    aru211285 Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    as i said when i try the sqlpage.php using localhost it gives me correct results in the way i want but when i give it to html page then i get this error of displaying all the code
     
    aru211285, Jul 5, 2011 IP
  4. amitavr

    amitavr Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    How are you getting dynamic select box in an HTML page?
     
    amitavr, Jul 5, 2011 IP
  5. aru211285

    aru211285 Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Here is the code
    <script type="text/javascript">
    		function populate(o)
    		{
    			d=document.getElementById('de');
    			if(!d){return;}			
    			var mitems=new Array();
    			mitems['Select class']=['Select subclass'];
    			mitems['x']=['All','subclass1','subclass2'];
    			mitems['y']=['All','value1','value2'];
    			mitems['z']=['All','value1,'value2'];
    			mitems['w']=['All','value1','value2'];
    			d.options.length=0;
    			cur=mitems[o.options[o.selectedIndex].value];
    			if(!cur){return;}
    			d.options.length=cur.length;
    			for(var i=0;i<cur.length;i++)
    			{
    				d.options[i].text=cur[i];
    				d.options[i].value=cur[i];
    			}
    		}
        </script>
    <select name="class" id="or" onchange="populate(this)">
    <option selected='selected' name="Select class">Select class</option>
    <option name = "x">x</option>
    <option name = "y">y</option>
    <option name ="z">z</option>
    <option name ="w">w</option>
    </select> <br />
    <label for="de">Subclass</label>
    	<select name="subclass" id="de">
    	</select><br />
    HTML:
     
    aru211285, Jul 6, 2011 IP
  6. Kyosys

    Kyosys Peon

    Messages:
    226
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #6
    If it displays the php code of that file it seems like your server doesn't have PHP installed/configured right
     
    Kyosys, Jul 6, 2011 IP
  7. aru211285

    aru211285 Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    thanks to all, i have solved my problem.....it was due to some problems in the installation of the server and configuration
     
    aru211285, Jul 7, 2011 IP
  8. dsoft

    dsoft Greenhorn

    Messages:
    32
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    18
    #8
    so it was PHP problems? or another installation issues? thanks
     
    dsoft, Jul 9, 2011 IP
  9. technonur

    technonur Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    i think its not php problems . maybe server settings or html code have erros.
     
    technonur, Jul 10, 2011 IP
  10. aru211285

    aru211285 Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    the html file with the php code was not on the server so the browser prints the PHP code as it is and when i moved the file to the server directories it worked like charm....thanks to all of u....will be back again if i have some problem.....

    cheers,
    Aravind
     
    aru211285, Jul 11, 2011 IP