Jump to content

php_tom

Members
  • Posts

    264
  • Joined

  • Last visited

    Never

Posts posted by php_tom

  1. Your code is long and a bit hard to read because you didn't use [ code ] tags, but maybe this is the problem:

    echo("<a href=\"$PHP_SELF?page=$pageprev\">PREV ".$limit."[/url]   ");

    I think this should be

    echo("<a href=\"$PHP_SELF?page=$pageprev&rory=".$_GET['rory']."\">PREV ".$limit."[/url]   "); 
    

     

    And similarily for the other parts where you echo the 'next 10' links, etc....

  2. I see...

    I found this somewhere in the vast cavern of knowledge we call the web:

     

    <script>
    function getQueryVariable(variable) {
       var query = window.location.search.substring(1);
       var vars = query.split("&");
       for (var i=0;i<vars.length;i++) {
          var pair = vars[i].split("=");
          if (pair[0] == variable) {
             return pair[1];
          }
       }
       alert('Query Variable ' + variable + ' not found');
    }
    </script>
    

     

    Now make a request to page.html?x=Hello

     

    <script>
    alert( getQueryVariable("x") );
    </script>
    

     

    Note that it only works with GET, not POST.

     

    Hope that helps.

  3. If you have a table for classes with these fields:

     

    Class                  NumCredits            Grade

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

    Biology 532          6                          3.5        (AB)

    Basket-Weaving    3                          2.0        ©

    Philosophy 773      4                          4.0        (A)

     

    You can get the GPA like so:

     

    <?php
    $link = mysql_connect(...);
    mysql_select_db(...);
    $tot_credits = 0;
    $tmp_gpa = 0;
    $res = mysql_query("SELECT * FROM classes");
    while($row = mysql_fetch_assoc($res)) {
       $tmp_gpa += $row['Grade']*$row['NumCredits'];
       $tot_credits += $row['NumCredits'];
    }
    $gpa_final = round(($tmp_gpa/$tot_credits),3);
    ?>
    

     

    Is this sort of what you wanted?

  4. Ya it's easy.

     

    in tmp1.html:

    <html>
    <body>
    <a href='tmp2.html#C4'>Go to chapter 4 in tmp2.html</a>
    </body>
    </html>
    

     

    then in tmp2.html:

    <html>
    <body>
    <p>
    <a href="#C4">See also Chapter 4.</a>
    </p>
    
    <h2>Chapter 1</h2>
    <p>This chapter explains ba bla bla</p>
    
    <h2>Chapter 2</h2>
    <p>This chapter explains ba bla bla</p>
    
    <h2>Chapter 3</h2>
    <p>This chapter explains ba bla bla</p>
    
    <h2><a name="C4">Chapter 4</a></h2>
    <p>This chapter explains ba bla bla</p>
    </body>
    </html>
    

     

    Hope that helps!

  5. You're right, it's JavaScript.

     

    Try this:

    <html>
    <head>
    <script>
    var big=false;
    function toggleSize() {
      if(big) {
        document.getElementById('img1').style.width='100px';
        big = !big;
      } else {
        document.getElementById('img1').style.width='1000px';
        big = !big;
      }
    }
    </script>
    </head>
    
    <body>
    <img src='myImage.jpg' id='img1' onclick='toggleSize()' width='100'/>
    </body>
    </html>
    

     

    Replace 'myImage.jpg' with your image url, and set the widths to whatever you want.

     

    Hope that helps.

  6. This:

    function radioclick0() {

      document.myform1.log_int.disabled = "no";

    }

             

    function radioclick1() {

      document.myform1.log_int.value = "0";

      document.myform1.log_int.disabled = "yes";

    }

    should be

    function radioclick0() {
      document.myform1.log_int.disabled = false;
    }
              
    function radioclick1() {
      document.myform1.log_int.value = "0";
      document.myform1.log_int.disabled = true;
    } 
    

    It worked in FF for me.

  7. Whoa... I just replied to a post and got this:

     

    Warning: mysql_real_escape_string(): Access denied for user 'ndowlat'@'82.197.131.25' (using password: NO) in /home/www/obb.awardspace.com/index.php on line 70

     

    Warning: mysql_real_escape_string(): A link to the server could not be established in /home/www/obb.awardspace.com/index.php on line 70

     

    Warning: mysql_real_escape_string(): Access denied for user 'ndowlat'@'82.197.131.25' (using password: NO) in /home/www/obb.awardspace.com/index.php on line 71

     

    Warning: mysql_real_escape_string(): A link to the server could not be established in /home/www/obb.awardspace.com/index.php on line 71

     

    Warning: mysql_real_escape_string(): Access denied for user 'ndowlat'@'82.197.131.25' (using password: NO) in /home/www/obb.awardspace.com/index.php on line 106

     

    Warning: mysql_real_escape_string(): A link to the server could not be established in /home/www/obb.awardspace.com/index.php on line 106

     

    Warning: mysql_real_escape_string(): Access denied for user 'ndowlat'@'82.197.131.25' (using password: NO) in /home/www/obb.awardspace.com/index.php on line 107

     

    Warning: mysql_real_escape_string(): A link to the server could not be established in /home/www/obb.awardspace.com/index.php on line 107

     

    Warning: mysql_query(): Access denied for user 'ndowlat'@'82.197.131.25' (using password: NO) in /home/www/obb.awardspace.com/index.php on line 111

     

    Warning: mysql_query(): A link to the server could not be established in /home/www/obb.awardspace.com/index.php on line 111

     

    Warning: mysql_query(): Access denied for user 'ndowlat'@'82.197.131.25' (using password: NO) in /home/www/obb.awardspace.com/index.php on line 113

     

    Warning: mysql_query(): A link to the server could not be established in /home/www/obb.awardspace.com/index.php on line 113

     

    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/www/obb.awardspace.com/index.php on line 113

     

    Warning: mysql_query(): Access denied for user 'ndowlat'@'82.197.131.25' (using password: NO) in /home/www/obb.awardspace.com/index.php on line 117

     

    Warning: mysql_query(): A link to the server could not be established in /home/www/obb.awardspace.com/index.php on line 117

     

    Warning: mysql_query(): Access denied for user 'ndowlat'@'82.197.131.25' (using password: NO) in /home/www/obb.awardspace.com/index.php on line 118

     

    Warning: mysql_query(): A link to the server could not be established in /home/www/obb.awardspace.com/index.php on line 118

     

    Warning: mysql_query(): Access denied for user 'ndowlat'@'82.197.131.25' (using password: NO) in /home/www/obb.awardspace.com/index.php on line 120

     

    Warning: mysql_query(): A link to the server could not be established in /home/www/obb.awardspace.com/index.php on line 120

     

    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/www/obb.awardspace.com/index.php on line 121

     

    Warning: mysql_query(): Access denied for user 'ndowlat'@'82.197.131.25' (using password: NO) in /home/www/obb.awardspace.com/index.php on line 123

     

    Warning: mysql_query(): A link to the server could not be established in /home/www/obb.awardspace.com/index.php on line 123

     

    You might want to fix it!

  8. did you print/echo anything out after the function call?

     

    that would break the page... what you need to do is something like this:

     

    "img_resize.php":

    img_resize("myImage.jpg");
    function img_resize($image) {
      $filename = $image;
      header('Content-type: image/jpeg');
      $percent = 0.22;
      list($width, $height) = getimagesize($filename);
      $newwidth = $width * $percent;
      $newheight = $height * $percent;
      $thumb = imagecreatetruecolor($newwidth, $newheight);
      $source = imagecreatefromjpeg($filename);
      imagecopyresampled($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
      imagejpeg($thumb);
    }
    

     

    Then in "myPage.php" something like:

    <img src='img_resize.php" />
    

     

    Hope that helps.

     

  9. $_SESSION['SERVER_NAME']

    AAAACCCKKKKK!!! I just wasn't thinking...

     

    What I meant was:

    $_SERVER['SERVER_NAME'] 

     

    So yeah you can do something like:

    <?php
    $test= $_SERVER['SERVER_NAME'];
    if($test=="myDomain.com") {
      // Link to one SQL server here
    } elseif($test=="localhost") {
      // Link to localhost SQL server
    } else {
      // Link to some other SQL server...
    }
    ?>
    

  10. is their any way to find out "localhost" of mysql to get the actual address?

     

    I don't entirely understand your question but this may help:

     

    $_SESSION['SERVER_NAME'] contains the name of the server the script is running on. So this could be 'localhost' or 'myDomain.com' or whatever.

  11. anything like stuf.php?variable=moreStuf is GET. But you can get either through $_REQUEST.

     

    If they want it in POST, you can instead of using header(), maybe this:

    <html>
    <body onload="document.getElementById('form1').submit();">
    <form action='page.php' method='POST' id='form1'>
    <input type='hidden' name='ticketDate' value='<?php echo $_POST['ticketDate']; ?>' />
    </form>
    </body>
    </html>
    

     

    Of course this only works if the client has JS, otherwise they see a blank page.

    And it's less secure, usually you don't put important stuff in hidden fields.

     

    I guess you could also pass info from page to page with sessions or cookies but then it gets more complicated.

  12. You need the GD lib installed for this to work (look in phpinfo() to see if you do):

     

    function img_resize($image) {
      $filename = $image;
      header('Content-type: image/jpeg');
      $percent = 0.22;
      list($width, $height) = getimagesize($filename);
      $newwidth = $width * $percent;
      $newheight = $height * $percent;
      $thumb = imagecreatetruecolor($newwidth, $newheight);
      $source = imagecreatefromjpeg($filename);
      imagecopyresampled($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
      imagejpeg($thumb);
    }
    

     

    So you use it like so:

    img_resize("/images/large_pics/pic1028489.jpg");
    

     

    Yeah and it only works on JPGs too, though you can fix this by using imagecreatefromgif($filename); and imagecreatefrompng($filename); if you want.

  13. Here's some pseudocode:

     

    $postTimeStamp = 1010101010; // Could get this from a DB
    $now = time();
    $newThreshold = 1 *24*60*60; // 1 day in seconds
    if($now - $postTimeStamp <= $newThreshold)
      echo "<b>".$postContent."</b>";
    else
      echo $postContent;
    

     

    Maybe that helps you?

  14. Yeah, \r is a carriage 'R'eturn (same thing [pretty much] as a 'N'ewline: \n).

    In windows filesystems, a new line is \r\n

    In Mac its \r

    in *nix its \n

    Confusing isnt it? We need some standards here...

     

    The problem with you code could be

    if (mail('mymail@gmail.com', $_POST["subject"], $Body) {

    Return .= "<text>Message successfully sent</text>\r\n";

    } else {

    Return .= "<text>Message delivery failed...</text>\r\n";

    }

     

    what you probably mean is

    if (mail('mymail@gmail.com', $_POST["subject"], $Body) {
    $Return .= "<text>Message successfully sent</text>\r\n";
    } else {
    $Return .= "<text>Message delivery failed...</text>\r\n";
    }
    

     

    Try that, post back if it still doesn't work...

  15. The following is probably too verbose, but will do the job for .wmv:

    <OBJECT id='mediaPlayer' width="320" height="240"
    classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95'
    codebase='http://activex.microsoft.com/activex/controls/ mplayer/en/nsmp2inf.cab#Version=5,1,52,701'
    standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject'>
    <param name='fileName' value="http://mydomain.com/video.wmv">
    <param name='animationatStart' value='1'>
    <param name='transparentatStart' value='1'>
    <param name='autoStart' value='1'>
    <param name='ShowControls' value='0'>
    <param name='ShowDisplay' value='0'>
    <param name='ShowStatusBar' value='0'>
    <param name='loop' value='0'>
    <EMBED type='application/x-mplayer2'
    pluginspage='http://microsoft.com/windows/mediaplayer/ en/download/'
    id='mediaPlayer' name='mediaPlayer' displaysize='4' autosize='0'
    bgcolor='darkblue' showcontrols='0' showtracker='1'
    showdisplay='0' showstatusbar='0' videoborder3d='0' width="320" height="240"
    src="http://mydomain.com/video.wmv" autostart='1' designtimesp='5311' loop='0'>
    </EMBED>
    </OBJECT>
    

     

    Of course that only works if the user has WMP installed. It might play mpegs too.

     

    Or you can convert the movies to flash (FLV) with something like http://vani.bhargav.googlepages.com/movica (MOVICA) to convert your videos to FLV. Then use an FLV player like flowplayer (http://flowplayer.org/) or something.

     

    Videos are fun...

  16. Hey.

     

    I lost you after the third paragraph, you'll have to explain again or put a link to your page.

     

    But for the times and intervals stuff, I'd use timestamps. Like for each shift of each employee or whatever have a DB entry with columns like the employee name or id, the timestamp of when they start work, and the timestamp of when they finish work. You can handle all the specifics of the timestamps with PHP's mktime(), time(), and strftime(). [Look these up in the PHP function reference if you don't know them]

     

    Maybe that helps a bit?

  17. Here's a funny one (although not really a vulnerability):

    http://meisnermusic.awardspace.com/index.php?s=-1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

     

    Request-URI Too Large

    The requested URL's length exceeds the capacity limit for this server.

     

    ;D Now I'm just playing... its not easy to get a 414 error!

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