Jump to content

benji87

Members
  • Posts

    136
  • Joined

  • Last visited

    Never

Posts posted by benji87

  1. Hi all. I recently had to change servers from linux to windows as i was having a load of problems with php and the easiest way to fix it seemed to be changing over. Now ive done this is cant seem to parse php in html files anymore.. ive still used the same .htaccess file but it just doesnt seem to work.

     

    Here is my htaccess code

     

    RemoveHandler .html .htm
    AddType application/x-httpd-php .php .htm .html
    

     

    Can someone help? Thanks

  2. this is my full code

     

    if($act_type == "All") 
      {
         $query=("SELECT * FROM events WHERE area = '$area' ORDER BY date DESC LIMIT 0,10");
      }
    elseif($area == "Portsmouth")
      {
         $query=("SELECT * FROM events WHERE act_type = '$act_type' ORDER BY date DESC LIMIT 0,10");
      }
    elseif($area == "Portsmouth" && $act_type == "All")
      {
         $query=("SELECT * FROM events ORDER BY date DESC LIMIT 0,10");
      }
    else
      {
         $query=("SELECT * FROM events WHERE act_type = '$act_type' AND area = '$area' ORDER BY date DESC LIMIT 0,10");
      }
    $result=mysql_query($query);
    $num=mysql_numrows($result);
    
    
    $i=0;
    while ($i < $num) {
    
    $event=mysql_result($result,$i,"event");
    $date=mysql_result($result,$i,"date");
    $time=mysql_result($result,$i,"time");
    $act_type=mysql_result($result,$i,"act_type");
    $id=mysql_result($result,$i,"id");
    $colour=mysql_result($result,$i,"colour");
    ?>

     

    All the other elseif statements work apart from the one where i want to return all the results.

     

    Thanks

  3. Hi all im trying to setup a search filter in which i have two input fields. But what time trying to do is set up a statement if both the fields are set to all. So basicly display everything in the database.

     

    This is the code i have at the moment but it doesnt return anything

    elseif($area == "Portsmouth" && $act_type == "All")
    {
         $query=("SELECT * FROM events ORDER BY date DESC LIMIT 0,10");
      }

     

    Can anybody help me out please?

     

    Thanks

     

     

  4. Hi all, im trying to install a radius server. This is all new to me so i may be talking rubbish. But i think i need to install a local server environment which includes mysql, php and apache. I have never attempted anything like this before so im quite a newbie.

     

    Can someone point me in the right direction in how to install a local server environment?? Im running windows xp sp2. I think i may need to be running linux? Or is that just one way of doing it?

     

    Any help info would be much appreciated!

  5. This is something ive not long learnt but i know this code works for a fact as im using it right now. So i cant really explain it all, but hey it works!

     

    Once you have registered you're text from the database for example

    $text=mysql_result($result,$i,"text");[code] (You may have done this differently)
    
    Then you need to use php explode to include line breaks. This code also includes a number to limit the amount of characters displayed, which is always useful. Just set it to your own needs as you can see mine is set at 1500 characters: [code]$text = wordwrap($text, 1500, "|", 1);
    list($text) = explode('|', $text);

     

    Then when you come to echo the text this is what you need to put

    <? echo nl2br("$text") ?>

    [/code][/code]

  6. Just a quick and i imagine simple one. How do i embed php into a .html file? Ive used

    addhandler application/x-httpd-php .htm .html

    in my .htaccess file. Which from googling seems to be the way to go with this, although i dont seem to get the right results from it? I can echo a simple string of text but i cant include files, as nothing appears?

     

    Also im wondering if this was working properly would the server print sql errors onto a .html page??

     

    Cheers

  7. Ive changed that but ive always done apostrophes like that before and never had problems with it. Although i will change that in future scripts so cheers for that. I have changed them for this script but im still getting the same error says its not a valid result resource

  8. Hi all im curently working on a script for editing records in a database. Trouble is when i call fields from my database it seems to only select the id and fill that id into text fields where other data should be appearing. I cant understand how or why its doing it. It seems that the query is writing the id of the entry to both my title and text fields which shouldnt be happening i want the title and text data obviously! Could someone take a look and tell me where im going wrong as i designed this script for a previous project and it worked fine, ive only made a few minor changes to this one:

     

    <? session_start();
    include "db.php";
    
      if (isset($_GET['action'])) {
        switch ($_GET['action']) {
    case 'delete':
    
    $query=("DELETE FROM profile_blog WHERE id = '{$_GET['id']}'");
    $result=mysql_query($query); 
    mysql_query("UPDATE staff_profile SET last_login=now() WHERE username='$username'");
    
    header("Location: editblog.php");
    
    break;
    
          case 'edit':
        
    $query1=("SELECT * FROM profile_blog WHERE id = '{$_GET['id']}'");
    $result=mysql_query($query1);
    $title_fld=mysql_result($result,"title");
    $text_fld=mysql_result($result,"text");
    
    };
    };
    ?>
    <link href="../../../css/default.css" rel="stylesheet" type="text/css">
    <body>
    <table width="250" border="0" cellspacing="6" bgcolor="efefef" class="bodytext">
      <tr>
        <td height="149">
    <table width="300" border="0" cellpadding="0" class="bodytext">
      <tr>
        <td width="234">Links:</td>
        <td width="60"><div align="center">Action:</div></td>
      </tr>
    </table>
    
    <?
    $username = $_SESSION['username'];
    
    $query=("SELECT * FROM profile_blog WHERE username = '$username' ORDER BY title ASC");
    $result=mysql_query($query);
    
    $num=mysql_numrows($result);
    
    mysql_close();
    
    $i=0;
    while ($i < $num) {
    
    $title=mysql_result($result,$i,"title");
    $date=mysql_result($result,$i,"date");
    $id=mysql_result($result,$i,"id");
    ?>
    
    <table width="100%" border="0" cellpadding="0" bordercolor="cdcdcd" class="bodytext" style="border-bottom:dotted; border-bottom-color:cdcdcd; border-bottom-width:1px;">
          <tr>
            <td width="6%" bgcolor="#EFEFEF"><? echo "$date" ?></td>
            <td width="73%" bgcolor="#EFEFEF"><? echo "$title" ?></td>
            <td width="10%" bgcolor="#EFEFEF"><div align="center"><? echo "<a href='blogactions.php?id=$id&action=edit'>E</a>" ?></div></td> 
            <td width="11%" bgcolor="#EFEFEF"><div align="center"><? echo "<a href='blogactions.php?id=$id&action=delete'>D</a>" ?></div></td>
    <?
    $i++;
    }
    ?>
    </tr>
    </table>
    <form name="form1" method="post" action="editlinks_frm.php">
      <table width="300" border="0" cellpadding="0" cellspacing="2" class="bodytext">
        <tr>
          <td width="234">Title:</td>
          <td width="60"><input name="title" type="text" class="bodytext" id="title" style="background-color:efefef; border: none; color: 009900; border: solid; border-width: 1px; border-color: cdcdcd;" value="<? echo ("$title_fld") ?>" size="40"></td>
        </tr>
        <tr>
          <td>URL:</td>
          <td><textarea name="text" cols="70" rows="10" class="bodytext" id="text" style="background-color:efefef; border: none; color: 009900; border: solid; border-width: 1px; border-color: cdcdcd;"><? echo ("$text_fld") ?></textarea></td>
        </tr>
        <tr>
          <td> </td>
          <td><input name="Submit" type="submit" class="bodytext" value="Update">
          </td>
        </tr>
      </table>
    </form></td>
    </tr>
    </table>
    </body>
    </html>
    

     

    Cheers

  9. Hi all. I managed to download a good php calendar for my new site. It works great but only problem is when i go to embed it in a page using php include, it displays fine but when you hover over a event date it is supposed to come up with a little box telling you what it is. Instead it just shows nothing but extends the page (as in the scrollbar gets longer) i cant work this out. I know it uses javascript for the little popup and all the links are pointing in the right direction just seems very strange. If someone could take a look that would be great.

     

    here is my calendar script:

     

    <?php include('cp/config.php'); ?>
    <style type="text/css" media="all">@import "style.css";</style>
    <script language="JavaScript" type="text/javascript">
    window.defaultStatus="Calendar Script";
    </script>
    <script type="text/JavaScript">
    function popupEvent(day, month, year, w, h) {
    var winl = (screen.width - w) / 2;
    var wint = (screen.height - h) / 2;
    win = window.open("popup.php?day=" + day + "&month=" + month + "&year=" + year + "","Calendar","scrollbars=yes, status=yes, location=no, toolbar=no, menubar=no, directories=no, resizable=yes, width=" + w + ", height=" + h + ", top=" + wint + ", left=" + winl + "");
    if (parseInt(navigator.appVersion) >= 4) {
    	win.window.focus();
    }
    }
    </script>
    </head>
    <body>
    <script type="text/JavaScript">
      var ol_width=140;
      var ol_delay=10;
      var ol_fgcolor="#FFFFFF";
      var ol_bgcolor="#AAAAAA";
      var ol_offsetx=10;
      var ol_offsety=10;
      var ol_border=1;
      var ol_vauto=1;
    </script>
    <div id="overDiv" style="position: absolute; visibility: hidden; z-index: 1000;"></div>
    <div align="left">
      <script type="text/JavaScript" src="overlib_mini.js"><!-- overLIB (c) Erik Bosrup --></script>
      
      <?php
    // Free Calendar Script
    // Coded and Designed by Bahadir Kocaoglu (bahadir@eggdrop.gen.tr)
    // (C) 2007 Eggdrop Inc.
    // http://www.eggdrop.gen.tr
    // bahadir@eggdrop.gen.tr
    
    if (empty($_GET['month'])) {
    $month = date('m');
    } else {
    $month = $_GET['month'];
    }
    
    if (empty($_GET['year'])) {
    $year = date('Y');
    } else {
    $year = $_GET['year'];
    }
    
    $theday = date('w', mktime(0, 0, 0, $month, 1, $year));
    
    $daysinmonth = date("t", mktime(0, 0, 0, $month, 1, $year));
    ?>
      
      <table border="0" align="left" cellpadding="0" cellspacing="1" class="mainTable">
        <tr>
          <td align="center" colspan="7" class="monthRow">
            <a href="<?php echo $_SERVER['PHP_SELF']; if ($month == '01') { $prevmonth = '12'; $prevyear = $year - 1; echo '?month=' . $prevmonth; echo '&year=' . $prevyear; } else { $prevmonth = $month - 1; echo '?month=' . $prevmonth; echo '&year=' . $year; } ?>">«</a>
            <?php
    			$monthName = date('F', mktime(0, 0, 0, $month, 1, $year));
    			$yearName = date('Y', mktime(0, 0, 0, $month, 1, $year));
    			echo $monthName . ' ' . $yearName;
    		?>
            <a href="<?php echo $_SERVER['PHP_SELF']; if ($month == '12') { $nextmonth = '01'; $nextyear = $year + 1; echo '?month=' . $nextmonth; echo '&year=' . $nextyear; } else { $nextmonth = $month + 1; echo '?month=' . $nextmonth; echo '&year=' . $year; } ?>">»</a>        </td>
        </tr>
        <tr class="dayNamesText">
          <td class="dayNamesRow" width="25" align="center">S</td>
        <td class="dayNamesRow" width="25" align="center">M</td>
        <td class="dayNamesRow" width="25" align="center">T</td>
        <td class="dayNamesRow" width="25" align="center">W</td>
        <td class="dayNamesRow" width="25" align="center">T</td>
        <td class="dayNamesRow" width="25" align="center">F</td>
        <td class="dayNamesRow" width="25" align="center">S</td>
        </tr>
        
        <tr class="rows">
          <?php
    for ($i = 0; $i < $theday; $i++) {
    ?>
          <td> </td>
      <?php
    }
    for ($list_day = 1; $list_day <= $daysinmonth; $list_day++) {
    	$tm = date("U", mktime(0, 0, 0, $month, $list_day, $year)) - 86400; // Bir gün önce
    	$tn = date("U", mktime(0, 0, 0, $month, $list_day, $year)); // O gün ...
    	$tp = date("U", mktime(0, 0, 0, $month, $list_day, $year)) + 86400; // Bir gün sonra
    	$Q = sprintf("SELECT * FROM `events` WHERE `date` > '%s' AND `date` < '%s' AND `day` = '%s';", $tm, $tp, $list_day);
    	$R = mysql_query($Q);
    	$D = mysql_fetch_assoc($R);
    	$S = mysql_num_rows($R);
    	$Y = $D['date'];
    	$TheDay = date('d', $Y);
    	$TheMon = date('F', $Y);
    	$TheYea = date('Y', $Y);
    	mysql_free_result($R);
    	if ($S) {
    	?>
          <td align="center" onclick="popupEvent(<?php echo $D['day']; ?>, <?php echo $D['month']; ?>, <?php echo $D['year']; ?>, 400, 500)" style="background-color: #A200FF; color: #333333; cursor: pointer;" onmouseover="return overlib('<table width="100%" border="0" cellpadding="2" cellspacing="0" class="popupDateTable"><tr><td align="center" class="popupDate"><?php echo $TheDay; ?> <?php echo $TheMon; ?> <?php echo $TheYea; ?></td></tr></table><div class="popupEventTitle s23"><?php echo $S; ?> Record(s)</div>');" onmouseout="return nd();" title="">
            <?php
    	} elseif ($tn > $tm AND $tn < $tp AND date('j') == $list_day AND date('m') == $month AND date('Y') == $year) {
    	?>
            <td align="center" style="background-color: #FFC18A; color: #CF0000; cursor: pointer;" onmouseover="return overlib('<div style="background-color: #FFC18A; color: #CF0000; padding: 4px;">Today</div>');" onmouseout="return nd();">
              <?php
    	} elseif ($theday == 6 or $theday == 0) {
    	?>
              <td align="center" style="background-color: #EEEEEE; color: #666666;">
                <?php
    	} else {
    	?>
                <td align="center" style="background-color: #CCCCCC; color: #333333;">
        <?php
    	}
    
    	echo $list_day;
    
    	echo '</td>';
    
    	if ($theday == 6) {
    		echo '</tr>';
    		echo '<tr class="rows">';
    		$theday = -1;
    	}
    $theday++;
    }
    ?>      </tr>
      </table>
    </div>
    </body>
    </html>
    

     

    You can view the calendar working at: www.alns.co.uk/newsite/calendar/

    Or you can view the embedded version at: www.alns.co.uk/newsite/news.php

     

    cheers

  10. Hi all. Im working style switching for a new website using css and javascript. I have a script for it from spoono but it just doesnt seem to want to work! When i click the links to change the style it brings up a page cannot be displayed error in both firefox and ie.

     

    here is my page code

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    <link rel="stylesheet" type="text/css" href="css/default.css" />
    <link rel="stylesheet" type="text/css" href="css/alternate.css" title="swanky" />
    <link rel="alternate stylesheet" type="text/css" href="css/alternate.css" title="groovy" />
    <script type="text/javascript" src="includes/javascript/styleswitcher.js"></script>
    </head>
    
    <body>
    <p>This text shouls change style when the style changer links are clicked. </p>
    <p><a href=”#” onclick=”setActiveStyleSheet(‘swanky’); return false;”>Change style to default</a>
      <a href=”#” onclick=”setActiveStyleSheet(‘groovy’); return false;”>Change style to alternate</a></p>
    </body>
    </html>
    

     

    My javascript is the styleswitcher.js written by Paul Sowden which is widely used, so i dont believe this is the cause of the problem.

     

    Cheers

  11. Cheers for the help guys darkwinter and sw0o0sh that query worked great but only returned one result. As when there was more than one value that = 2 it came up with an error saying the result could not be saved because the query returned more than one result.

     

    So i guess this is something to do with the PK like Patrick said. So i changed it to the query he gave me but i still only seem to get one result when i should get two.

     

    Here is my query as it stands:

     

    <?php
    $sql ="SELECT * FROM pl_users WHERE username IN (SELECT username FROM pl_gpr WHERE value = '2')";
    $result = mysql_query($sql) or die(mysql_error());
    ?>
    

     

    Cheers

  12. Hi guys i can work out why im getting unexpected T_STRING in this query, can someone help?

     

    <?
    $sql =("SELECT * FROM pl_users WHERE username = (SELECT username FROM pl_grp WHERE value = '2')") or die mysql_error());
    $result = mysql_query($sql);
    ?>
    

     

    cheers

  13. Ok i want it to echo

     

    <td width=100 bgcolor=\"$row_colour\" class='navigation'><div align='centre'>$VARIABLE</div></td>

     

    WHILE

     

    an array of results returned from a database = 1

     

    So for every result returned from the query that = 1 echo the name of that result.

  14. Hey guys, could someone please show me the best way to make this into a loop:

     

    if ($sk > 0) {
    echo "<td width=100 bgcolor=\"$row_colour\" class='navigation'><div align='centre'>Subject Knowledge</div></td>";
    } else {
    echo "";
    }
    if ($afl > 0) {
    echo "<td width=100 bgcolor=\"$row_colour\" class='navigation'><div align='centre'>Assessment for learning</div></td>";
    } else {
    echo "";
    }
    if ($lst > 0) {
    echo "<td width=100 bgcolor=\"$row_colour\" class='navigation'><div align='centre'>Learning style theories</div></td>";
    } else {
    echo "";
    }

     

    Im not sure how to do it as eah result is based on a different variable.

  15. Thanks but cant seem how to get it to work. I obviously need to put the javascript in the page with the form that is being submitted. I then named all the checkboxes 'links' and put in a hidden field called 'chkIds'.

     

    When i submit the form i thought i would try and echo the 'chkIds' post data but nothing is returned?

  16. Hi all im trying to create an update query but im stuck as to how to do it so any help would be great if i try and explain wat im trying to do:

     

    This is what my sqltable looks like:

     

    |  ID  |  SUBJECT  |  VALUE  |  USERNAME  |

        1        SUBJECT1        0              USER

        2        SUBJECT2        0              USER

        3        SUBJECT3        0              USER

     

    ---------------------------------------------------

     

    Now the user fills in a form in which they tick next to the subjects that they would like to learn about which have tick boxes next to them. These tick boxes are named the same as the subjects and have a value of '1'.

     

    When the user submits the form i want the table to update the values the column where the user had ticked the checkboxes with the subject name of the subject column. This could be either one column being updated or up to 20.

     

    I just cant seem to figure out a query for this that would work  :(

  17. No, i want the logged in user to fill out a form then after processing out putting like a report. So say for example:

     

    Here is your report based on the choices you made:

     

    You picked:

     

    Objective led planning  Stuctures and pace  gifted and talented

     

     

    those variables are the columns of the table

  18. Sorry i dont think, i explain myself very well. What i need to do is echo the column names from the table. But i only want to  echo the columns that have the value 1 in an inserted field that also matches the sessions username.

     

    What im trying to do is create a sort of questionnaire where the user fills out three forms with check boxes. The value of each box when ticked is '1' so when the form is processed it inserts 1 into all the columns that match the checked boxes along with the username.....

     

    does that make sense?

×
×
  • 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.