Грешка в код

nom3r1

Registered
Код:
			$sql = "SELECT MAX(id) AS total FROM `users`";
			if ( !($result = $db->sql_query($sql)) ) {
				die('Could not obtain next user_id information', $sql);
			}

			if ( !($row = $db->sql_fetchrow($result)) ) {
				die('Could not obtain next user_id information', $sql);
			}
			$id = $row['total'] + 1;
			
$query = mysql_query("INSERT INTO users (id, username, password, email, date, ip) VALUES('$id', '" . str_replace("\'", "''", $username) . "','" . str_replace("\'", "''", $password) . "','$email', '".time()."', '$ip')"); 
echo "<br /><b>Поздравления регистрирахте се успешно!</b>";

Parse error: parse error in /home/nom3r1/public_html/register.php on line 40

Ред 40:
die('Could not obtain next user_id information', $sql);
 
Здравей!

Грешката ти е в синтаксиса на die(); -> подаваш 2 аргумента:

die('Could not obtain next user_id information', $sql);

... докато функцията може да приеме само един:

die(int);
die(string);

Подобен запис, съчленяващ низа и стойността на променливата чрез оператора за присъединяване (".") вече би бил коректен:

die('Could not obtain next user_id information'.$sql);


Повече:

http://bg2.php.net/manual/bg/function.exit.php
 
Интересно, защо като имам 1 потребител в таблицата повече регистрации не могат да се правят?

Код:
          $sql = "SELECT MAX(id) AS total FROM `users`";
         if (!($result = mysql_query($sql))) {
			die('Could not obtain next id information'.$sql);
         }

         if (!($row = mysql_fetch_row($result))) {
			die('Could not obtain next id information'.$sql);
         }
         $id = $row['total'] + 1; 
		 
$query = mysql_query("INSERT INTO users (id, username, password, email, date, ip) VALUES('$id', '" . str_replace("\'", "''", $username) . "','" . str_replace("\'", "''", $password) . "','$email', '$date', '$ip')"); 
echo "<br /><b>Поздравления регистрирахте се успешно!</b>";
 
Е пък какъв е смисалът да правиши id с променлива??? Опитай да е без нея и остави id на NULL
Код:
         $sql = "SELECT MAX(id) AS total FROM `users`";
         if (!($result = mysql_query($sql))) {
         die('Could not obtain next id information');
         }

         if (!($row = mysql_fetch_row($result))) {
         die('Could not obtain next id information');
         }
         $id = $row['total'] + 1;
      
		$query = mysql_query("INSERT INTO users (id, username, password, email, date, ip) VALUES('$id', '" . str_replace("\'", "''", $username) . "','" . str_replace("\'", "''", $password) . "','$email', '$date', '$ip')");
		echo "<br /><b>Поздравления регистрирахте се успешно!</b>";
Опитай така!
 
Id-трябва да ти е int в дб-то и кода да ти е така :
Код:
	          <?
			  $sql = "SELECT MAX(id) AS total FROM `users`";
         if ( !($result = $db->sql_query($sql)) ) {
            die('Could not obtain next user_id information', $sql);
         }

         if ( !($row = $db->sql_fetchrow($result)) ) {
            die('Could not obtain next user_id information', $sql);
         }
         
$query = mysql_query("INSERT INTO users (id, username, password, email, date, ip) VALUES('', '" . str_replace("'\'", "''", $username) . "','" . str_replace("'\'", "''", $password) . "','$email', '".time()."', '$ip')");
echo "<br /><b>Поздравления регистрирахте се успешно!</b>"; 

?>
 

Back
Горе