Current location: Hot Scripts Forums » Programming Languages » PHP » Can someone see the problem here, cause i cant


Can someone see the problem here, cause i cant

Reply
  #1 (permalink)  
Old 08-03-05, 01:13 AM
lppa2004 lppa2004 is offline
Newbie Coder
 
Join Date: Oct 2004
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Can someone see the problem here, cause i cant

Okay in the next little bit of code, All of it works, but when it gets to the point of formatting the sql table name for August it outputs 08 instead of Aug... basically it takes an input of teh numerical month .. 01, 02, 03 etc etc, and then formats it to the abbreviated alpha month, Jan, Feb, Mar and then it creates a MySQL table in the format of Jan_2005... I dont understand why it returns all teh other months correctly except for August.. when i look at it everthing looks correct.. Maybe someone else can see a mistake im missing... FYI this isnt the complete script, i can provide it if need be...



PHP Code:

################################################################################

function points_table($player,$month,$day,$time,$venue,$tpr,$place,$rank,$bonus,$total) {

         
$year date("Y");
         
$table "$year".'_'.'points';
         
connect_to_mysql();

         
$bpoints bonus_point($place,$tpr);
         
$rpoints rank_point($place);
         
$total $rpoints $bpoints;
         
$month_formatted format_month_table($month);
         
$monthly_table "$month_formatted".'_'."$year";

         if(
mysql_query("CREATE TABLE IF NOT EXISTS `$monthly_table` (`id` int(20) NOT NULL auto_increment,`name` varchar(40) NOT NULL default '',`month` varchar(20) NOT NULL default '',`day` varchar(20) NOT NULL default '',`year` int(4) NOT NULL default '0',`time` varchar(5) NOT NULL default '',`venue` varchar(40) NOT NULL default '',`tplayer` int(20) NOT NULL default '0',`place` int(20) NOT NULL default '0',`rank` int(20) NOT NULL default '0',`bonus` int(20) NOT NULL default '0',`total` int(20) NOT NULL default '0',PRIMARY KEY  (`id`)) TYPE=MyISAM AUTO_INCREMENT=6 "))
         {
         
mysql_query("INSERT INTO `$monthly_table` VALUES ('','$player','$month','$day','$year','$time','$venue','$tpr','$place','$rpoints','$bpoints','$total')");
         echo 
"New Monthly Table Added To Database";
          }
         else
         {
         
mysql_query("INSERT INTO `$monthly_table` VALUES ('','$player','$month','$day','$year','$time','$venue','$tpr','$place','$rpoints','$bpoints','$total')");
         
mysql_query("INSERT INTO '$table' VALUES ('','$player','$month','$day','$year','$time','$venue','$tpr','$place','$rpoints','$bpoints','$total')");
         }

         
mysql_close();

         return;

}
################################################################################
function format_month_table($month){


if (
$month == 01) {  $month 'Jan';   }

elseif (
$month == 02) {  $month 'Feb';   }

elseif (
$month == 03) {  $month 'Mar';   }

elseif (
$month == 04) {  $month 'Apr';   }

elseif (
$month == 05) {  $month 'May';   }

elseif (
$month == 06) {  $month 'Jun';   }

elseif (
$month == 07) {  $month 'Jul';   }

elseif (
$month == 08) {  $month 'Aug';   }

elseif (
$month == 09) {  $month 'Sep';   }

elseif (
$month == 10) {  $month 'Oct';   }

elseif (
$month == 11) {  $month 'Nov';   }

elseif (
$month == 12) {  $month 'Dec';   }

return 
$month;

}
################################################################################
function tndata_form(){

print <<<EOF
<form action='$_SERVER[PHP_SELF]' method='post'>
<input type='hidden' name='t' value='tn_points'>
  <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
    <tr>
      <td width="5%" bgcolor="#111111">&nbsp;</td>
      <td width="1%" bgcolor="#111111">&nbsp;</td>
      <td width="53%" bgcolor="#111111">&nbsp;</td>
    </tr>
    <tr>
      <td width="5%">Date</td>
      <td width="1%">&nbsp;</td>
      <td width="53%">Time</td>
    </tr>
    <tr>
      <td width="5%"> <select size="1" name="month">
  <option value="01">Januarary</option>
  <option value="02">Feburary</option>
  <option value="03">March</option>
  <option value="04">April</option>
  <option value="05">May</option>
  <option value="06">June</option>
  <option value="07">July</option>
  <option value="08">August</option>
  <option value="09">September</option>
  <option value="10">October</option>
  <option value="11">November</option>
  <option value="12">December</option>
  </select><select size="1" name="day">
<option value="01">01</option>
                        <option value="02">02</option>
                        <option value="03">03</option>
                        <option value="04">04</option>
                        <option value="05">05</option>
                        <option value="06">06</option>

                        <option value="07">07</option>
                        <option value="08">08</option>
                        <option value="09">09</option>
                        <option value="10">10</option>
                        <option value="11">11</option>
                        <option value="12">12</option>

                        <option value="13">13</option>
                        <option value="14">14</option>
                        <option value="15">15</option>
                        <option value="16">16</option>
                        <option value="17">17</option>
                        <option value="18">18</option>

                        <option value="19">19</option>
                        <option value="20">20</option>
                        <option value="21">21</option>
                        <option value="22">22</option>
                        <option value="23">23</option>
                        <option value="24">24</option>

                        <option value="25">25</option>
                        <option value="26">26</option>
                        <option value="27">27</option>
                        <option value="28">28</option>
                        <option value="29">29</option>
                        <option value="30">30</option>

                        <option value="31">31</option>

  </select><select size="1" name="year">
  <option value="2005">2005</option>
  <option value="2006">2006</option>
  <option value="2007">2007</option>
  <option value="2008">2008</option>
  <option value="2009">2009</option>
  <option value="2010">2010</option>
  </select></td>
      <td width="1%">&nbsp;</td>
      <td width="53%"> <select size="1" name="time">
  <option value="6PM">6:00 PM</option>
  <option value="9PM">9:00 PM</option>
  </select></td>
    </tr>
    <tr>
      <td width="5%">Venue</td>
      <td width="1%">&nbsp;</td>
      <td width="53%">Total Players</td>
    </tr>
    <tr>
      <td width="5%"><select size="1" name="venue">
      <option value="Knickerbocker Saloon" selected>Knickerbocker Saloon
      </option>
      </select></td>
      <td width="1%">&nbsp;</td>
      <td width="53%">
  <input type="text" name="tpr" size="10"></td>
    </tr>
    <tr>
      <td width="5%">&nbsp;</td>
      <td width="1%">&nbsp;</td>
      <td width="53%">&nbsp;</td>
    </tr>
    <tr>
      <td width="59%" colspan="3">Rank&nbsp; Player Name</td>
    </tr>
    <tr>
      <td width="5%"><select size="1" name="place">
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
      <option value="6">6</option>
      <option value="7">7</option>
      <option value="8">8</option>
      <option value="9">9</option>
      <option value="10">10</option>
      <option value="11">11</option>
      <option value="12">12</option>
      <option value="13">13</option>
      <option value="14">14</option>
      <option value="15">15</option>
      <option value="16">16</option>
      <option value="17">17</option>
      <option value="18">18</option>
      <option value="19">19</option>
      <option value="20">20</option>
      </select><input type="text" name="player" size="20"></td>
      <td width="1%">&nbsp;</td>
      <td width="53%">&nbsp;</td>
    </tr>
    <tr>
      <td width="5%">&nbsp;</td>
      <td width="1%">&nbsp;</td>
      <td width="53%">&nbsp;</td>
    </tr>
    <tr>
      <td width="5%">
      <p align="center">
      <input type="submit" value="Submit" style="float: right"></td>
      <td width="1%">&nbsp;</td>
      <td width="53%"><input type="reset" value="Reset"></td>
    </tr>
    <tr>
      <td width="5%">&nbsp;</td>
      <td width="1%">&nbsp;</td>
      <td width="53%">&nbsp;</td>
    </tr>
  </table>
  <p align="center">&nbsp;</p>
</form>
EOF;

        return;
}
################################################################################ 
Also some of this code isnt complete, i still have some work to do on it, but the basic code works that i need, ill clean the rest of it up after i figure out this problem, if not i may just say ta hell with it and have it outpiut the table name all numerically

Last edited by lppa2004; 08-03-05 at 01:15 AM.
Reply With Quote
  #2 (permalink)  
Old 08-03-05, 03:01 AM
FiRe FiRe is offline
Code Guru
 
Join Date: Oct 2004
Location: UK
Posts: 801
Thanks: 0
Thanked 0 Times in 0 Posts
try putting the numbers in quotes e.g.

elseif ($month == "09") { $month = 'Sep'; }

also if you look at http://php.net/date you will see the character M in a date function gives "a short textual representation of a month, three letters"
__________________
Alexa Share <-- Trade virtual shares in websites with this online game.

codR.us <-- Submit and vote for your favorite code snippets with codR.us.

XEWeb.net <-- The ultimate PHP resource network.
Reply With Quote
  #3 (permalink)  
Old 08-03-05, 02:32 PM
lppa2004 lppa2004 is offline
Newbie Coder
 
Join Date: Oct 2004
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
thanks that fixed it, still dont know why all the other months worked except for that one, kinda weird.. o well, it works now, thats all that matters... I thought about quoting them but since teh rest worked i didnt think it would make a difference.. lol
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
sql problem da.bass PHP 2 05-24-05 05:00 AM
Looping problem mcrob PHP 2 04-13-05 10:21 AM
Count problem kasic ASP.NET 1 10-20-04 12:23 AM
Asp and Microsoft Access 2002 problem gop373 ASP 2 10-06-04 09:13 AM
an unusual problem.... fabulosas10 PHP 0 07-16-04 02:03 AM


All times are GMT -5. The time now is 07:00 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.