Howdy, Stranger!

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

Categories

forms and php and mysql

KiLr@KiLr@ Member Posts: 91
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

  • Mark StrijbosMark Strijbos Member Posts: 82
    : [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"



  • KiLr@KiLr@ Member Posts: 91
    : : [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

  • Mark StrijbosMark Strijbos Member Posts: 82

    : 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


  • KiLr@KiLr@ Member Posts: 91
    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

  • Mark StrijbosMark Strijbos Member Posts: 82
    : 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.

  • KiLr@KiLr@ Member Posts: 91
    : : 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

  • salatsalat Member Posts: 2
    [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
  • Chris BrownChris Brown USAMember Posts: 4,624 ✭✭

    ___ || http://forcoder.org || free video tutorials and ebooks about { JavaScript, Python, C, PL/SQL, Objective-C, Go, Visual Basic .NET, Ruby, R, Delphi, Perl, Swift, PHP, Java, Assembly, C++, C#, MATLAB, Visual Basic, Scratch Clojure, D, ML, Scheme, Ada, Lisp, Transact-SQL, Erlang, Scala, Crystal, Apex, Kotlin, LabVIEW, Bash, VBScript, Julia, Prolog, ABAP, SAS, F#, COBOL, Dart, Fortran, Alice, FoxPro, Hack, Logo, Lua, Rust, Awk } ______

Sign In or Register to comment.