jmatulevich Posted February 8, 2010 Share Posted February 8, 2010 I can hit the DB no problem.... However the code below is returning blank... is there a new Query for 5? ~~~~~~~~~~~~~~ <?php $result = mysql_query("SELECT * FROM $table WHERE item_number = '$item_number' "); while($row = mysql_fetch_array($result)) { echo $row['item_number']; } ?> Link to comment https://forums.phpfreaks.com/topic/191390-works-perfect-in-php43-but-is-blank-in-php5/ Share on other sites More sharing options...
Mchl Posted February 8, 2010 Share Posted February 8, 2010 Where does $item_number come from? Link to comment https://forums.phpfreaks.com/topic/191390-works-perfect-in-php43-but-is-blank-in-php5/#findComment-1008986 Share on other sites More sharing options...
jmatulevich Posted February 8, 2010 Author Share Posted February 8, 2010 from a Form feeding the page... <FORM NAME="ViewItem" METHOD=POST ACTION="submit_view_item.php"> <div align="center"> <table width="275" border="0" align="center" bgcolor="#FFFFFF"> <tr> <td><div align="center" class="SubHeader">To VIEW Item Data <br> Select Item Number from List </div> <label></label></td> </tr> <tr> <td><div align="center"> <?php $query = "SELECT * FROM $table ORDER BY item_number"; $result = mysql_query($query) or die(mysql_error()); echo "<SELECT NAME=\"item_number\">\n"; while ($row = mysql_fetch_assoc($result)) { echo "<OPTION VALUE=\"$row[item_number]\">$row[item_number]</option>\n"; } echo "</SELECT>\n"; ?> <input type = "Submit" name = "Submit2" value = "Look-Up" /> </div></td> </tr> <tr> <td height="26"><div align="center"></div></td> </tr> </table> </div> </FORM> Link to comment https://forums.phpfreaks.com/topic/191390-works-perfect-in-php43-but-is-blank-in-php5/#findComment-1008987 Share on other sites More sharing options...
Mchl Posted February 8, 2010 Share Posted February 8, 2010 Starting from PHP5 register_globals setting is disabled by default. You should use $_POST and $_GET arrays instead. <?php $item_number = mysql_real_escape_string($_POST['item_number']); $result = mysql_query("SELECT * FROM $table WHERE item_number = '$item_number' "); while($row = mysql_fetch_array($result)) { echo $row['item_number']; } ?> Link to comment https://forums.phpfreaks.com/topic/191390-works-perfect-in-php43-but-is-blank-in-php5/#findComment-1009004 Share on other sites More sharing options...
jmatulevich Posted February 8, 2010 Author Share Posted February 8, 2010 Fixed it ... Thanks so much... I need to probably re-write this entire thing... but once <?php $item_number = mysql_real_escape_string($_POST['item_number']); $result = mysql_query("SELECT * FROM $table WHERE item_number = '$item_number' "); while($row = mysql_fetch_array($result)) { echo $row['item_number']; } ?> The rest of the page filled in nicely Link to comment https://forums.phpfreaks.com/topic/191390-works-perfect-in-php43-but-is-blank-in-php5/#findComment-1009019 Share on other sites More sharing options...
jmatulevich Posted February 8, 2010 Author Share Posted February 8, 2010 I was able to get all the reads fixed by just enabling the registar_globals. And I am able to Create new records, but this does not update for some reason <?php mysql_query("UPDATE $table SET replacement_item = '$replacement_item' WHERE item_number = '$item_number'"); ?> Do i need to use $item_number = mysql_real_escape_string($_POST['item_number']); in this file also?... Sorry about the newb questions. I have very little mileage on this... Link to comment https://forums.phpfreaks.com/topic/191390-works-perfect-in-php43-but-is-blank-in-php5/#findComment-1009046 Share on other sites More sharing options...
Mchl Posted February 8, 2010 Share Posted February 8, 2010 If you have register_globals enabled, you shouldn't need this (although using $item_number = mysql_real_escape_string($item_number) would still be a good idea due to security concerns). Read more here about register_globals, and why it has been disabled: http://php.net/manual/en/security.globals.php Link to comment https://forums.phpfreaks.com/topic/191390-works-perfect-in-php43-but-is-blank-in-php5/#findComment-1009051 Share on other sites More sharing options...
jmatulevich Posted February 8, 2010 Author Share Posted February 8, 2010 i am missing something then... it still will not updating... I will play with it more... Thanks Link to comment https://forums.phpfreaks.com/topic/191390-works-perfect-in-php43-but-is-blank-in-php5/#findComment-1009074 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.