Member Avatar for begueradj

Hello people,

When I call my function ReadMyTable::readAdmin(); i get an error where it says I have not the right to use self::admin within that function, please, help me to fix this problem !

here is my code :

<?php

class ReadMyTable{
	public static $admin="admin";
	public static $presentation="presentation";
	
	public static function getAdmin(){
		return self::$admin;
	}
	public static function getPresentation(){
		return self::$presentation;		
	}
	
	
	public static function readAdmin(){
   	  $radmin="SELECT * FROM self::$admin";
   	  $qadmin=mysql_query($radmin)or die(mysql_error());
   	  $rowadmin=mysql_fetch_assoc($qadmin);
   	  return $rowadmin;
   }
	
}
?>

Try

$radmin="SELECT * FROM ".self::$admin;
Member Avatar for begueradj

thank you, but it says :

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROMadmin' at line 1

Based on error it seems you haven't provide space after FROM.
There must be a space after FROM for proper query.

Member Avatar for begueradj

it works !!!!
thank you very much vibha !!!!

Member Avatar for begueradj

i mean i added the space you asked after FROM and it works !!!
than you again very much

Welcome :)
Make thread solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.