Jump to content

Insert a variable into script?


SixPack

Recommended Posts

I'm trying to insert a $varable into code to retrieve data from mysql.

 

   
   include("./local/geoip/geoip.inc");   
          include("./local/geoip/geoipcity.inc");   
           include("./local/geoip/geoipregionvars.php");   
          $gi = geoip_open("./local/geoip/GeoLiteCity.dat", GEOIP_STANDARD);   
          $rsGeoData = geoip_record_by_addr($gi, $_SERVER  ['REMOTE_ADDR']);   
          geoip_close($gi);   
          $location = $rsGeoData->region;  

 

$location being the variable. I can echo $location onto the html page using this. Works ,no problem.

 

    
<h3 class="members">Members near  <? echo $location;?></h3> 

 

 

But I'm unable to make a database query with this. It returns blank. If I manually edit the file, remove <?=$location;?> and substitue it with a state value, it works.

 

  
<div class="block members">
{members:limit=10,profile_state=<?=$location;?>,cache_time=0}  
</div>

 

It would also help if I knew exactly what type of code/script this is. It's making a database call.

 

   
{members:limit=10,profile_state= ******, cache_time=0}

 

The <div class="block members"> is after the "echo" so I know the $location is getting there, just appears to be a problem with the way it's interpeted. And/or the {} brackets around the code. I have short_open_tags enabled and have tried every conceivable way I know of to get this to work. <?php=$location;?>  I have searched google for 2 weeks.

If I knew what type of scripting thats being used to call mysql I'd have a better chance of finding the answer on google.

Any help here will most certainly be appreciated.

 

Link to comment
https://forums.phpfreaks.com/topic/190955-insert-a-variable-into-script/
Share on other sites

It's returning a state. It echo's on the page like it suppose to. If I remove <?=$location?>

and insert a state name everything works as it should.  It leaves no spaces or extra strings

when echoed.  I have to believe it has to do with the curly brackets it's in. {} 

  No idea what type of script that is? Ajax maybe?  If I knew that much it would make my search alot more simple. "Insert a variable into" returns alot of results. I've ruled out javascript . Page source shows nothing.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.