Jump to content

Shadow Hatake

Members
  • Posts

    23
  • Joined

  • Last visited

    Never

Posts posted by Shadow Hatake

  1. Olay, so I'm making a chat box in an iamge and I want the line to stop at a certain point and make a new line. How would I do this?

    Here's my code. It's currently untested due to my hosting being down.

    [code]<?php

    include('dbconnect.php');

    $height = 150;
    $width = 400;
    $background = 'http://www.infected-designs.com/chatbox/chatbox.png';
    $im = imagecreatefrompng($background);
    $white = imagecolorallocate( $im, 255, 255, 255 );
    $x = 32;

    $query = "SELECT * FROM chatbox ORDER BY id ASC";
    $result = mysql_query( $query );

    while( $row = @mysql_fetch_array( $result, MYSQL_ASSOC ) ) {
    imagestring( $im, 2, 7, $x, $row['name'].': '.$row['message'], $white );
    $x = $x + 15;
    }

    header('Content-Type: image/png');
    imagepng($im);
    ?>[/code]
  2. Odd. Would it make a difference if I was using more letters?

    This is the whole code I'm using.
    [code]
    <?php

    $test = "a";

    $letters = array( 'a',
      'b',
      'c',
      'd',
      'e',
      'f',
      'g',
      'h',
      'i',
      'j',
      'k',
      'l',
      'm',
      'n',
      'o',
      'p',
      'q',
      'r',
      's',
      't',
      'u',
      'v',
      'w',
      'x',
      'y',
      'z');
     
    $replace = array( 'b5fc',
      'c8hd',
          'd8re',
          'ej9f',
          'f8jg',
          'g8ph',
          'hd7i',
          'iokj',
          'ji8k',
          'kh0l',
          'lbhm',
          'm87n',
          'nuvo',
          'ohvp',
          'p7yq',
          'qjhr',
          'ribs',
          'soit',
          't9nu',
          'ud6v',
          'v89w',
          'w9sx',
          'x8sy',
          'y9dz',
          'z8ha',
          'a9jb');

    echo str_replace($letters, $replace, $test);

    ?>[/code]

    http://www.infected-designs.com/replace.php
  3. Okay I have a problem. I want to echo the results of a str_replace() but when I put echo infront of it it goes into a huge loop. Here's my code:

    [code]<?php

    $test = "a b";

    $letters = array('a', 'b');
    $replace = array('t455', '5gr4');

    str_replace($letters, $replace, $test);

    ?>[/code]

    So how should I go about doing this?
  4. I recently started a programming job and started on a tutorial to learn from. In the tutorial it talked about how the program I would be making would have a few layers. Well I got the idea for doing that for my site with php. But I'm still not great with php. What i want to do is basically have a code layer where all my php code resides, and then the interface layer where the code is displayed. Does anyone have any links suggestions, or pieces of code I can learn from?
  5. I got bored and decided to code a random ad script. And this si what I've got...

    [code]<?php

    include('dbconnect.php');

    $query_link = 'SELECT link FROM ads';
    $result_link = mysql_query( $query_link );
    $row_link = @mysql_fetch_array( $result_link, MYSQL_ASSOC );

    shuffle( $row_link );

    echo '<a href="'.$row_link.'">';

    $query_img = 'SELECT img FROM ads WHERE link = "'.$row_link.'"';
    $result_img = mysql_query( $query_img );
    $row_img = @mysql_fetch_array( $result_img, MYSQL_ASSOC );

    echo'<img src="'.$row_img.'"></a>';

    ?>[/code]

    Now when I go to test it it doesn't work. Help?
  6. [code] <?php

    include('dbconnect.php');

    $id = $_GET['jid'];
    $question = $_GET['q'];

    if( isset( $_GET['jid'] ) ) {
         if( isset( $_GET['q'] ) ) {
             $query = 'SELECT '.$question.' FROM boards WHERE id = "'.$id.'"';
            $result = mysql_query( $query );
                        
            if( $result ) {
                echo $result;
            } else {
                echo 'Error';
            }
        } else {
            echo 'Page accessed incorrectly...';
        }
    } else {
        echo 'Page accessed incorrectly...';
    }

    ?>[/code]

    All I'm getting is resource id #3 when it should be showing the query. Help?
  7. [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''boardname' , 'retrievalname' , 'cat1_name' , 'cat1_q1' , 'cat1_a1' , 'cat1_q2' ' at line 1[/quote]
  8. Okay, so for a spanish extra credit project our spanish teacher asked us to create a jeaprody game. Well I decided to make mine web based and allow it to store multiple games and reuse them. Now here's my problem. I've got a query but it doesn't work. Can anyone tell what wrong with it?

    Due tot he size of the query I'm posting the code on another page:
    [a href=\"http://www.infected-designs.com/jeoprody/query.htm\" target=\"_blank\"]http://www.infected-designs.com/jeoprody/query.htm[/a]
  9. [!--quoteo(post=351746:date=Mar 4 2006, 08:59 PM:name=php_b34st)--][div class=\'quotetop\']QUOTE(php_b34st @ Mar 4 2006, 08:59 PM) [snapback]351746[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    I recently bought PHP and MySQL Web Development by Luke Welling and Laura Thomson, it has good working examples and has been very usefull for me but that doesnt mean it will work for you. I suggest you go to your local bookstore and browse through a few before you buy one because they are not cheap.
    [/quote]
    Yeah, I'd suggest that one as well. It's extremely useful for it's secure coding section as well.
  10. Okay so I made this news system and it worked fine for a while, but now it's acting up and adding a blank entry to the databse when I post a piece of news.

    Code from confirm.php:
    [code]    } elseif( $_GET['p'] == 'news' ) {
            $stat_chk_query = 'SELECT status FROM users WHERE name = "'.$_SESSION['valid_user'].'"';
            $result = mysql_query( $stat_chk_query );
            $row = @mysql_fetch_array( $result, MYSQL_ASSOC );
            
            if( $row['status'] == 2 ) {
                $news_add_query = 'INSERT INTO news( title, news, date, user )';
                $news_add_query .= 'VALUES( "'.$news_title.'", "'.$news_content.'", NOW(), "'.$_SESSION['valid_user'].'" )';
                $result = mysql_query( $news_add_query );
                
                if( $result ) {
                    content_box( $news_pos_title, $news_pos_content );
                } else {
                    content_box( $news_neg_title, $news_neg_content);
                }
            } else {
                content_box( $news_err_title, $news_err_msg);
            }[/code]
  11. well i tested it by replacing the 10's with 3's and it won't show the next/prev page at bottom, and it seems to be adding them above the last news box.

    EDIT: Well after palying with a little, it shows the next/prev page thing. but now how do I get it to show after last piece of news? :/

    ANOTHER EDIT: I created 2 footer functions. And that fixed the placement problem. Thanks for the code. ^^;
  12. Okay so my news script is set to view only 10 pieces of news. But I want it so that it starts a new page once I have more than 10 pieces of news.

    [code]<?php
    require("functions.php");
    include("dbconnect.php");

    session_start();

    head1();
    body1();
    new_temp();
    sotw();
    navbar();
        
    $start = 0;
    $display = 10;
    $query = "SELECT * FROM news ORDER BY id DESC LIMIT $start, $display";
    $result = mysql_query( $query );

    if ($result) {
        while( $row = @mysql_fetch_array( $result, MYSQL_ASSOC ) ) {
            news_box( $row['news'], $row['title'], $row['user'], $row['date'], $row['id'] );
        }
        mysql_free_result($result);
    } else {
        news_box( 'Could not retrieve news entries!', 'Error', 'Error', 'Error');
    }
                      
    footer();

    mysql_close($link);
    ?>[/code]

    I tried a few things but they failed....miserably.
×
×
  • 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.