Unstoppable Domains โ€” Expired Auctions

Little Php error

SpaceshipSpaceship
Watch

edmarriner

Established Member
Impact
4
hi,
i made a code (to do with a template system) but im having trouble.

i get the infomation from the database and try to put the data into two functions which have in them a switch.
the file is included from a diffrent file when it needs to know things such as the sites name etc...

but i can get it working :'(

heres the code, whats wrong?

PHP:
<?php

mysql_connect("localhost", "root", "*password*") or die(mysql_error());
mysql_select_db("topsite") or die(mysql_eror());


$result = mysql_query("SELECT * FROM tags");

$mysql_tag = mysql_fetch_array($result);
   

mysql_free_result($result);

//Site() template tags
function site($tag){
switch ($tag) {
case "name":
   echo $mysql_tag["site_name"]; 
   break;
case "url":
   echo $mysql_tag["site_url"]; 
   break;
case "slogan":
   echo $mysql_tag["site_slogan"]; 
   break;
case "subject":   
   echo $mysql_tag["site_subject"]; 
   break;
case "email": 	
   echo $mysql_tag["site_email"]; 
   break;   
}
}


//Meta() template tags
function meta($tag){
switch ($tag) {
case "keywords":
   echo $mysql_tag["meta_keywords"]; 
   break;
case "description":
   echo $mysql_tag["short_description"]; 
   break;
case "title":
   echo $mysql_tag["short_short_description"]; 
   break;
}
}

?>
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable Domains โ€” AI StorefrontUnstoppable Domains โ€” AI Storefront
where is the code where you are trying to use the functions?

Also when you say it does not work what is happening?
 
0
•••
function site($tag){
global $mysql_tag;
switch ($tag) {
...

otherwise the function doesn't know what's $mysql_tag
 
0
•••
filth said:
where is the code where you are trying to use the functions?

Also when you say it does not work what is happening?
ok, on the page im doing this:

this is at the top of the page.
PHP:
include"./includes/config.php"; ?>

then to use the tags im doing this.
PHP:
<?php site(name) ?>

The answer two your 2nd question is that nothing happends. where the text is ment to be it leaves a blank space.

Le Wolf said:
function site($tag){
global $mysql_tag;
switch ($tag) {
...

otherwise the function doesn't know what's $mysql_tag
i did it but still does not work :(


anymore ideas?

------------------------------------------
solved
------------------------------------------

thanks to all who helped :D
 
0
•••
Dynadot โ€” .com TransferDynadot โ€” .com Transfer
CatchedCatched
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back