php - search attempt syntax error -


this question has answer here:

i not figure out if doing right. trying output results search, unsure if done properly. plus i'm getting error.

parse error: syntax error, unexpected '''' (t_constant_encapsed_string) in /usr/local/www/project/olegariojw/largecoursework/tobakuhome.php on line 152

in addition, intending put inside div 2 of results <a> tag these have links , inside variable. how done?

below code:

<html> <header></header>  <body>  <?php     $servername = "example.com";     $dbname = "abc";     $user = "abc";     $pass = "abc";      $connection = mysqli_connect($servername, $user, $pass, $dbname);     if (!$connection){         die("connection failure" . mysqli_connect_error());     }  ?>  <form id ="search" action="tobakuhome.php" method="post">         <input type="text" name="search" placeholder="search game titles here"/>         <input type="submit" value="go" /> </form>  <?php print("$output"); ?>  <?php  $output = ''; if (isset($_post['search'])){     $searching = $_post['search'];     $searching = preg_replace("#[^0-9a-z]#i","", $searching); }       $query = "select * software name '%searching%' or description '%$searching%' or exclusivity '%$searching%' or format '%$searching%'";     $result = mysqli_query($connection, $query) or die("no results found");     $count = mysqli_num_rows($query);     if($count ==0){         $output = 'sorry, no results found.';      }else{         while($row = mysqli_fetch_array($query)){             $tname = $row['name'];             $tdes = $row['description'];             $timg = $row['image'];             $texcl = $row['exclusivity'];             $tform = $row['format'];             $tprice = $row['price'];             $id = $row['id'];               $output .= '<div id="data">''<ul id="itemgal">'             '<li id = "softitem">'             '<a id= "row" href = "displaysoftware.php?id=" .$id." '.$tname.' />' '</a>'             '<a id= "row" href = "displaysoftware.php?id=" .$id." '.$timg.' />'    '</a>'             '<br />'             '<h3>'.$tform . '</h3>''</td>'             '<br />'             '<h4>'.$texcl . '</h4>''</td>'             '<h5>' '£' . $tprice.'</h5>'             '</li>'             '</ul>'             '</div>';         }     }  ?> </body> </html> 

you forgot single quotes around $id in $output variable , then, when have string spread on more lines, need use dot . in end of each row, of don't close string quote.

$output .= '<div id="data"><ul id="itemgal">' .                                               ^             '<li id = "softitem">' .                                    ^             '<a id= "row" href = "displaysoftware.php?id="' .$id. '" '.$tname.' /></a>' .                ^                                          ^       ^                     ^             '<a id= "row" href = "displaysoftware.php?id="' .$id. '" '.$timg.' />'    '</a>' //                                                        ^       ^ etc.  

put . @ end of each row in $output var.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -