Help please

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Shaun Demellweek

    Help please

    Two things I am not sure about, and would appreciate an answer to.

    1) This may be simple. When creating a form to insert data into a table, I
    seem to loose all the returns when data is inputted. I use the following
    script:

    page1.php:
    <form action="page2.p hp">
    <textarea name="textbox"> </textarea>
    <input type="submit">
    </form>

    page2.php:
    <?php
    include("dblogi n.php"); // Loads database password, username and opens
    database line.
    $query = "INSERT INTO table1 (column1) VALUES ('$textbox')";
    $result = mysql_query($qu ery);
    ?>

    All the carrige returns dissappear, meaning i have to use <br> or the <p>
    tags, but this is not possible for users of a site to have to type in <br>
    instead of return. Any ideas?

    2) Even easier. Does anyone know where there is a good tutorial for creating
    ..png images automatically from data.

    Many thanks in advance
    Shaun
    http://www.shaund.com - My Homepage
    http://www.green-cabbage.co.uk - My Plymouth Argyle Site (UK Soccer Team)


  • Savut

    #2
    Re: Help please

    You may need to catch the variable from the textbox if your php.ini config
    has Global variable disabled which is the best option for security issues.

    <?php
    $textbox = $_POST["textbox"];
    include("dblogi n.php"); // Loads database password, username and opens
    database line.
    $query = "INSERT INTO table1 (column1) VALUES ('$textbox')";
    $result = mysql_query($qu ery);
    ?>

    2nd: you have to replace \n (return) by <br> with the function

    str_replace("\n ", "<br>", $textarea);

    "Shaun Demellweek" <shaun@shaund.c om> a écrit dans le message de
    news:bkd3u8$ktn $1@newsg2.svr.p ol.co.uk...[color=blue]
    > Two things I am not sure about, and would appreciate an answer to.
    >
    > 1) This may be simple. When creating a form to insert data into a table, I
    > seem to loose all the returns when data is inputted. I use the following
    > script:
    >
    > page1.php:
    > <form action="page2.p hp">
    > <textarea name="textbox"> </textarea>
    > <input type="submit">
    > </form>
    >
    > page2.php:
    > <?php
    > include("dblogi n.php"); // Loads database password, username and opens
    > database line.
    > $query = "INSERT INTO table1 (column1) VALUES ('$textbox')";
    > $result = mysql_query($qu ery);
    > ?>
    >
    > All the carrige returns dissappear, meaning i have to use <br> or the <p>
    > tags, but this is not possible for users of a site to have to type in <br>
    > instead of return. Any ideas?
    >
    > 2) Even easier. Does anyone know where there is a good tutorial for[/color]
    creating[color=blue]
    > .png images automatically from data.
    >
    > Many thanks in advance
    > Shaun
    > http://www.shaund.com - My Homepage
    > http://www.green-cabbage.co.uk - My Plymouth Argyle Site (UK Soccer Team)
    >
    >[/color]


    Comment

    • Geoff Berrow

      #3
      Re: Help please

      I noticed that Message-ID: <8Aoab.7765$BT1 .357678@news20. bellglobal.com>
      from Savut contained the following:
      [color=blue]
      >2nd: you have to replace \n (return) by <br> with the function
      >
      >str_replace("\ n", "<br>", $textarea);[/color]

      or use the new line to <br> function

      nltobr($textare a);



      --
      Geoff Berrow
      It's only Usenet, no one dies.
      My opinions, not the committee's, mine.
      Simple RFDs http://www.ckdog.co.uk/rfdmaker/

      Comment

      • sam

        #4
        Re: Help please

        "Shaun Demellweek" <shaun@shaund.c om> wrote in message
        news:bkd3u8$ktn $1@newsg2.svr.p ol.co.uk...[color=blue]
        > Two things I am not sure about, and would appreciate an answer to.
        >
        > 1) This may be simple. When creating a form to insert data into a table, I
        > seem to loose all the returns when data is inputted. I use the following
        > script:
        >
        > page1.php:
        > <form action="page2.p hp">
        > <textarea name="textbox"> </textarea>
        > <input type="submit">
        > </form>
        >
        > page2.php:
        > <?php
        > include("dblogi n.php"); // Loads database password, username and opens
        > database line.
        > $query = "INSERT INTO table1 (column1) VALUES ('$textbox')";
        > $result = mysql_query($qu ery);
        > ?>
        >
        > All the carrige returns dissappear, meaning i have to use <br> or the <p>
        > tags, but this is not possible for users of a site to have to type in <br>
        > instead of return. Any ideas?[/color]


        $textbox = nl2br($textbox) ;

        This way you replace carrige returns with <br>'s
        [color=blue]
        > 2) Even easier. Does anyone know where there is a good tutorial for[/color]
        creating[color=blue]
        > .png images automatically from data.
        >
        > Many thanks in advance
        > Shaun
        > http://www.shaund.com - My Homepage
        > http://www.green-cabbage.co.uk - My Plymouth Argyle Site (UK Soccer Team)
        >
        >[/color]


        Comment

        Working...