Go Back   RunUO - Ultima Online Emulation > Developer's Corner > Programming > Script Languages

Script Languages Perl/PHP/Python/Ruby so on and so forth.

Reply
 
Thread Tools Display Modes
Old 01-20-2007, 01:54 PM   #1 (permalink)
Forum Novice
 
FingersMcSteal's Avatar
 
Join Date: Mar 2006
Location: North East, England, UK
Posts: 865
Send a message via ICQ to FingersMcSteal Send a message via MSN to FingersMcSteal
Default PHP Web Page Variables ???

I'm new to PHP so bare with me

Is there a particular order to creating a web page where you should define your variables, i know some languages get picky with case, does PHP do the same but in an order of whats where in the file ?

Is it along the lines of the same thing like C# classes or something, like (example)...

Code:
{
     Variable def's here
          {
               Code
          }
}
So the variables cant be seen outside say a table region ???, like...

PHP Code:
<td>
     
vars defined here
</td
so the PHP code can't see it here ??? out side the class, as it were ?

Anyone ?
FingersMcSteal is offline   Reply With Quote
Old 01-20-2007, 02:28 PM   #2 (permalink)
Account Terminated
 
Join Date: Jun 2004
Location: Cincinnati, Ohio
Age: 20
Posts: 3,954
Default

I'd say that your best place to find answers would be to look through the first few chapters of the PHP online manual. PHP: PHP Manual - Manual

Specifically, this is the chapter on variables. PHP: Variables - Manual

You can place PHP code at any place of your file, as long as it is between a beginning '<?php' and an ending '?>'. This includes inside of HTML.

Code:
<td>
<?php
Your code can go here!
?>
</td>
WarAngel is offline   Reply With Quote
Old 01-20-2007, 02:31 PM   #3 (permalink)
Forum Novice
 
FingersMcSteal's Avatar
 
Join Date: Mar 2006
Location: North East, England, UK
Posts: 865
Send a message via ICQ to FingersMcSteal Send a message via MSN to FingersMcSteal
Default

Quote:
Originally Posted by WarAngel View Post
I'd say that your best place to find answers would be to look through the first few chapters of the PHP online manual. PHP: PHP Manual - Manual

Specifically, this is the chapter on variables. PHP: Variables - Manual

You can place PHP code at any place of your file, as long as it is between a beginning '<?php' and an ending '?>'. This includes inside of HTML.

Code:
<td>
<?php
Your code can go here!
?>
</td>
So anything SQL or PHP related outside of this <td> area will not work if trying to reference the PHP code ?

Yeah, i have a few PHP manuals downloaded, hate reading those
FingersMcSteal is offline   Reply With Quote
Old 01-20-2007, 02:32 PM   #4 (permalink)
Account Terminated
 
Join Date: Jun 2004
Location: Cincinnati, Ohio
Age: 20
Posts: 3,954
Default

Correct. If it's not contained in the php definition area (made up term; can't remember what it's actually called), it will simply be read as plain text or HTML.
WarAngel is offline   Reply With Quote
Old 01-20-2007, 02:35 PM   #5 (permalink)
Forum Novice
 
FingersMcSteal's Avatar
 
Join Date: Mar 2006
Location: North East, England, UK
Posts: 865
Send a message via ICQ to FingersMcSteal Send a message via MSN to FingersMcSteal
Default

* the lights are on and theres no one home *

Thanks, that clears up the messyness problems i was having

So in some respects, you have to have the PHP you want to access in a 'class' something like when your make a c# object (private, public as a nasty example), the PHP is like considered private to the <php & ?> area.

Np's i get the gist of it now.
FingersMcSteal is offline   Reply With Quote
Old 01-20-2007, 02:47 PM   #6 (permalink)
Account Terminated
 
Join Date: Jun 2004
Location: Cincinnati, Ohio
Age: 20
Posts: 3,954
Default

It really depends on your coding style. You could simply have the entire file be inside the php definition area and produce the HTML using PHP. It doesn't really have anything to do with public or private, but for organization and aesthetics. It is also very difficult to compare C# to PHP because, unless you are specifically using PHP's object-oriented features, they are really not the same idea. One is procedural and one is object-oriented.

Last edited by WarAngel; 01-20-2007 at 02:57 PM.
WarAngel is offline   Reply With Quote
Old 01-20-2007, 02:59 PM   #7 (permalink)
Forum Novice
 
FingersMcSteal's Avatar
 
Join Date: Mar 2006
Location: North East, England, UK
Posts: 865
Send a message via ICQ to FingersMcSteal Send a message via MSN to FingersMcSteal
Default

