Jump to content

When i submit the form, browser just prints my code


soundaddict

Recommended Posts

This is a simple search script that I wrote to search a mysql database.  When i submit the search term, however, the browser just prints the bottom half of my code.  I am a total newbie, and would appreciate if someone would point me in the right direction.

 

Here is the code

 


<?php
   	$search=$REQUEST("search");

if (!empty($REQUEST["search"])) {
	$conn = mysql_connect("localhost", "content_code", "dolby")
			or die("ERROR: Could not connect to the database");
	mysql_select_db ("content");
		$sql = "SELECT * FROM content WHERE * LIKE '%".$search."%'";
	$result = mysql_query ($sql ,$conn);

	while ($row = mysql_fetch_array($result)){
		$clipid= $row['clipID'];
		$content_title = $row['content_title'];
		$clip_length = $row['clip length'];
		$studio = $row ['studio'];
		$color_space = $row['resolution'];
		$high_motion = $row['high_motion'];

	<<<HERE
		print
		<tr>
		<th>Clip ID</th>
		<th>Title</th>
		<th>Length</th>
		<th>Studio</th>
		<th>Color Space</th>
		<th>High Motion</th>
		</tr>
HERE;
		foreach($row as $clip){
		 <<<Hello
		 	print
			<tr>
			<td>.$clipid.</td>
			<td>.$content_title.</td>
			<td>.$clip_length.</td>
			<td>.$studio.</td>
			<td>.$color_space.</td>
			<td>.$high_motion.</td>
			</tr>
Hello;

		}//end foreach
	}//end while

}  //end if

else{
	print "Please enter a search query";
}//end else
?>

<?php
      $search=$REQUEST("search");
   
   if (!empty($REQUEST["search"])) {
      $conn = mysql_connect("localhost", "content_code", "dolby")
            or die("ERROR: Could not connect to the database");
      mysql_select_db ("content");
         $sql = "SELECT * FROM content WHERE * LIKE '%".$search."%'";
      $result = mysql_query ($sql ,$conn);
      
      while ($row = mysql_fetch_array($result)){
         $clipid= $row['clipID'];
         $content_title = $row['content_title'];
         $clip_length = $row['clip length'];
         $studio = $row ['studio'];
         $color_space = $row['resolution'];
         $high_motion = $row['high_motion'];
         
      echo <<<HERE
         <tr>
         <th>Clip ID</th>
         <th>Title</th>
         <th>Length</th>
         <th>Studio</th>
         <th>Color Space</th>
         <th>High Motion</th>
         </tr>
HERE;
         foreach($row as $clip){
          echo <<<Hello
            <tr>
            <td>.$clipid.</td>
            <td>.$content_title.</td>
            <td>.$clip_length.</td>
            <td>.$studio.</td>
            <td>.$color_space.</td>
            <td>.$high_motion.</td>
            </tr>
Hello;
         
         }//end foreach
      }//end while
      
   }  //end if
   
   else{
      print "Please enter a search query";
   }//end else
?>

 

you must put an echo for heredocs (start)<<<HERE (end)-> HERE;

 

echo <<<FIRST 
hello this heredoc
FIRST;

 

you can try, i little of knowledge in php, i am starting in php

 

edit: then you remove the print statement

cheers

Archived

This topic is now archived and is closed to further replies.

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