Jump to content

[SOLVED] major noob question


rallokkcaz

Recommended Posts

$query = "SELECT * FROM `database` WHERE username = '".$username."' LIMIT 1";
$result = mysql_query($query);
if (!$result) { die(mysql_error()); }
$rows = mysql_num_rows($result);
if ($rows > 0) { echo "user allready exists"; }
else { echo "user don't exist"; }

link=topic=138756.msg588491#msg588491 date=1178068730]

$query = "SELECT * FROM `database` WHERE username = '".$username."' LIMIT 1";
$result = mysql_query($query);
if (!$result) { die(mysql_error()); }
$rows = mysql_num_rows($result);
if ($rows > 0) { echo "user allready exists"; }
else { echo "user don't exist"; }

 

I'm sorry, but that is a terrible example of how to code. Its hardly friendly on the eye.

 

<?php

  $query = "SELECT * FROM database WHERE username = '$username' LIMIT 1";
  if ($result = mysql_query($query)) {
    if (mysql_num_rows($result)) {
      // user already exists.
    } else {
      // do the signup, INSERT.
    }
  } else {
    // query failed, handle error / debugging.
  }

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.