iceblox Posted June 8, 2009 Share Posted June 8, 2009 Hi guys i need to replace some data in one of my queries i think the best way to do this is through 3 str_replace queries but im not sure where to place this within by script. Can anyone help me with this? $arr = array(); $query = "SELECT * FROM errordata WHERE MerchantID = 'Dial-A-Phone'"; $result = mysql_query($query); if (mysql_num_rows($result) > 0) { while($row = mysql_fetch_array($result)) $arr[$row['error_text']] = $row['correct_id']; } else { echo 'No rows found!'; } Thanks, Phil Quote Link to comment https://forums.phpfreaks.com/topic/161343-need-to-replace-data/ Share on other sites More sharing options...
Adam Posted June 8, 2009 Share Posted June 8, 2009 Most likely here: $arr[$row['error_text']] = $row['correct_id']; You'll want to replace the data stored within $row['correct_id'] before storing within your array - though I'm totally guessing as you've not supplied much information as to what you're trying to replace. However, as there's no braces {} after the while loop you can only run one statement, which depending how you've done the str_replace()'s may cause a problem. Change it to this to avoid any confusion: while($row = mysql_fetch_array($result)) { $arr[$row['error_text']] = $row['correct_id']; } Quote Link to comment https://forums.phpfreaks.com/topic/161343-need-to-replace-data/#findComment-851415 Share on other sites More sharing options...
iceblox Posted June 8, 2009 Author Share Posted June 8, 2009 Hmm maybe im going about it the wrong way. I have a number of text strings which have double spaces. In the database the string is displayed like this "text 12" but when the browser receives the text it looks like this "text 12" How can i get it so that the extra space is still present? Thanks again Phil Quote Link to comment https://forums.phpfreaks.com/topic/161343-need-to-replace-data/#findComment-851419 Share on other sites More sharing options...
Adam Posted June 8, 2009 Share Posted June 8, 2009 HTML <pre> tags.. Quote Link to comment https://forums.phpfreaks.com/topic/161343-need-to-replace-data/#findComment-851420 Share on other sites More sharing options...
joshgarrod Posted June 8, 2009 Share Posted June 8, 2009 ? Quote Link to comment https://forums.phpfreaks.com/topic/161343-need-to-replace-data/#findComment-851422 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.