Quote:
Originally Posted by WarAngel View Post
It really depends on your coding style. You could simply have the entire file be inside the php definition area, and simply produce the HTML using PHP. It doesn't really have anything to do with public or private, but for organization and aesthetics.
Yup, hear what your saying... my organization and aesthetics sux right now

Have a look...

Shard Millionaires

If you have myrunuo working, i've updates some old scripts i found for PHP relating to it, i'll attach them.

This is the new table layout which will work with the MyRunUO part if you replace the script file...

Code:
-- MySQL dump 9.10
--
-- Host: localhost    Database: MyRunUO
-- ------------------------------------------------------
-- Server version	4.0.20a-nt

--
-- Table structure for table `myrunuo_characters`
--

CREATE TABLE myrunuo_characters (
  char_id int(12) unsigned default NULL,
  char_name varchar(150) default NULL,
  char_str int(3) unsigned default NULL,
  char_dex int(3) unsigned default NULL,
  char_int int(3) unsigned default NULL,
  char_female int(2) unsigned default NULL,
  char_counts int(3) unsigned default NULL,
  char_guild varchar(4) default NULL,
  char_guildtitle varchar(150) default NULL,
  char_nototitle varchar(150) default NULL,
  char_bodyhue int(3) unsigned default NULL,
  char_public int(1) unsigned default NULL,
char_bankaccount int(12) unsigned default NULL,
KEY char_id (char_id),
  KEY char_guild (char_guild)
) TYPE=MyISAM;

--
-- Table structure for table `myrunuo_characters_layers`
--

CREATE TABLE myrunuo_characters_layers (
  char_id int(12) unsigned default NULL,
  layer_id int(3) unsigned default NULL,
  item_id int(12) unsigned default NULL,
  item_hue int(3) unsigned default NULL,
  KEY charid (char_id)
) TYPE=MyISAM;

--
-- Table structure for table `myrunuo_characters_skills`
--

CREATE TABLE myrunuo_characters_skills (
  char_id int(12) unsigned default NULL,
  skill_id int(3) unsigned default NULL,
  skill_value int(3) unsigned default NULL,
  KEY charid (char_id),
  KEY skillid (skill_id)
) TYPE=MyISAM;

--
-- Table structure for table `myrunuo_guilds`
--

CREATE TABLE myrunuo_guilds (
  guild_id varchar(4) default NULL,
  guild_name varchar(150) default NULL,
  guild_abbreviation varchar(4) default NULL,
  guild_website varchar(150) default NULL,
  guild_charter varchar(250) default NULL,
  guild_type varchar(8) default NULL,
  guild_wars int(3) unsigned default NULL,
  guild_members int(3) unsigned default NULL,
  guild_master int(12) unsigned default NULL,
  KEY guild_id (guild_id)
) TYPE=MyISAM;

--
-- Table structure for table `myrunuo_guilds_wars`
--

CREATE TABLE myrunuo_guilds_wars (
  guild_1 varchar(4) default NULL,
  guild_2 varchar(4) default NULL,
  KEY guild1 (guild_1),
  KEY guild2 (guild_2)
) TYPE=MyISAM;

--
-- Table structure for table `myrunuo_status`
--

CREATE TABLE myrunuo_status (
  char_id int(12) unsigned default NULL,
  char_location varchar(14) default NULL,
  char_map varchar(8) default NULL,
  char_karma int(6) default NULL,
  char_fame int(6) default NULL,
  KEY charid (char_id)
) TYPE=MyISAM;

--
-- Table structure for table `myrunuo_timestamps`
--

CREATE TABLE myrunuo_timestamps (
  time_datetime varchar(22) default NULL,
  time_type varchar(6) default NULL
) TYPE=MyISAM;
The red lines the addition to the tables, and this part in the script was added...

