dsaba Posted April 26, 2007 Share Posted April 26, 2007 I'm doing this: <?php $var = $row['title_en']; ?> that works perfectly and fetches from the fieldname named: title_en now I do this: <?php $lang = 'en'; $var = $row['title_'.$lang]; ?> it doesnt work so i try this: <?php $var = $row["title_$lang"]; ?> still doesn't work my goal is to call the fieldname: title_en using the variable $lang which equals: en p.s. I have also echoed out $lang, and it does indeed equal: en how do I do it? -going crazy over something so simple, thanks Link to comment https://forums.phpfreaks.com/topic/48830-solved-mysql_fetch_array-index-not-working/ Share on other sites More sharing options...
bobleny Posted April 26, 2007 Share Posted April 26, 2007 Try: $lang = 'en'; $row = 'title'; $row = $row.$lang $var = $row[$row]; Or try: $lang = 'en'; $var = $row[title.$lang]; I haven't tried it so it might not work... Link to comment https://forums.phpfreaks.com/topic/48830-solved-mysql_fetch_array-index-not-working/#findComment-239314 Share on other sites More sharing options...
dsaba Posted April 26, 2007 Author Share Posted April 26, 2007 I tried both of those still doesn't work!!! What am I doing wrong!!! Holy crap this is frustrating.... Link to comment https://forums.phpfreaks.com/topic/48830-solved-mysql_fetch_array-index-not-working/#findComment-239316 Share on other sites More sharing options...
MadTechie Posted April 26, 2007 Share Posted April 26, 2007 <?php $row['title_en'] = "TEST"; $lang = 'en'; $var = $row['title_'.$lang]; echo $var;//workds fine!! ?> Link to comment https://forums.phpfreaks.com/topic/48830-solved-mysql_fetch_array-index-not-working/#findComment-239319 Share on other sites More sharing options...
dsaba Posted April 26, 2007 Author Share Posted April 26, 2007 aha! i figured it out I was making the $lang variable in a function and I forgot to global $lang; fixed I was echoing the variable in the function, thinking that it echoed, no wonder... -thanks for your help Link to comment https://forums.phpfreaks.com/topic/48830-solved-mysql_fetch_array-index-not-working/#findComment-239320 Share on other sites More sharing options...
MadTechie Posted April 26, 2007 Share Posted April 26, 2007 heehee Link to comment https://forums.phpfreaks.com/topic/48830-solved-mysql_fetch_array-index-not-working/#findComment-239321 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.