•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 401,956 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,099 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 4944 | Replies: 2
![]() |
•
•
Join Date: Jan 2007
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
Hi, I'm quite new to PHP and MYSQL, but I have chosen to do an A-level project in it. This is just a basic registering page, which I've copied and modified from one out of a book. That one works, but this doesn't, saying that "mysql_numrows(): supplied argument is not a valid MySQL result resource". I hope that makes sense to someone.
Cheers
php Syntax (Toggle Plain Text)
<?php #Script 8.7 - register.php //SEND NOTHING TO BROWSER BEFORE HEADER() //Check if form is sumbitted if (isset($_POST['submitted'])) { require_once('../mysql_pp_connect.php'); $errors = array(); //Validate crap if (empty($_POST['title'])) { $errors[] = 'You forgot to enter your first name.'; } else { $t = escape_data($_POST['title']); } if (empty($_POST['first_name'])) { $errors[] = 'You forgot to enter your first name.'; } else { $fn = escape_data($_POST['first_name']); } if (empty($_POST['last_name'])) { $errors[] = 'You forgot to enter your last name.'; } else { $ln = escape_data($_POST['last_name']); } if (empty($_POST['addressline1'])) { $errors[] = 'You forgot to enter your address.'; } else { $al1 = escape_data($_POST['addressline1']); } $al2 = escape_data($_POST['addressline2']); $al3 = escape_data($_POST['addressline3']); if (empty($_POST['postcode'])) { $errors[] = 'You forgot to enter your postcode.'; } else { $pc = escape_data($_POST['postcode']); } if (empty($_POST['email'])) { $errors[] = 'You forgot to enter your email address.'; } else { $e = escape_data($_POST['email']); } if (empty($_POST['phone_number'])) { $errors[] = 'You forgot to enter your phone number.'; } else { $pn = escape_data($_POST['phone_number']); } if(!empty($_POST['password1'])) { if($_POST['password1'] != $_POST['password2']) { $errors[] = "Your passwords didn't match"; } else { $p = escape_data($_POST['password1']); } } else { $errors[] = "You didn't enter a password!"; } if (empty($errors)) { $query = "SELECT user_id FROM users WHERE email='$e'"; $result = mysql_query ($query); if (mysql_num_rows($result) == 0) { //Make query $query = "INSERT INTO customers (Title, FirstName, LastName, AddressLine1, AddressLine2, Addressline3, Postcode, EmailAddress, PhoneNumber, Password) VALUES ('$t', '$fn', '$ln', '$al1', '$al2', '$al3', '$pc', '$e', '$pn', SHA('$p'))"; $result = @mysql_query ($query); //Run query if ($result) { //send email blah blah //redirect to thanks.php page //start defining url $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\')) { $url = substr($url, 0, -1); //chop off slashah. } $url .= '/thanks.php'; header("Location: $url"); exit(); } else { $errors[] = 'You could not be registered due to a system error. oops. sorry!'; $errors[] = mysql_error() . '<p>Query ' . $query; } } else { $errors = 'The email address has already been registered!'; } } mysql_close(); }else{ $errors = NULL; } //end of submit conditional $page_title = 'Register'; include ('./header.html'); if(!empty($errors)){ echo '<h1 id="mainhead">Error!</h1><p class="error">The following errors occurred:<br><ul>'; foreach ($errors as $msg) { echo "<li>$msg</li><br>"; } echo '</ul><p>Please try again'; } //end of if empty errrors if ?>
Cheers
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource (PHP)
- Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource (PHP)
- Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource (PHP)
- Supplied argument is not a valid MySQL result resource (MySQL)
- Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource (PHP)
- Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in (PHP)
- Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource (PHP)
- mysql_num_rows(): supplied argument is not a valid MySQL result resource in /user/690 (PHP)
- Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource (PHP)
Other Threads in the PHP Forum
- Previous Thread: PHP Parse error: parse error, unexpected T_STRING in F:\downloads\cats-0.6.1\index.ph
- Next Thread: Matrix Script


Linear Mode