Jump to content

Get values from database and assign them to variables


asmina22

Recommended Posts

hello

i have a mysql database that contains one table called configuration

it contains some values, for example Adsense, that i wanna get from the database

and make a new variable $adsense that will take the value of Adsense from the databse,

then i will use $adsense on my site.

i tried this but didnt work :

 

<?php
$cnx=mysql_connect($server, $username , $password);
mysql_select_db($base) 
    or die("Database not found.");


$sqlRequete = "select * from configuration";
$qryRequete = mysql_query($sqlRequete,$cnx);
$foRequete = mysql_fetch_object($qryRequete);
while($qryRequete)
{
print($foRequete->Adsense);
$adsense=($foRequete->Adsense);
$foRequete = mysql_fetch_object($qryRequete);
} 

mysql_close();
?>



<script type="text/javascript"><!--
google_ad_client = "$adsense";
google_ad_width = 250;
google_ad_height = 250;
google_ad_format = "250x250_as";
google_ad_type = "text_image";
google_ad_channel = "";
google_color_border = "20395B";
google_color_bg = "FFFFFF";
google_color_link = "20395B";
google_color_text = "FFFFFF";
google_color_url = "FFFFFF";
google_ui_features = "rc:10";
//-->
</script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

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.