Jump to content

Ph0enix

Members
  • Posts

    64
  • Joined

  • Last visited

    Never

Posts posted by Ph0enix

  1. Well before i tried andys code i used redarrow's code and got the output
    SELECT * FROM clans WHERE clantag='test' OR clanname='test'

    Then when i tried andys code i got no output, and nothing happened with my databases.

    Now iv tried redarrow's code and i get the output..
    SELECT * FROM clans WHERE clantag='test' OR clanname='test'
    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\wamp\www\league\clanck.php on line 29
  2. Well my code i started with is the one right at the start.
    The code i have now is

    [code]
    <?php session_start();

    include "connect.php";

    $username=$_SESSION['username']=$username;


    $username=($_POST['username']);
    $clantag=($_POST['clantag']);
    $clanname=($_post['clanname']);
    $clansite=($_post['clansite']);

    $username=addslashes($username);
    $clantag=addslashes($clantag);
    $clanname=addslashes($clanname);
    $clansite=addslashes($clansite);



    if (($_POST['clanname']=="") || ($_POST['clantag']=="")) {

      echo "Clan Tag and Clan Name are required fields.";

    }else{

    $query = "SELECT * FROM clans WHERE clantag='$clantag' OR clanname='$clanname'";

    echo $query;
    $result=mysql_query(query);

    while($row=mysql_fetch_assoc($result)){

    if($row['clanname']==1) {

    echo "The Clan Tag or Clan Name you have chosen are allready in use.";

    }else{

    $add_clan="INSERT INTO clans (clantag, clanname, clansite) VALUES ('$clantag', '$clanname', '$clansite')";
    mysql_query($add_clan) or die(mysql_error());


    $update_name="UPDATE users SET clanname='$clanname' WHERE username='$username'";
    $result1=mysql_query($update_name) or die(mysql_error());


    $update_tag="UPDATE users SET clantag='$clantag' WHERE username='$username'";
    $result2=mysql_query($update_tag) or die(mysql_error());


    $update_rank="UPDATE users SET rank='Leader' WHERE username='$username'";
    $result3=mysql_query($update_rank) or die(mysql_error());

    echo "You have sucessfully registered a clan";

    }
    }
    ?>
    [/code]

    I'm not sure if this code is doing the same as what the first bit of code was trying to do..
  3. lol!
    Now instead of the clansite being the thing that is put it, the clan tag is being put in, and nothing else. =/
    But now i get this...
    "Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\league\clanck.php on line 31
    You have sucessfully registered a clan" 
    Line 31 is..
    $rows = mysql_num_rows($result);
    Is there anything else i can try?
    Thanks for your help.
  4. Hi, yes i have another very annoying error in my script.
    This is my script..

    [code]
    <?php
    session_start();
    include "connect.php";
    $username= $_SESSION['username'];

    if ($_POST[clanname]="" OR $_POST['clantag']="") {
      echo "Clan Tag and Clan Name are required fields.";
    }else{
    $result = mysql_query("SELECT * FROM clans WHERE clantag = '$_POST[clantag]' OR clanname = '$_POST[clanname]'");
    $rows = mysql_num_rows($result);
    if ($rows > 0) {
      echo "The Clan Tag or Clan Name you have chosen are allready in use.";
    }else{
    $add_clan = ("INSERT INTO clans (clantag, clanname, clansite) VALUES ('$_POST[clantag]', '$_POST[clanname]', '$_POST[clansite]')");
    mysql_query($add_clan) or die(mysql_error());
    $update_name = ("UPDATE users SET clanname = '$_POST[clanname]' WHERE username = '$username' ");
    mysql_query($update_name) or die(mysql_error());
    $update_tag = ("UPDATE users SET clantag = '$_POST[clantag]' WHERE username = '$username' ");
    mysql_query($update_tag) or die(mysql_error());
    $update_rank = ("UPDATE users SET rank = 'Leader' WHERE username = '$username' ");
    mysql_query($update_rank) or die(mysql_error());
    echo "You have sucessfully registered a clan";

    }
    ?>
    [/code]
    Now the annoything is that it says "You have successfully registered a clan" and a new row has been added in the database, but only the name of the website is submitted into it. Both the clanname and clantag fields are empty. Its sooooo annoying. Please help me..
    Thanks
    Max
  5. I tried them both and the first one says "That you are associated with a clan" whether the field is empty or not.
    The second one works.. YES!!! Finally.
    Thank you both for helping me. I really appreciate it. :D
  6. Argh!! Still doesn't work  :(
    I was thinking, should i set the default for the column clanname to 1 and then check the field to see if it is equal to 1, and if it is then they are not in a clan.

    If i should try this how would i do it?  :-[
    (thanks for all the help your giving me tomfmason)
    Thanks
    Max
  7. Hi, thanks for your fast reply.
    The first part of the script works fine its just the next bit..

    $username = $_SESSION['username'];
    $result = mysql_fetch_array(mysql_query("SELECT clanname FROM users WHERE username = '$username'"));
    if (($result['username'] != "")) {
      echo "You are allready in a clan.";

    even if the user is in a clan the form still shows.
    But if they are in a clan i want a message to come up saying "you are allready in a clan" and then thats it.
    Thanks
    Max
  8. Hi, im creating a league script and i have come across a problem. On the page where people are able to register clans, i want to check to see if they are allready in a clan. This is my script.

    [code]<?php
    session_start();
    include "connect.php";
    if (empty($_SESSION['username'])) {
    echo "You must be logged in to access this page. <a href='login.php'>Click here</a> to login.";
    }else{
    $username = $_SESSION['username'];
    $result = mysql_fetch_array(mysql_query("SELECT clanname FROM users WHERE username = '$username'"));
    if (($result['username'] != "")) {
      echo "You are allready in a clan.";
    }else{
    echo
    "<form action='clanck.php' method='POST'>
    <table align='center' border='0' cellspacing='0'>
    <tr>
    <td>Clan Tag:</td>
    <td><input type='text' name='clantag'></td>
    </tr>
    <tr>
    <td>Clan Name:</td>
    <td><input type='text' name='clanname'>
    </tr>
    <tr>
    <td>Clan Site:</td>
    <td><input type='text' name='clansite'></td>
    </tr>
    <tr>
    <td><input type='submit' value='Register Clan'></td>
    </tr>
    </table>
    </form>";
    }
    }
    ?>
    [/code]

    The first bit works, so if they are not logged in then they cant access the page. But the next bit doesnt. I dont get any error, but the form is always shown even if they are in a clan. Can someone help me please?
    Thanks
    Max
  9. WAMP5 is a very good program and its what i use. If you want to install it and see how to configure it. Go to www.phpvideotutorials.com and look at the tuts. You will learn a lot from this site. ;)
×
×
  • 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.