Jump to content

Recommended Posts

And I edited my post above. So my query is failing.

 

I'm not sure how many times I need to say it, you need to SELECT a field.

 

I'm not selecting a field, I'm just seeing if it exists. Which brings me to another point. Should I put the whole code inside the failing part, because when it fails....that means a clan with that name doesn't exist.

Can you please make it so there is no edit limit on posts? I always go to edit and the limit us up.

 

I think this is the answer to the problem. I just keep getting this parse error:

 

Parse error: parse error in C:\wamp\www\project11\register_clan.php on line 28

 

for

 

if(!$clan_name) {
	    echo "Enter in a clan name: <form action='register_clan.php' method='POST'><input type='text' name='clan'><input type='submit' value='Register Clan'></form>";
	 } else {
      if ($get_other = mysql_query("SELECT FROM clans WHERE clan_name='$clan_name'")) {
              $check = mysql_num_rows($get_other);

          } else {

	   echo "Yes.";

	  } else {

	   echo "No.";

	  }
	 }
	}

And I edited my post above. So my query is failing.

 

I'm not sure how many times I need to say it, you need to SELECT a field.

 

I'm not selecting a field, I'm just seeing if it exists.

 

In order to see if a field exists, you need to select it.  This is SQL 101.

See here http://dev.mysql.com/doc/refman/5.1/en/select.html. I'm honestly over repeating myself.

 

WHAT?! REPEATING YOURSELF?! I've read every single one of your posts...and what I'm talking about now, my error above, is not even something we have discussed...

<?php
session_start();
$session = $_SESSION['user'];

$mysql_host = "localhost";
$mysql_username = "root";
$mysql_password = "";
$mysql_database = "project11";

mysql_connect($mysql_host, $mysql_username, $mysql_password);
mysql_select_db($mysql_database);

     if(!$session) {
    echo "Please <a href='login.php'>login</a> first, or <a href='index.php'>go home</a>.";
 } else {

  $clan_name = $_POST['clan'];
  $ip = $_SERVER['REMOTE_ADDR'];
  $date = date("M-D-Y");
   
     if(!$clan_name) {
	    echo "Enter in a clan name: <form action='register_clan.php' method='POST'><input type='text' name='clan'><input type='submit' value='Register Clan'></form>";
	 } else {
      if ($get_other = mysql_query("SELECT FROM clans WHERE clan_name='$clan_name'")) {
          $check = mysql_num_rows($get_other);
          } else {
	   echo "Yes.";
	  } else {
	   echo "No.";
	  }
	 }
	}
?>

<?php
session_start();
$session = $_SESSION['user'];

$mysql_host = "localhost";
$mysql_username = "root";
$mysql_password = "";
$mysql_database = "project11";

mysql_connect($mysql_host, $mysql_username, $mysql_password);
mysql_select_db($mysql_database);

if(!$session) {
    echo "Please <a href='login.php'>login</a> first, or <a href='index.php'>go home</a>.";
} else {
    $clan_name = $_POST['clan'];
    $ip = $_SERVER['REMOTE_ADDR'];
    $date = date("M-D-Y");
   
    if(!$clan_name) {
        echo "Enter in a clan name: <form action='register_clan.php' method='POST'><input type='text' name='clan'><input type='submit' value='Register Clan'></form>";
    } else {
        if ($get_other = mysql_query("SELECT FROM clans WHERE clan_name='$clan_name'")) {
            $check = mysql_num_rows($get_other);
            echo "Yes.";
        } else {
            echo "No.";
        }
    }
}
?>

What does doesn't work mean? In the last part you still aren't selecting any field (see my link above). You then never actually check to see if your query returned any results.

 

if ($get_other = mysql_query("SELECT clan_name FROM clans WHERE clan_name='$clan_name'")) {
    $check = mysql_num_rows($get_other);
    if ($check) {
        echo "Yes."; // clan already exists
    } else {
        echo "No."; // clan not found
    }
}

<?php
session_start();
$session = $_SESSION['user'];

$mysql_host = "localhost";
$mysql_username = "root";
$mysql_password = "";
$mysql_database = "project11";

mysql_connect($mysql_host, $mysql_username, $mysql_password);
mysql_select_db($mysql_database);

if(!$session) {
    echo "Please <a href='login.php'>login</a> first, or <a href='index.php'>go home</a>.";
} else {
    $clan_name = $_POST['clan'];
    $ip = $_SERVER['REMOTE_ADDR'];
    $date = date("M-D-Y");
   
    if(!$clan_name) {
        echo "Enter in a clan name: <form action='register_clan.php' method='POST'><input type='text' name='clan'><input type='submit' value='Register Clan'></form>";
    } else {
       if ($get_other = mysql_query("SELECT clan_name FROM clans WHERE clan_name='$clan_name'")) {
    $check = mysql_num_rows($get_other);
    if ($check) {
        echo "Yes."; // clan already exists
    } else {
        echo "No."; // clan not found
    }
}
}
}
?>

 

No, it doesn't work. Even when I enter in something that doesn't exist, it says no.

Dude, I appreciate it a lot. I know It could get frustrating working with me, I haven't even went to sleep....so I'm half awake and half a sleep. But I can finally mark this thread solved. Until about 15 minutes later when I run into another bug :P

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.