Jump to content

alberto_zurita

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Posts posted by alberto_zurita

  1. Hey VTS,


    It seems we have the same book. Good advise from Meloni isn't it? :)

    Now, one thing I had to do to get this code running was to change the:


    if (!isset($_GET['topic_id'])) {
    header("Location: topiclist.php");
    exit;
    }



    //for:



    if(!$topic_id){
    header("Location: topic_list.php");
    exit;


    }



    You see, the $_GET[] global array was not working, so I just used straight the $topic_id passed to this file from topiclist.php.


    If you entered already posts to the forum, you should be able to get them from the database.

    If it worked on mine, it should work on yours... ;)


    Well, let me know if you need more help





    Alberto
  2. Thanks Ken,



    I already fixed the weird charcters printing, but still the image doesn't show up. Only the sad square box with the X in the middle.



    Do you have any ideas what the problem might be?



    Thanks.




    Alberto
  3. Hi,

    I am having a problem related to GD and PHP. I am trying to create an image with GD library and PHP, but...

    here is what happens:

    If I run the code on my localhost




    <?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);
    ?>



    Instead of showing a png file it prints wierd characters on the browser:

    ‰PNG  IHDRæ£þÓêPLTE ér¿`ŽLÚIDATxœåбAàŸMhF®!ža’+(„WÙË&ª;‘x?ë”Z…‡Ði'J­D£RÑ+®0wÁ¯`«ÙýòÏfø³Sc

    CYeŸG?Eý˜õà«*T,(´ªšðñ£Peí|&H»;?&¦±éÖ³½54IÇ%¥öÉé¿×‘[¢•!‘i¡)1kg$;ÇP

    E‚˜o™¶²,{»—z÷·†…Âå:`Ž¾´¹Ì”?¨Ž,³fSñƒ8Ÿ¨Æ7È?½íEµ¯E´ª,ÒNçÛ@µ4&‚øg••Gé2ü¶'€£D?ijžIEND®B`‚



    Yes, it prints all this weird characters just as it is above. I know I have installed GD, because I checked it with the info() function:

    <?php


    echo "<xmp> ";

    print_r(gd_info());


    echo "</xmp> ";


    ?>



    This prints:


    Array
    (
    [GD Version] => bundled (2.0.28 compatible)
    [FreeType Support] => 1
    [FreeType Linkage] => with freetype
    [T1Lib Support] =>
    [GIF Read Support] => 1
    [GIF Create Support] => 1
    [JPG Support] => 1
    [PNG Support] => 1
    [WBMP Support] => 1
    [XPM Support] =>
    [XBM Support] => 1
    [JIS-mapped Japanese Font Support] =>
    )




    This shows GD is enabled.


    But, I don't know why it doesn't show the image but a string of weird characters.
    If I run the following code, and image is created in the specified local directory below, but only an orange square is created(png file), but with NO STRING attached to it:



    header("Content-type: image/png");

    $string = "hey dude.......";
    $im = imagecreate(600,900);
    $orange = imagecolorallocate($im, 220, 210, 60);
    imagestring($im,5,3,1,$string,$orange);

    //saves image to "myimage.png"

    imagepng($im,"myimage.png");


    Is there something I am missing? It seems I have all the files in place. I put bgd.dll, and php_gd2.dll in the Systems directory in Windows.
    I also uncommented the line required on php.ini for extensions, so it seems it is loading that module.




    Please help me. All your help is very much appreciated.




    Thanks!!




    Alberto


    ps: I am running PHP version 5.0.4



    gd
    GD Support enabled
    GD Version bundled (2.0.28 compatible)
    FreeType Support enabled
    FreeType Linkage with freetype
    FreeType Version 2.1.9
    GIF Read Support enabled
    GIF Create Support enabled
    JPG Support enabled
    PNG Support enabled
    WBMP Support enabled
    XBM Support enabled
  4. Hi,

    I am having some problems related to GD and PHP. I am trying to create an image with GD library and PHP, but...

    here is what happens:

    If I run the code on my localhost




    <?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);
    ?>



    Instead of showing a png file it prints wierd characters on the browser:

    ‰PNG  IHDRæ£þÓêPLTE ér¿`ŽLÚIDATxœåбAàŸMhF®!ža’+(„WÙË&ª;‘x?ë”Z…‡Ði'J­D£RÑ+®0wÁ¯`«ÙýòÏfø³Sc

    CYeŸG?Eý˜õà«*T,(´ªšðñ£Peí|&H»;?&¦±éÖ³½54IÇ%¥öÉé¿×‘[¢•!‘i¡)1kg$;ÇP

    E‚˜o™¶²,{»—z÷·†…Âå:`Ž¾´¹Ì”?¨Ž,³fSñƒ8Ÿ¨Æ7È?½íEµ¯E´ª,ÒNçÛ@µ4&‚øg••Gé2ü¶'€£D?ijžIEND®B`‚



    Yes, it prints all this weird characters just as it is above. I know I have installed GD, because I checked it with the info() function:

    <?php


    echo "<xmp> ";

    print_r(gd_info());


    echo "</xmp> ";


    ?>



    This prints:


    Array
    (
    [GD Version] => bundled (2.0.28 compatible)
    [FreeType Support] => 1
    [FreeType Linkage] => with freetype
    [T1Lib Support] =>
    [GIF Read Support] => 1
    [GIF Create Support] => 1
    [JPG Support] => 1
    [PNG Support] => 1
    [WBMP Support] => 1
    [XPM Support] =>
    [XBM Support] => 1
    [JIS-mapped Japanese Font Support] =>
    )




    This shows GD is enabled.


    But, I don't know why it doesn't show the image but a string of weird characters.
    If I run the following code, and image is created in the specified local directory below, but only an orange square is created(png file), but with NO STRING attached to it:



    header("Content-type: image/png");

    $string = "hey dude.......";
    $im = imagecreate(600,900);
    $orange = imagecolorallocate($im, 220, 210, 60);
    imagestring($im,5,3,1,$string,$orange);

    //saves image to "myimage.png"

    imagepng($im,"myimage.png");


    Is there something I am missing? It seems I have all the files in place. I put bgd.dll, and php_gd2.dll in the Systems directory in Windows.
    I also uncommented the line required on php.ini for extensions, so it seems it is loading that module.




    Please help me. All your help is very much appreciated.




    Thanks!!




    Alberto


    ps: I am running PHP version 5.0.4



    gd
    GD Support enabled
    GD Version bundled (2.0.28 compatible)
    FreeType Support enabled
    FreeType Linkage with freetype
    FreeType Version 2.1.9
    GIF Read Support enabled
    GIF Create Support enabled
    JPG Support enabled
    PNG Support enabled
    WBMP Support enabled
    XBM Support enabled
  5. I did realized the query didn't worked because I didn't put the reference pointer inside the query function mysql_query($anyvariable). I did get confused about using $query, $sql, $mysql, $link. Khendar said I could only use $query because that is the only database connection resource. But now I realize as you said you can use any variable!

    Thanks to both of you for your help!


    Regards,

    Alberto
  6. [!--quoteo(post=361803:date=Apr 4 2006, 09:11 PM:name=khendar)--][div class=\'quotetop\']QUOTE(khendar @ Apr 4 2006, 09:11 PM) [snapback]361803[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    [code]
    $link = "INSERT INTO companysys2 VALUES(8, 9, 'zuritaproperty')";
    echo mysql_errno($link) . ": " . mysql_error($link). "\n";
    [/code]

    Is that all the code ? That wont do anything because you are not running a mysql_query() and $link is not a database connection resource.

    Where are you executing the query ?

    You need something like:

    [code]

    $query = "INSERT INTO companysys2 VALUES(8, 9, 'zuritaproperty')";

    $result = mysql_query($query);
    if(mysql_error())
        echo mysql_errno() . ": " . mysql_error(). "\n";
    [/code]
    [/quote]


    It works!!

    Thanks Khendar. You are awesome!

    You are right. I didn't put the query inside the query function. That was the whole problem. Somehow, I thought the result query was only necessary to display the records. But since I was only inserting them I thought it was not necessary to do a query for insert. Now, I understand more this. Basically the $query variable gets a pointer from the query expression. Then this pointer is used to access the database, based on Insert and Select.

    However, I tested with the variables $query, $mysql, $link, and they all seem to work.



    My respects to you!
  7. [!--quoteo(post=361464:date=Apr 3 2006, 11:07 PM:name=khendar)--][div class=\'quotetop\']QUOTE(khendar @ Apr 3 2006, 11:07 PM) [snapback]361464[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    In your PHP code - echo the query you are trying to execute before running it. This way you get a print out of exactly what its trying to do. Copy and paste this into myadmin and see if it still works.
    [/quote]


    I added: or die (mysql_error()) at the end of the script. and also tried:

    $link = "INSERT INTO companysys2 VALUES(8, 9, 'zuritaproperty')";
    echo mysql_errno($link) . ": " . mysql_error($link). "\n";


    They don't give any errors, which means the code runs smoothly. However it does not insert the record in the database. I wonder why SELECT extracts the record, but INSERT is not doing its job?

    Any extra tips?


    Thanks!



    Alberto
  8. Thanks for your quick response.

    The query works perfect in mysqlAdmin(it inserts a record). Here goes the query which is very simple. It works, but somehow it won't insert any record on my database.


    mysql_connect( 'localhost', 'Oscar', 'musico' )
    or die ( 'Unable to connect to server.' );

    // Select database on MySQL server

    mysql_select_db( 'musicians' )
    or die ( 'Unable to select database.' );


    $mysql = "SELECT companysys2.company_id, company_name, expiration_date FROM companysys1 LEFT JOIN companysys2 USING(company_id)";


    //now SELECT works fine, it extracts the records from the database correctly, but if I go:


    "INSERT INTO companysys2 VALUES(8, 9, 'zuritaproperty')";

    It does nothing




    //the table companysys2 has 3 fields:

    1)company_id INT(11)
    2)wholesale_id INT(11)
    3)company_name VARCHAR(32)



    Thanks again!


    Alberto




    [!--quoteo(post=361464:date=Apr 3 2006, 11:07 PM:name=khendar)--][div class=\'quotetop\']QUOTE(khendar @ Apr 3 2006, 11:07 PM) [snapback]361464[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    In your PHP code - echo the query you are trying to execute before running it. This way you get a print out of exactly what its trying to do. Copy and paste this into myadmin and see if it still works.
    [/quote]


    By the way Khendar, I did echoed the query, and pasted into mysqlAdmin. It works there (i.e., inserts the record)


    Thanks!
  9. Hi there,

    I can retrieve information from mySQL using PHP and Apache Server using SELECT. But, whenever I try to insert a record on mySQL from PHP(using Dreamweaver) it fails. However, I can retrieve records from the tables on the database, but as I said before it fails to insert them. No, errors or anything.

    I know the mysql query runs and it is correct because it inserts the record just using mysqlAdmin byitself.
    I am new to PHP/MYSQL.

    Please help me.


    Thanks in advance!



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