Jump to content

Zoey

Members
  • Posts

    27
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Zoey's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. thorpe - I tried that and it still didn't work. Jenk - how do you mean?
  2. But its not an else.  The second clause should only happen under a specific set of circumstances, that are not the opposite of the circumstances called by the first if.
  3. If a new pet is being added, it does the first thing, else if the person is banned it does the second thing, otherwise it just goes onto the rest of the page.  The second one is not an else because users may not be adding pets and may not be banned but still should be able to access the rest of the page.
  4. Variables are being set: [code]<form method="POST" action="add_pet.php"> <table><tbody>   <tr><td>Pet name:</td><td><input type="text" name="new_pet" size="50"></td></tr>   <tr><td>Contact name:</td><td> <?php if (array_key_exists("username",$_SESSION)) print $_SESSION["username"];                       else print("<a href=\"user_login.php\">Log in first.</a>"); ?></td></tr>   <tr><td>Rules Page URL:</td><td><input type="text" name="owner_url" size="50"> </td></tr>   <tr><td>Color:</td><td><?php my_build_adv_listbox("neopets", "color", "id", "description",""); ?> </td></tr>   <tr><td>Species:</td><td><?php my_build_adv_listbox("neopets", "species", "id", "description",""); ?> </td></tr>   <tr><td>Sex:</td><td><?php my_build_adv_listbox("neopets", "sex", "id", "description","1"); ?> </td></tr>   <tr><td><input type="hidden" name="status" value="8"></td></tr>   <tr><td colspan=2 align=center><?php if (array_key_exists("username",$_SESSION)) print("<input type=\"submit\" name=\"Submit\" value=\"Add pet\">"); ?> </td></tr> </tbody></table> </form> [/code] Userlevel function: (it returns the userlevel for the user accessing the page) [code]function userlevel() { GLOBAL $_SESSION; if(array_key_exists("adminflags",$_SESSION)) { return $_SESSION["adminflags"]; } else {return 0;}; }[/code]
  5. Okay, so on my site, I'm having trouble with users being falsely banned.  I have userlevels set up so that 10 is user and anything below that is banned, frozen, etc.  So on my page where users can add new pets (it's a Neopets.com fansite, for anyone particularily interested) to the database, I've got this code: [code]   if($new_pet && userlevel() > 9)   {     if (array_key_exists("username",$_SESSION)) $owner=$_SESSION["username"];     if (array_key_exists("userid",$_SESSION)) $ownerid=$_SESSION["userid"];     if($today = getdate()) { $curdate = $today[year]."-".$today[mon]."-".$today[mday]." ".$today[hours].":".$today[minutes].":".$today[seconds]; }     $result=mysql_query("INSERT INTO pet (petname,ownername,owner_id,link_url,color,species,status,submitdate,sex) VALUES ('$new_pet','$owner','$ownerid','$owner_url','$color','$species','$status','$curdate','$sex');");     if($result)     {        print("\n<p><b><i>Pet $new_pet added.  Please note, you will not see your pet in the database immediately.  An admin will need to verify your pet before it is added.</i></b></p>\n");     }     else     {        print("\n<p><b><i>Add FAILED for pet $new_pet <br><br>Please check that your pet is not in the adopted<br>section before contacting a FAERIE FEEPIT admin.</i></b></p>\n");     }   } else if (userlevel() <= 9) { print ("<center>You cannot add pets after being banned from the database."); print ("</div><div id=\"rightcontent\">"); print_right_loginbar(); print ("</div></body>"); print ("</html></center>"); exit; } ?> The rest of the page coded here.[/code] So when some users are logging in while their userlevels are 10, they are finding that they have been 'banned' from the site (are getting that banned message).  However, when I log into their accounts, I am able to add pets and not get that banned message.  I have no clue why the same accounts would be banned for them and not for me.. and why users with userlevels of 10 would even ever get that error message.  I've been at this for a month, so really, any insight you can give me would be MUCHLY appriciated. Thanks.
  6. I created the table character, which has the following info: [code]`id` int(11) NOT NULL auto_increment,   `character` varchar(255),   PRIMARY KEY  (`id`)[/code] However, I later realized that I wanted the column character to be called description so it matched up with some of my other tables.  So using this code: [code]$sql = "ALTER TABLE `character` CHANGE `character` `description` varchar(255)"; mysql_query($sql) or DIE (mysql_error());[/code] I attempted to do that.  I received no error messages so I assumed everything was fine... however, when I plugged in this code: [code]$result = mysql_query("DESCRIBE `character`");   while ($row = mysql_fetch_array($result, MYSQL_NUM)) {     printf("%s %s", $row[0], $row[1]);   echo"<br>";   }     mysql_free_result($result) OR DIE (mysql_error());[/code] It was still displaying the following info, even after I refreshed a few times: [quote] id int(11) character varchar(255) [/quote] Instead of: [quote] id int(11) description varchar(255) [/quote] I dont have access to my server directly, so I have to make these adjustments via PHP.  I'm really hoping that someone can help me.  Thanks SO much!
  7. Hm, okay that got it to connect, but now I'm getting: Incorrect table definition; there can be only one auto column and it must be defined as a key
  8. No database selected Why would it be giving me that?  I'm only connecting to the one database, and the username and password and all that are correct.. copied and pasted from another page that works.
  9. Alright, I must have read through the syntax for creating a table in mysql a thousand and one times, but I cannot figure out what is wrong with my code.  I'm hoping another pair of eyes can help me. [quote] $database=mysql_connect("localhost","username","password"); $result=mysql_query("CREATE TABLE `poll` (   `id` int(11) NOT NULL auto_increment,   `name` varchar(50) default NULL,   `question` varchar(255) default NULL,   `bgcolor` varchar(20) default NULL,   `fontsize` varchar(10) default NULL,   `font` varchar(50) default NULL,   `fontcolor` varchar(20) default NULL,   `orientation` varchar(100) default NULL,   `tbgcolor` varchar(20) default NULL,   `tfontsize` varchar(10) default NULL,   `tfontcolor` varchar(20) default NULL,   `tfont` varchar(50) default NULL,   `votes` int(11) default '0')");   if ($result) { echo "Table Created!"; } else print "Error"; [/quote] No matter what I do, I keep getting "Error".  And I know the table hasn't already been created because when I plug it into this code: [quote] $result = mysql_query("DESCRIBE poll");   while ($row = mysql_fetch_array($result, MYSQL_NUM)) {     printf("%s %s", $row[0], $row[1]);   echo"<br>";   }     mysql_free_result($result); [/quote] I get a blank page, even though when I test it on a table that I know already exsists, it gives me the feedback I'm looking for (the names of all the columns in the specified table). Can someone please help? (And unfortunatly, no, I don't have access to my server itself, so I do need to create the tables in PHP)
  10. [code]function get_ip () { $ip = ! empty ( $_SERVER['CLIENT_IP'] ) ? $_SERVER['CLIENT_IP'] : ''; $ip = ! empty ( $_SERVER['HTTP_CLIENT_IP'] ) ? $_SERVER['HTTP_CLIENT_IP'] : $ip; if ( ! empty ( $_SERVER['HTTP_X_FORWARDED_FOR'] ) && preg_match_all ( '#\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}#s', $_SERVER['HTTP_X_FORWARDED_FOR'], $f ) ) { foreach ( $f[0] AS $id ) { if ( ! preg_match ( "#^(10|172\.16|192\.168)\.#", $id ) ) { $ip = $id; break; } } } $ip = ! empty ( $_SERVER['REMOTE_ADDR'] ) && empty ( $ip ) ? $_SERVER['REMOTE_ADDR'] : $ip; return $ip; } function ip_check() { $myip = get_ip(); $addr = mysql_db_query("blah","SELECT ip FROM bans;"); while ($ip = mysql_fetch_assoc($addr)) { $banned_ip = $ip['ip']; if(strstr($myip,$banned_ip)) {   print ("Error message");   exit;   } } }[/code] That's not working..
  11. So I can still have admins enter IPs on the webpage itself? I actually don't have access to the database, my webhost only gives me access to the code itself, so I just get to work with what I have.  All I know is the table is bans and the field is ip... would you need more information than that? :/ (But if you can't do it from what I have, the current way I have it works, so I'm okay either way :P) ======== That code you just added... so whole thing would take the place of $myip = $_SERVER['REMOTE_ADDR'];? Sorry, I'm confused now :(
  12. Ohoh!  Figured it out.  Thanks SO much! Topic closed.
×
×
  • 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.