Jump to content

chawezul

Members
  • Posts

    19
  • Joined

  • Last visited

    Never

Posts posted by chawezul

  1.     <?php 
            //header ("Content-type: image/png"); 
            $img_handle = ImageCreate (230, 20) or die ("Cannot Create image"); 
            $back_color = ImageColorAllocate ($img_handle, 0, 10, 10); 
            $txt_color = ImageColorAllocate ($img_handle, 233, 114, 191); 
            ImageString ($img_handle, 31, 5, 5,  "My first Program with GD", $txt_color); 
            //ImagePng ($img_handle); 
        ?> 

     

    Run this and see if there is any output in the page source. You may have a built-in function that runs before everything else in PHP.

  2. If a variable number or records may be added into the database (ie, 3 or 4 or 2 or 1 are all acceptable), I would recommend imploding all of the records together into one string and keeping them in one database field, then exploding them back into seperate records when you take them out of the database.

     

    That's how my blogs handle tags, it works very well with variable amounts of input.

  3. Ah :)

     

    Check your Javascript console to make sure you're not sending:

     

    passvar(1, 3, name ,this);

     

    Because in that name is a constant!  Try:

     

    <?php
    echo "<tr id=\"action\" title=\"Click to display sites below\" onclick=\"passvar(${pageNum}, ${id}, '${name}', this );\">";
    ?>

     

    :) thanks!

     

    <ins>By the way, in that case the error you would get is: Variable 'name' is undefined in ... on line ...</ins>

  4. You need to tell PHP which session values to take as well as to set, so You'd go

     

    session_start();
    session_register("idstud");

     

    session_register() will "tell" the computer that you are going to allow reading and writing of a session value of whatever you input. Otherwise it doesn't know that. After that you can set and access it from the public field

     

    $_SESSION["idstud"];

     

    Hope that helps

  5. You can also use parse_str() on $_SERVER["QUERY_STRING"] for a register globals effect, getting the query string is generally easy if you're only passing one value to the script, but if you're using it with parse_str it's frowned upon and begs for injection.

  6. When I create a new php file in dreamweaver and open it, I get

    [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>
    </head>

    <body>
    </body>
    </html>
    [/code]

    Wheras I'd like to get something like:

    [code]<?php
    // author:
    // date:

    class * {
      function __construct() {
       
      }
    }


    ?>[/code]

    Does anyone know how to do this?
  7. It's kind of hard to understand what you're asking, plus you didn't show us how this query is applied to your code so it's harder to understand what you're trying to do with the result. But if you want to grab more columns (and assuming you don't have a million) you can simply use

    [code]SELECT * FROM `table` WHERE condition[/code]

    And that will grab all of the columns. Sorry if I didn't answer your question.
  8. Ok, here's my problem, I want my function to return an array of numbers that are the prime factors of the input number. My code works. It's all good. Everything is great. Except, the array that is returned is only ONE item long, and it is the last item in the array. So my assumption is that everytime it calls to add to the array, it simply empties the array (or recreates it) and then adds the item. If you can help me that'd be great!

    Code:

    [code]$result = Array();

    function prime($n, $y) {
        if ($y == 1) return true;
        elseif (($n % $y) == 0) return false;
        else return prime($n, $y-1);
    }

    function findprimes($n, $p) {
        if (! (prime($p, $p-1))) return findprimes($n, $p+1);
        elseif ($n == $p) { $result[] = $n; return $result; }
        elseif (($n % $p) == 0) { $result[] = $p; return findprimes($n/$p, $p); }
        else return findprimes($n, $p+1);
    }

    function primefactors($n) {
        return findprimes($n, 2);
    }[/code]
×
×
  • 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.