Printer Friendly Version Print this thread
Email this thread to a friend eMail this thread to a friend
  • PHP or ASP (In: General Search Engine Optimization)
  • what is best php or html? (In: General Search Engine Optimization)
  • Featured Web Site Template

    Hundreds More at Free Site Templates.com!

    Web Site Partners
    Sponsored Links
    Jet City Software
     
    Whos Here ?
    There are 0 guests and 1 members in the forums right now.
    Reflects user activity within the last 5 minutes
    Moderator(s): Prowler, jcokos
    Member Message

    ronnieplant
    Joined: Feb 09, 2005
    # Posts: 7

    View the profile for ronnieplant Send ronnieplant a private message

    Posted: 2005-Feb-09 22:57
    Edit Message Delete Message Reply to this message

    To anybody still sane...

    Basically, I'm trying to create a register/login system with php & dreamweaver. I've created the login system but my problem is creating the register/signup system. I've tried to do this with the following code for a registration form to put information into the "members" table, which is located within my "venmembers" database.

    It only says "could not execute query" . Which is basically telling me that it can't use/find the "members" table. I don't understand because it can find the database which it is in, but not the table.

    Somebody please browse this code to see if there's anything which doesn't make sense. I'd be eternally grateful. I've been trying to do this (and only this) for two days.


    <html>
    <head>
    <title>Please Register Here</title>
    <style type="text/css">
    <!--
    .style1 {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 10px;
    }
    -->
    </style>
    </head>
    <body>
    <h1 align="center" class="style1"><strong>Sign up</strong></h1>
    <form method="post" name="signup" action="<?$PHP_SELF?>">
    <table align="center">
    <!-User name
    <tr>
    <td><span class="style1">Username:</span></td>
    <td><input type="text" name="loginname" maxlength="20"></td>
    </tr>
    <!-User password
    <tr>
    <td><span class="style1">Password:</span></td>
    <td><input type="password" name="password" maxlength="20"></td>
    </tr>
    <!-Last name
    <tr>
    <td><span class="style1">Last Name:</span></td>
    <td><input type="text" name="lastname" maxlength="50"></td>
    </tr>
    <!-First name
    <tr>
    <td><span class="style1">First Name:</span></td>
    <td><input type="text" name="firstname" maxlength="40"></td>
    </tr>
    <!-Street name
    <tr>
    <td><span class="style1">Street Name:</span></td>
    <td><input type="text" name="street" maxlength="50"></td>
    </tr>
    <!-City
    <tr>
    <td><span class="style1">City:</span></td>
    <td><input type="text" name="city" maxlength="50"></td>
    </tr>
    <!-county
    <tr>
    <td><span class="style1">County:</span></td>
    <td><input type="text" name="county" maxlength="50"></td>
    </tr>
    <!-Postcode
    <tr>
    <td><span class="style1">Postcode:</span></td>
    <td><input type="text" name="postcode" maxlength="10"></td>
    </tr>
    <!-Email
    <tr>
    <td><span class="style1">Email Address:</span></td>
    <td><input type="text" name="email" maxlength="50"></td>
    </tr>
    <!-Phone
    <tr>
    <td><span class="style1">Phone:</span></td>
    <td><input type="text" name="phone" maxlength="15"></td>
    </tr>
    <!-Fax
    <tr>
    <td><span class="style1">Fax:</span></td>
    <td><input type="text" name="fax" maxlength="15"></td>
    </tr>
    <!-Submit Buttons
    <tr>
    <td><input name="submit" type="submit" class="style1" value="submit"></td>
    <td><input name="reset" type="reset" class="style1" value="reset"></td>
    </tr>
    </table>
    </form>
    <?php
    { $conn = @mysql_connect( "localhost", "root", "xxxxxxx" )
    or die ("Could not connect to MySQL"wink;
    $db = @mysql_select_db( "venmembers", $conn )
    or die ("Could not select database"wink;
    $sql = "insert into member (loginname, createdate, password, lastname, firstname, street, city, county, postcode, email, phone, fax) values
    ('$loginname', '$password', '$lastname', '$firstname', '$street', '$city', '$county', '$postcode', '$email', '$phone', '$fax'))";
    $result = @mysql_query( $sql, $conn )
    or die ("Could not execute query"wink;
    if ( $result ) { echo ("New user $loginname added" );}
    }
    ?>
    </body></html>



    Sinoed
    Joined: Dec 11, 2000
    # Posts: 5266

    View the profile for Sinoed Send Sinoed a private message

    Posted: 2005-Feb-10 01:51
    Edit Message Delete Message Reply to this message

    You're missing '$createdate' after '$loginname' in the $sql statement. You have to be very precise with those, one tiny little thing wrong can throw you way off track (I've been there too :P) . Try adding that and see if it fixes your problem. smile



    ronnieplant
    Joined: Feb 09, 2005
    # Posts: 7

    View the profile for ronnieplant Send ronnieplant a private message

    Posted: 2005-Feb-10 10:21
    Edit Message Delete Message Reply to this message

    Hi Sinoed, I'm afraid it didn't fix my problem. Well spotted though! Thanks.

    Can you think of anything else it might be? It's so frustrating isn't it?



    Sinoed
    Joined: Dec 11, 2000
    # Posts: 5266

    View the profile for Sinoed Send Sinoed a private message

    Posted: 2005-Feb-10 13:41
    Edit Message Delete Message Reply to this message

    Looks like an extra bracket at the end of the $sql statement too..



    ronnieplant
    Joined: Feb 09, 2005
    # Posts: 7

    View the profile for ronnieplant Send ronnieplant a private message

    Posted: 2005-Feb-10 15:37
    Edit Message Delete Message Reply to this message

    That'll be it!

    Thanks.



    Sinoed
    Joined: Dec 11, 2000
    # Posts: 5266

    View the profile for Sinoed Send Sinoed a private message

    Posted: 2005-Feb-10 15:49
    Edit Message Delete Message Reply to this message

    I hope that it works now. smile Just for future reference if you're having a really tough time with a long sql statement that inserts a number of variables you can debug like I do.

    Just go back and create your basic statement and try inserting one or two variables first. If that doesn't work, you know that you have a problem with something before that like the connection string or path. If it does, then you know there is a problem somewhere in the syntax of the sql statement. If its really long, just keep adding in the variables one or two at a time and testing as you go along. By breaking it up into little sections its easier to pinpoint where you might have a problem - sometimes something silly like an extra letter or spelling.

    Hope that helps, post again if you run into troubles. smile



    g1smd
    Staff
    Joined: Jul 28, 2002
    # Posts: 10418

    View the profile for g1smd Send g1smd a private message

    Posted: 2005-Feb-10 17:12
    Edit Message Delete Message Reply to this message

    You can simplify the HTML code a lot.


    Change the HTML:

    <table align="center">
    ...
    <td><span class="style1">Street Name:</span></td>


    to be:

    <table align="center" class="style1">
    ...
    <td>Street Name:</td>


    and then change the stylesheet to style it this way:

    .style1 td { the style info; }

    This does away with all of the span tags, and applies the class to the table, the ".style1 td" selector in the stylesheet then styles the cells as if each had had its own style attribute directly attached.

    You can then style the input text a different way, if you want, by using the ".class1 input" selector in the stylesheet.


    Your comment tags like <!-Phone are invalid. There must be exactly two dashes, and the tag must be closed: <!-- Phone -->


    You don't need a <strong> tag on the heading tag, headings are rendered in bold-face by default.


    You are not permitted to post messages in this forum or topic, because of one or more of the following reasons:
    1. You have not yet logged in, or registered properly as a member
    2. You are a member, but no longer have posting rights.
    3. This is a private forum, for which you do not have permissions.

    If you are a recent member, it's possible that you simply have not yet confirmed your account. Please check your email for a message entitled 'JimWorld Forums: Confirm Your Account' and follow the instructions contained within.

    If you cannot find this message, click here to Re-Send it.

    If you are still experiencing problem, please read the Login Assistance Article for some advice on what may be causing your login not to work properly.

    Switch to Advanced Editor and ... Create a New Topic or Reply to this Thread

    New posts Forum is locked
    © 1995  ·  iWeb, Inc  ·  DBA JimWorld Productions