Jump to content

mysql_query("DELETE $clan_name FROM clans");


3raser

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.

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.