forms and php and mysql

hmm i want to add a new row into a database , the value of wot should be inserted is in the textbox. one problem it doesnt work :(

can anyone help me please

[code]
<?
$insert = mysql_query("insert into tester (Name) values text1");
?>


     &nbsp


[/code]

im new at this so i hope its not a stupid question :D

thanx
[hr]
CYA
[red][b]KiLLeRRaT a.k.a KiLr@ a.k.a albert :D[/b][/red]
someone said to me :"u cant do it man u just copy and past the code." and i said well, why reinvent the wheel:D

Comments

  • : [code]
    :
    :
    : [/code]
    you can't use PHP as an event handler (like javascript) because it's server-side code that runs just once as the page is rendered.
    the solution is to use another page as target of your form (see above)
    and put the insert statements in that page.
    OR you could refer to the same page but add a block of code that only executes when $submit = "submit"



  • : : [code]
    : :
    : :
    : : [/code]
    : you can't use PHP as an event handler (like javascript) because it's server-side code that runs just once as the page is rendered.
    : the solution is to use another page as target of your form (see above)
    : and put the insert statements in that page.
    : OR you could refer to the same page but add a block of code that only executes when $submit = "submit"
    :
    :
    :
    :
    how would i do that ??? i dont know ANYTHING ;)

    thanx

    [hr]
    CYA
    [red][b]KiLLeRRaT a.k.a KiLr@ a.k.a albert :D[/b][/red]
    someone said to me :"u cant do it man u just copy and past the code." and i said well, why reinvent the wheel:D


  • : how would i do that ??? i dont know ANYTHING ;)

    well, in that case i must refer you to the PHP manual. i can't explain EVERYTHING :)
    There are also loads of examples to be found on the net BTW


  • hmm ok dumb question , what do i look for coz ive had a look but dunno wot to look for , i tried like instert into and that is all
    so just gimme a hint to what to look for
    thanx
    [hr]
    CYA
    [red][b]KiLLeRRaT a.k.a KiLr@ a.k.a albert :D[/b][/red]
    someone said to me :"u cant do it man u just copy and past the code." and i said well, why reinvent the wheel:D

  • : hmm ok dumb question
    no no, that's not what i meant to say (IMHO there are no dumb questions)
    a forum like this is just not the place for lectures or programming courses. but for basic questions like this you really need to go back to the basics and knuckle down on a bit of theory. trust me: you won't be able to run if you cant walk

    take a look at phpbuilder.com; they have lots of commented scripts and 'how to' articles on a myriad of php & mysql subjects.

    1 word of advice: leave the MySQL bits alone until you are a bit more confident in php in general.

  • : : hmm ok dumb question
    : no no, that's not what i meant to say (IMHO there are no dumb questions)
    : a forum like this is just not the place for lectures or programming courses. but for basic questions like this you really need to go back to the basics and knuckle down on a bit of theory. trust me: you won't be able to run if you cant walk
    :
    : take a look at phpbuilder.com; they have lots of commented scripts and 'how to' articles on a myriad of php & mysql subjects.
    :
    : 1 word of advice: leave the MySQL bits alone until you are a bit more confident in php in general.
    :
    :
    Thanx man il have a look there when i have a chance
    cya
    [hr]
    CYA
    [red][b]KiLLeRRaT a.k.a KiLr@ a.k.a albert :D[/b][/red]
    someone said to me :"u cant do it man u just copy and past the code." and i said well, why reinvent the wheel:D

  • [b][red]This message was edited by salat at 2002-10-16 4:41:15[/red][/b][hr]
    [b][red]This message was edited by salat at 2002-10-16 4:39:51[/red][/b][hr]
    [b][red]This message was edited by salat at 2002-10-16 4:38:56[/red][/b][hr]
    [b][red]This message was edited by salat at 2002-10-16 4:35:52[/red][/b][hr]
    : hmm i want to add a new row into a database , the value of wot should be inserted is in the textbox. one problem it doesnt work :(
    :
    : can anyone help me please
    :
    : [code]
    : <?
    : $insert = mysql_query("insert into tester (Name) values text1");
    : ?>
    :
    :
    :      &nbsp
    :
    :
    : [/code]
    :
    : im new at this so i hope its not a stupid question :D
    :
    : thanx
    : [hr]
    : CYA
    : [red][b]KiLLeRRaT a.k.a KiLr@ a.k.a albert :D[/b][/red]
    : someone said to me :"u cant do it man u just copy and past the code." and i said well, why reinvent the wheel:D
    :


    I think you just made a little mistake.
    in the line

    $insert = mysql_query("insert into tester (Name) values text1");

    you miss $ in front of text1!!!!
    so the row should look like this

    $insert = mysql_query("insert into tester (Name) values $text1");

    If this doesn't work try this instead

    $insert = mysql_query("insert into tester (Name) values ('$text1')");

    a last thing you could try is to change you initiation of forms
    () with



    where it says page.php you should write the name of the php file like myownphppage.php

    best regards
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories