Printer Friendly Version
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 |
|
There are 0 guests and 1 members in the forums right now.
Reflects user activity within the last 5 minutes
|
|
| Member |
Message |
ronnieplant
Joined: Feb 09, 2005
# Posts: 7
|
Posted: 2005-Feb-09 22:57
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" ;
$db = @mysql_select_db( "venmembers", $conn )
or die ("Could not select database" ;
$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" ;
if ( $result ) { echo ("New user $loginname added" );}
}
?>
</body></html>
|
 |
Sinoed
Joined: Dec 11, 2000
# Posts: 5266
|
Posted: 2005-Feb-10 01:51
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.
|
 |
ronnieplant
Joined: Feb 09, 2005
# Posts: 7
|
Posted: 2005-Feb-10 10:21
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
|
Posted: 2005-Feb-10 13:41
Looks like an extra bracket at the end of the $sql statement too..
|
 |
ronnieplant
Joined: Feb 09, 2005
# Posts: 7
|
Posted: 2005-Feb-10 15:37
That'll be it!
Thanks.
|
 |
Sinoed
Joined: Dec 11, 2000
# Posts: 5266
|
Posted: 2005-Feb-10 15:49
I hope that it works now. 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.
|
 |
g1smd
Staff
Joined: Jul 28, 2002
# Posts: 10418
|
Posted: 2005-Feb-10 17:12
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:
- You have not yet logged in, or registered properly as a member
- You are a member, but no longer have posting rights.
- 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
|
|