Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Aug 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    php : query & submit allowed ???

    hmmm...is this wrong? why won't this work...any fast ideas?

    <?

    mysql_connect("localhost","vvvvvvv","vvvvvv");
    mysql_select_db("vvvvvvv");

    $query = mysql_query("SELECT * FROM content,response where response.a=content.blog and blog='$blog' " ) or die ("Unexpected error for MySQL database [1b]");
    $row = mysql_fetch_array($query);

    if ($submit){

    mysql_query("insert into response (name,email,website,date,comments) values ('$name','$email','$website','$date','$comments')") or die ("ciao");

    ?>

    and further down i have a simple form that inserts into the response table...but...am i not allowed to do it this way? it was working fine until i inserted the "submit" part of things...

    thanks for any advice...jv

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What errors do you get, and what errors are reported by mysql_error()? Does $submit default to a boolean true? Without knowing these parts we can only guess what went wrong in your script.

  • #3
    New to the CF scene
    Join Date
    Aug 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    this is what i have...

    this is what i have so far...it's a mish mash of things from the past...the page in question opens properly...but when i try to submit the data is not inserted...

    <?

    mysql_connect("localhost","vvvvvvv","vvvvvv");
    mysql_select_db("vvvvv");

    $query = mysql_query("SELECT * FROM content,response where response.a=content.blog and blog='$blog' " ) or die ("Unexpected error for MySQL database [1b]");
    $row = mysql_fetch_array($query);

    if(isset($response)){
    $mysql_link = mysql_connect("localhost","vvvvvvv","vvvvvv");
    mysql_select_db("vvvvv", $mysql_link);
    $name=addslashes($name);
    $email=addslashes($email);
    $website=addslashes($website);
    $date=addslashes($date);
    $a=addslashes($a);
    $comments=addslashes($comments);

    $query="Insert into review (name, email, website, comments, date, a ) ";

    $query.="VALUES ('$name','$email','$website','$comments','$date','$a' ) ";

    $mysql_result=mysql_query($query,$mysql_link);
    $err=mysql_errno($mysql_link);

    mysql_close($mysql_link);
    }
    ?>

    this is what i'm using for the form itself further down the page...with no luck...

    <?php
    {
    echo "<FORM Action=\"index6.php\" Method=\"POST\">\n";

    echo "<BR>Author Title <INPUT TYPE=TEXT NAME=name SIZE=30 MAXLENGTH=30>\n";
    echo "<BR>Author Email <INPUT TYPE=TEXT NAME=email SIZE=40 MAXLENGTH=40>\n";
    echo "<BR>Author Email <INPUT TYPE=TEXT NAME=website SIZE=40 MAXLENGTH=40>\n";
    echo "<BR>Author Email <INPUT TYPE=TEXT NAME=date SIZE=40 MAXLENGTH=40>\n";
    echo "<BR>Author Email <INPUT TYPE=TEXT NAME=a SIZE=40 MAXLENGTH=40>\n";
    echo "<BR>Author Email <TEXTAREA NAME=comments cols=40 rows=8 WRAP=soft></textarea>\n";

    echo "<BR><INPUT TYPE=submit NAME=Add Article VALUE=Add Article>\n";
    echo "</FORM>\n";

    }
    ?>

    thanks...jv

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I can only repeat myself, what message do you get when you echo mysql_error() after the query that does not work? From what I see in your code you assign the error number to a variable, but neither do you have mysql_error in use nor do you echo the error number.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •