Forum Moderators: coopster
source code:
signup.php
errors on 158,172,179 rows/mentioned after
$string = $username;
// username check
if (Validate_String($string, $return_invalid_chars)!= "true") {
echo "<div class=error>You username contains invalid characters. You can use only alphanumeric lowercase characters(a-z 0-9).</div>";
signup_step1();
return(14);
}
// username check 2
$r=mysql_query("select * from blogusers where username='".mysql_escape_string($username)."'",$link);
158= if (mysql_num_rows($r)) {
echo "<div class=error>Such user has already registered</div>";
signup_step1();
return(15);
}
// email check
if (ValidateEmail($email)!= "true") {
echo "<div class=error>It seems that your email is not valid, please check.</div>";
signup_step1();
return(16);
}
// check email to avoid abuse
$r=mysql_query("select * from blogusers where email='".mysql_escape_string($email)."'",$link);
172= if (mysql_num_rows($r)>3) { // edit here the number of blog allowed for each email address, and edit the text below, too.
echo "<div class=error>This email is already in use 3 times.</div>";
signup_step1();
return(17);
}
// check ip to avoid abuse
$r=mysql_query("select * from blogusers where ip like '".mysql_escape_string($_SERVER['REMOTE_ADDR'])."'",$link);
179= if (mysql_num_rows($r)>3) { // edit here the number of blog allowed for each ip address, and edit the text below, too.
echo "<div class=error>There is a limit of 3 blog per each user in this community.</div>";
signup_step1();
return(18);
Help me, plz
$r=mysql_query("select * from blogusers where username='mysql_escape_string($username)'",$link);
If that doesn't work, what you'll need to do is to ensure the query is valid, thus returning a result.
$query = "select * from blogusers where username='".mysql_real_escape_string($username)."'";
$r = mysql_query($query ,$link) or [url=http://www.php.net/die]die[/url]([url=http://www.php.net/mysql-error]mysql_error[/url]());
This will give you some sort of heads-up as to what is happening with MySQL and why your query is failing.
$query=sprintf("select * from blogusers where username='%s'" ,mysql_real_escape_string($username));
$result = mysql_query($query, $link);
$r = mysql_num_rows($result);
if ($r) {
echo "<div class=error>Such user has already registered</div>";
signup_step1();
return(15);
}
It doesn't appear that you're actually wanting to use the value of mysql_num_rows, just that any value being returned will trigger an action. I can see potential problems with this code, but it should at least get you moving forward.
it says, no database
Generally when you are getting an error like this it means that you didn't specify the database correctly using mysql_select_db [php.net]. Take a look at this. I also don't see where you connect to the db server in the first place; maybe it is up above?
eelixduppy, thanks, I have created, iii.php
with this code, changed data, and is said, it cannot do the action to my database.
<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Not connected : ' . mysql_error());
}
// make foo the current db
$db_selected = mysql_select_db('foo', $link);
if (!$db_selected) {
die ('Can\'t use foo : ' . mysql_error());
}
?>
well
and connection in signup.php code is on 50-88 lines, and the errors are on 170 line.
// starting signup process
include("config.php");
$link = mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die ("Could not connect");
@mysql_select_db(DB_NAME, $link);
// step one, we collect all the info
function signup_step1() {
include("signup.html");
return(0);
}
// step two, we check all the collected info, and if everything is fine, we send an email with further instructions.
function signup_step2() {
// preparing all the variables
global $link;
global $siteurl;
global $sitename;
global $hostpress_server_path;
global $adminemail;
$username = trim($username);
$password = trim($password);
$password2 = trim($password2);
$email = trim($email);
$username = htmlspecialchars($_POST['username']);
$password = htmlspecialchars($_POST['password']);
$password2 = htmlspecialchars($_POST['password2']);
$email = htmlspecialchars($_POST['email']);