farnoise Posted January 19, 2010 Share Posted January 19, 2010 Good day, I'm having this code here, its a HTML table that is showing up in my PHP page everything works fine but the problem is, It doesn't show any data in the echo section. PS: There is nothing wrong with my connection string or other stuff, because if I call the variables outside of this table I can see them but I cant see anything inside the table. Should I use any variable encoder or something??????? please HELP >>>>>>>>>PHP CODES<<<<<<<<<<<<<< mysql_connect("localhost", "admin", "Pass") or die(mysql_error()); mysql_select_db("movedb") or die(mysql_error()); $find = strtoupper($find); $find = strip_tags($find); $find = trim ($find); $data = mysql_query("SELECT * FROM sheet1sa WHERE upper($field) LIKE'%$find%'"); while($result = mysql_fetch_array( $data )) { echo <<<HTML <table width="400" border="0" class="sample"> <tr> <td width="97" rowspan="5"><? echo $F6; ?> </td> <td width="125">Name, Lastname</td> <td width="164"> <? echo $name; ?> </td> </tr> <tr> <td>Cell Number </td> <td> <?php echo $cell; ?> </td> </tr> <tr> <td>Extension Number </td> <td> <?php echo $ext; ?> </td> </tr> <tr> <td>Office Number </td> <td><?php echo $F2; ?> </td> </tr> <tr> <td>Department</td> <td><?php echo $dep; ?> </td> </tr> </table> <br> <br> HTML; } >>>>>>>>>PHP CODES<<<<<<<<<<<<<< Quote Link to comment https://forums.phpfreaks.com/topic/189016-echo/ Share on other sites More sharing options...
taquitosensei Posted January 19, 2010 Share Posted January 19, 2010 I don't think it will parse the php that way. Try this >>>>>>>>>PHP CODES<<<<<<<<<<<<<< mysql_connect("localhost", "admin", "Pass") or die(mysql_error()); mysql_select_db("movedb") or die(mysql_error()); $find = strtoupper($find); $find = strip_tags($find); $find = trim ($find); $data = mysql_query("SELECT * FROM sheet1sa WHERE upper($field) LIKE'%$find%'"); while($result = mysql_fetch_array( $data )) { // ?> <table width="400" border="0" class="sample"> <tr> <td width="97" rowspan="5"><?php echo $F6; ?></td> <td width="125">Name, Lastname</td> <td width="164"><?php echo $name; ?></td> </tr> <tr> <td>Cell Number </td> <td><?php echo $cell; ?></td> </tr> <tr> <td>Extension Number </td> <td><?php echo $ext; ?></td> </tr> <tr> <td>Office Number </td> <td><?php $F2; ?></td> </tr> <tr> <td>Department</td> <td><?php echo $dep; ?></td> </tr> </table> <br> <br> <?php } Quote Link to comment https://forums.phpfreaks.com/topic/189016-echo/#findComment-997979 Share on other sites More sharing options...
Buddski Posted January 19, 2010 Share Posted January 19, 2010 If you were to replace your, <?php echo $dep; ?> with {$dep}, for example, it will work inside your heredoc statement.. Quote Link to comment https://forums.phpfreaks.com/topic/189016-echo/#findComment-998015 Share on other sites More sharing options...
farnoise Posted January 19, 2010 Author Share Posted January 19, 2010 ?> <table width="400" border="0" class="sample"> <tr> <td width="97" rowspan="5"><?php echo $F6; ?></td> <td width="125">Name, Lastname</td> <td width="164">{$name}, </td> </tr> <tr> <td>Cell Number </td> <td><?php echo {$cell}, ?></td> </tr> <tr> <td>Extension Number </td> <td><?php echo $ext; ?></td> </tr> <tr> <td>Office Number </td> <td><?php $F2; ?></td> </tr> <tr> <td>Department</td> <td><?php echo $dep; ?></td> </tr></table><br> <br> <?php Neither of these works !!!! Well the last reply messed up my pgae Quote Link to comment https://forums.phpfreaks.com/topic/189016-echo/#findComment-998019 Share on other sites More sharing options...
Buddski Posted January 19, 2010 Share Posted January 19, 2010 You arent actually defining those values, as far as I can tell anyway. You need to either define them or replace them with $result['field_name'] Quote Link to comment https://forums.phpfreaks.com/topic/189016-echo/#findComment-998024 Share on other sites More sharing options...
farnoise Posted January 19, 2010 Author Share Posted January 19, 2010 Bu as I said if I just call this variabales ouside of my HTML area I can see the result so there is nothing wrong with that variable example if i use $data = mysql_query("SELECT * FROM sheet1sa WHERE upper($field) LIKE'%$find%'"); while($result = mysql_fetch_array( $data )) { echo $cell; I'll see the cell number but if I put in that HTML format nothing shows up Quote Link to comment https://forums.phpfreaks.com/topic/189016-echo/#findComment-998039 Share on other sites More sharing options...
Buddski Posted January 19, 2010 Share Posted January 19, 2010 Are you getting the HTML output at all? or are the vars just not showing up.. Quote Link to comment https://forums.phpfreaks.com/topic/189016-echo/#findComment-998043 Share on other sites More sharing options...
farnoise Posted January 19, 2010 Author Share Posted January 19, 2010 Yes im getting My Table every thing works just fine, But I dont see VARs!! Just want to remember again: If I use my echo command outside my HTML section I can see the VARS so it means everything is ok in PHP Quote Link to comment https://forums.phpfreaks.com/topic/189016-echo/#findComment-998048 Share on other sites More sharing options...
Buddski Posted January 19, 2010 Share Posted January 19, 2010 You may be getting some errors.. error_reporting(E_ALL); ini_set('display_errors',1); Quote Link to comment https://forums.phpfreaks.com/topic/189016-echo/#findComment-998052 Share on other sites More sharing options...
farnoise Posted January 19, 2010 Author Share Posted January 19, 2010 I'm pretty sure there is no error, I've tried that I didnt get anything.. well here is my whole scrpt do you mind take a look at it and tell me if it looks OK or not!? <link href="../css/lightstyle.css" type="text/css" rel="stylesheet" /> <?php include("../header.php"); ?> <script type="text/JavaScript"> <!-- function MM_jumpMenu(targ,selObj,restore){ //v3.0 eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'"); if (restore) selObj.selectedIndex=0; } //--> </script> <form name="search" method="post" action="<?=$PHP_SELF?>"> <fieldset><legend>Phonebook System</legend><input name="find" type="text" value="Search" maxlength="100" /> <div align="left"><h5> <Select NAME="field" class="arad"> <option value="name">Name and(or) Last name</option> <option value="cell">Cell Number</option> <option value="ext">Extension / Office</option> <option value="dep">Department</option> </Select> <input type="hidden" name="searching" value="yes" /> <input type="submit" name="search" value="Search" class="btt1"/> </div> </form> <div align="left"> <p> <? if ($searching =="yes") { echo "<h5>Results<p>"; if ($find == "") { echo "<p>You forgot to enter a search criteria"; exit; } mysql_connect("localhost", "Uganda", "u^77HYuj***$$") or die(mysql_error()); mysql_select_db("movedb") or die(mysql_error()); $find = strtoupper($find); $find = strip_tags($find); $find = trim ($find); //Now we search for our search term, in the field the user specified $data = mysql_query("SELECT * FROM sheet1sa WHERE upper($field) LIKE'%$find%'"); while($result = mysql_fetch_array( $data )) { echo <<<HTML <table width="400" border="0" class="sample"> <tr> <td width="97" rowspan="5"><? echo $F6; ?> </td> <td width="125">Name, Lastname</td> <td width="164"> <? echo $name; ?> </td> </tr> <tr> <td>Cell Number </td> <td> <?php echo $cell; ?> </td> </tr> <tr> <td>Extension Number </td> <td> <?php echo $ext; ?> </td> </tr> <tr> <td>Office Number </td> <td><?php echo $F2; ?> </td> </tr> <tr> <td>Department</td> <td><?php echo $code; ?> </td> </tr> </table> <br> <br> HTML; } $anymatches=mysql_num_rows($data); if ($anymatches == 0) { echo "<h5>Sorry, but I can not find the person that you are looking for.<br>Please .<br><br>Thanks"; } //And we remind them what they searched for echo "<b><h5>Searched For:</b></b> " .$find; echo "<br>"; echo "<br>"; } ?> <head> </head> <body> </p> <p> </p> <hr width="500" size="1" /> <p> </p> <p> </p> <p align="center"> </p> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/189016-echo/#findComment-998059 Share on other sites More sharing options...
Buddski Posted January 19, 2010 Share Posted January 19, 2010 Apart from your HTML being all messed up <head> </head> <body> at the bottom of the page.. I still cannot see where you are defining those variables you are trying to call.. You also cannot use <?php ?> inside a HEREDOC statement.. Quote Link to comment https://forums.phpfreaks.com/topic/189016-echo/#findComment-998082 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.