Code:
public void InsertMobile( Mobile mob )
		{
			string guildTitle = mob.GuildTitle;

			if ( guildTitle == null || (guildTitle = guildTitle.Trim()).Length == 0 )
				guildTitle = "NULL";
			else
				guildTitle = SafeString( guildTitle );

			string notoTitle = SafeString( Titles.ComputeTitle( null, mob ) );
			string female = ( mob.Female ? "1" : "0" );
			
			bool pubBool = ( mob is PlayerMobile ) && ( ((PlayerMobile)mob).PublicMyRunUO );

			string pubString = ( pubBool ? "1" : "0" );

			string guildId = ( mob.Guild == null ? "NULL" : mob.Guild.Id.ToString() );

            // ***********************
            string bankaccount = (Banker.GetBalance(mob).ToString());
            // ***********************

			if ( Config.LoadDataInFile )
			{
				m_OpMobiles.Write( LineStart );
				m_OpMobiles.Write( mob.Serial.Value );
				m_OpMobiles.Write( EntrySep );
				m_OpMobiles.Write( SafeString( mob.Name ) );
				m_OpMobiles.Write( EntrySep );
				m_OpMobiles.Write( mob.RawStr );
				m_OpMobiles.Write( EntrySep );
				m_OpMobiles.Write( mob.RawDex );
				m_OpMobiles.Write( EntrySep );
				m_OpMobiles.Write( mob.RawInt );
				m_OpMobiles.Write( EntrySep );
				m_OpMobiles.Write( female );
				m_OpMobiles.Write( EntrySep );
				m_OpMobiles.Write( mob.Kills );
				m_OpMobiles.Write( EntrySep );
				m_OpMobiles.Write( guildId );
				m_OpMobiles.Write( EntrySep );
				m_OpMobiles.Write( guildTitle );
				m_OpMobiles.Write( EntrySep );
				m_OpMobiles.Write( notoTitle );
				m_OpMobiles.Write( EntrySep );
				m_OpMobiles.Write( mob.Hue );
				m_OpMobiles.Write( EntrySep );
				m_OpMobiles.Write( pubString );

                // ******************************
                m_OpMobiles.Write(EntrySep);
                m_OpMobiles.Write(bankaccount);
                // ******************************

				m_OpMobiles.Write( LineEnd );
			}
			else
			{
                // ***** Changes in this line too ****
                ExecuteNonQuery("INSERT INTO myrunuo_characters (char_id, char_name, char_str, char_dex, char_int, char_female, char_counts, char_guild, char_guildtitle, char_nototitle, char_bodyhue, char_public, char_bankaccount ) VALUES ({0}, '{1}', {2}, {3}, {4}, {5}, {6}, {7}, {8}, '{9}', {10}, {11}, {12})", mob.Serial.Value.ToString(), SafeString(mob.Name), mob.RawStr.ToString(), mob.RawDex.ToString(), mob.RawInt.ToString(), female, mob.Kills.ToString(), guildId, guildTitle, notoTitle, mob.Hue.ToString(), pubString, Banker.GetBalance(mob).ToString());
			}
		}
This is for RunUO 1.0
Attached Files
File Type: cs MyRunUO.cs (17.9 KB, 13 views)
FingersMcSteal is offline   Reply With Quote
Old 01-20-2007, 03:07 PM   #8 (permalink)
Account Terminated
 
Join Date: Jun 2004
Location: Cincinnati, Ohio
Age: 20
Posts: 3,954
Default

Web design takes a lot of time and practice. No one simply goes to sleep and wakes up the next morning as a world-class designer. Keep working on PHP and read some guides on color and you'll be set. I read Slash7 with Amy Hoy - Home, which has a few articles on color. The current new post and this one (Slash7 with Amy Hoy - Drop That Design! 6 Things You Need to Know About Color) are especially awesome.
WarAngel is offline   Reply With Quote
Old 01-20-2007, 03:14 PM   #9 (permalink)
Forum Novice
 
FingersMcSteal's Avatar
 
Join Date: Mar 2006
Location: North East, England, UK
Posts: 865
Send a message via ICQ to FingersMcSteal Send a message via MSN to FingersMcSteal
Default

Yeah i know, this is something i've just started to play around with over the last week now that i'm re-doing the web site.

Heres the PHP by the way, forgot to add it to that last post, might be useful for someone maybe.

2 files needed.
Attached Files
File Type: zip 2 PHP files.zip (2.5 KB, 34 views)
FingersMcSteal is offline   Reply With Quote
Old 01-20-2007, 06:34 PM   #10 (permalink)
Forum Expert
 
mordero's Avatar
 
Join Date: Nov 2003
Location: Illinois, USA
Age: 22
Posts: 2,911
Default

php4 lacks quite a bit in OOP, however php5 is much much better. Now anything in a php document is global UNLESS it is declared in a function. So it doesnt matter if you use multiple <?php //code ?> within your html or use just one <?php //code ?> that spits out the html.
mordero is offline   Reply With Quote
Old 01-20-2007, 07:20 PM   #11 (permalink)
Forum Novice
 
FingersMcSteal's Avatar
 
Join Date: Mar 2006
Location: North East, England, UK
Posts: 865
Send a message via ICQ to FingersMcSteal Send a message via MSN to FingersMcSteal
Default

Aye, thanks. Got it working finally, it was the <td> & <tr> parts that was causing me a problem from the editor, thats why i needed something better i think. Plus the code needed to be cleaned up a bit too.

Anyway, it's here for your paroosing pleasure...

Shard Millionaires

My first attempt
FingersMcSteal is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5