DontheCat Posted December 29, 2018 Share Posted December 29, 2018 I have stored some texts in the database associated with a variable name in my database ... I intend to use this in my site as global text using the variable name ... This is the code I've created in a php file, which I'm 'including' in my webpage . <div style="display:none"> <?php mysqli_select_db($xxx, $database_xxx); $query_Recordset1 = "SELECT * FROM text_declares"; $Recordset1 = mysqli_query($xxx, $query_Recordset1) or die(mysqli_error()); $row_Recordset1 = mysqli_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysqli_num_rows($Recordset1); ?> <?php do { echo '$' . $row_Recordset1['bd_variable'] . ' = "' . $row_Recordset1['bd_desc'] . '"<br>'; } while ($row_Recordset1 = mysqli_fetch_assoc($Recordset1)); echo 'Company Name =' . $company_full_name ; ?> </div> When i execute the file, this is the ouput Quote $company_full_name = "Some Company Pvt. Ltd." $company_small_name = "Some Company" $company_short = "Some" $total_placements = "30000" $total_verticals = "35" $total_emps = "350" $total_offices = "7" $total_countries_present = "4"Notice: Undefined variable: company_full_name in global_text_declares.php on line 13 Company Name = not able to figure out why the $company_full_name is not showing in the echo. Many Thanks for the support . Quote Link to comment Share on other sites More sharing options...
Barand Posted December 29, 2018 Share Posted December 29, 2018 The clue is in the error message. The variable $company_full_name has not been assigned a value anywhere. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted December 29, 2018 Share Posted December 29, 2018 Your first retrieved row is being output correctly while your second one (and later) is being output incorrectly. Quote Link to comment Share on other sites More sharing options...
Barand Posted December 29, 2018 Share Posted December 29, 2018 I think this is what you are trying to do do { ${$row_Recordset1['bd_variable']} = $row_Recordset1['bd_desc']; } while (...) echo "$company_full_name - $company_small_name"; //--> Some Company Pvt, Ltd - Some Company 1 Quote Link to comment Share on other sites More sharing options...
DontheCat Posted December 29, 2018 Author Share Posted December 29, 2018 Many Thanks Barand... ?♂️ I had tried it with a regular bracket instead of the curly and got a syntax error. ? But I still haven't figured out what you meant here... The 1st row outputs the $company_full_name and i was trying to echo that. 1 hour ago, ginerjm said: Your first retrieved row is being output correctly while your second one (and later) is being output incorrectly. Thanks again.... Cheers Quote Link to comment 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.