Herod Posted October 12, 2007 Share Posted October 12, 2007 Hello. I have a function that need to read from the database and display infos on a page: here's the code i'll explain down what i was thinking: this is the function: <?php function text_areas_populated($pag) { $gs = strtoupper(substr($pag, 0,1)); // get the table first letter. all the fields in the database have an letter to define what table they are in //sTitlu_roN, sStire_roN for example. echo "Title news Romana<br />"; echo '<input class="titlu" type="text" name="titlu_ro" value="'.$row_get_.$pag['sTitlu_ro'.$gs].'" /><br />'; /* .... */ echo "News Romana<br />"; echo '<textarea name="stire_ro" class="stire">'.$row_get_.$pag['sStire_ro'.$gs].'</textarea><br />'; /* .... */ }?> and this is the calling of the function: <?php $sql_get_news = "SELECT * FROM t_news WHERE nIdN = '".$_GET['id']."'"; $res_get_news = mysql_query($sql_get_news) or die (mysql_error(__LINE__)); $row_get_news = mysql_fetch_array($res_get_news); echo text_areas_populated ($_GET['pag']); // where page in this case is news My problem is that nothing is displayed in the input fields. Can anyone help me with this problem? Thank you! [edited by kenrbnsn to put in the tags] Quote Link to comment https://forums.phpfreaks.com/topic/72878-_get-problem-in-a-function/ Share on other sites More sharing options...
pocobueno1388 Posted October 12, 2007 Share Posted October 12, 2007 Where do you define this variable? $row_get_.$pag If it is outside of the function, you probably have a scope issue. Show more code that shows where that variable is defined, and it will be easier to help you. Quote Link to comment https://forums.phpfreaks.com/topic/72878-_get-problem-in-a-function/#findComment-367570 Share on other sites More sharing options...
Herod Posted October 12, 2007 Author Share Posted October 12, 2007 this is the page: <script type="text/javascript"> function do_change() { if(document.getElementById('id_poza').value == 0) { document.getElementById('poza_default').innerHTML='<img src="../imag/select_image.gif" />'; } else { document.getElementById('poza_default').innerHTML='<img src="../imag/poze_stiri/'+(document.getElementById('id_poza').value)+'" />'; } } </script> <table width="780px" align="center"> <tr> <td class="text_top"> <? echo $_SESSION['news_err']['title']; echo $_SESSION['news_err']['stire']; echo $_SESSION['news_err']['match']; ?> </td> </tr> <tr> <td align="center"> <h3 style="color:#ffffff; font-family:Arial, sans-serif"> REVIEW AND PUBLISH NEWS </h1> </td> </tr> <tr> <td class="text_top" align="center"> <form action="stiri_publica.do.php" method="post"> <?php $sql_get_news = "SELECT * FROM t_news WHERE nIdN = '".$_GET['id']."'"; $res_get_news = mysql_query($sql_get_news) or die (mysql_error()); $row_get_news = mysql_fetch_array($res_get_news); echo text_areas_populated($_GET['pag']); $sql_select_poze = "SELECT * FROM t_poze ORDER BY sNume_PozaP ASC"; $res_select_poze = mysql_query($sql_select_poze) or die (mysql_error()); ?> Select a picture:<br /> <select id="id_poza" name="id_poza" onchange="do_change()"> <option value="0">Select a picture</option> <?php while ($row_select_poze = mysql_fetch_array($res_select_poze)) { ?> <option value=<?=$row_select_poze['sNume_PozaP']; ?> ><?=$row_select_poze['sAlt_PozaP']; ?></option> <?php } ?> </select> <div id="poza_default"><img src="../imag/select_image.gif"></div><br /> <div align="center"> News you are posting will not be automaticaly be inserted into the website. They will be verified by an website admin and after that they will be aproved or not to be published!<br /><br /><br /> </div> <input type="submit" class="submit" value="Post news" /><br /> </form> </td> </tr> </table> <? unset ($_SESSION['news_err'], $_SESSION['posturi_news'], $_SESSION['posturi']); ?> and function remain the same. Quote Link to comment https://forums.phpfreaks.com/topic/72878-_get-problem-in-a-function/#findComment-367574 Share on other sites More sharing options...
kenrbnsn Posted October 12, 2007 Share Posted October 12, 2007 Please use tags around you code snippets. Doing so will make them much more readable. Reading RED code is very hard on the eyes. Ken Quote Link to comment https://forums.phpfreaks.com/topic/72878-_get-problem-in-a-function/#findComment-367578 Share on other sites More sharing options...
Herod Posted October 12, 2007 Author Share Posted October 12, 2007 Also the function is written in a separate file functions.php Quote Link to comment https://forums.phpfreaks.com/topic/72878-_get-problem-in-a-function/#findComment-367602 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.