soundaddict Posted August 24, 2009 Share Posted August 24, 2009 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 ?> Link to comment https://forums.phpfreaks.com/topic/171700-when-i-submit-the-form-browser-just-prints-my-code/ Share on other sites More sharing options...
JOWP Posted August 24, 2009 Share Posted August 24, 2009 <?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 Link to comment https://forums.phpfreaks.com/topic/171700-when-i-submit-the-form-browser-just-prints-my-code/#findComment-905397 Share on other sites More sharing options...
merck_delmoro Posted August 24, 2009 Share Posted August 24, 2009 you need a php server like wamp or xamp Link to comment https://forums.phpfreaks.com/topic/171700-when-i-submit-the-form-browser-just-prints-my-code/#findComment-905421 Share on other sites More sharing options...
soundaddict Posted August 24, 2009 Author Share Posted August 24, 2009 I am running xampp, and have been running the script through the localhost. Is there a reason that xampp could simply not be recognizing the code? Link to comment https://forums.phpfreaks.com/topic/171700-when-i-submit-the-form-browser-just-prints-my-code/#findComment-905434 Share on other sites More sharing options...
merck_delmoro Posted August 25, 2009 Share Posted August 25, 2009 @JOWP maybe you are right about print but if there are errors in php script there should be no output and it will be blank @soundaddict check if your xamp server was activate or online Link to comment https://forums.phpfreaks.com/topic/171700-when-i-submit-the-form-browser-just-prints-my-code/#findComment-905442 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.