Jump to content

xc0n

Members
  • Posts

    37
  • Joined

  • Last visited

    Never

Everything posted by xc0n

  1. thanks premiso for actially posting help instead of payign out on me like the others!, i got angry cause use were basically calling me an idiot, thsi is a help forum... @teynon: u think takeing out the quotes fixed it?? wrong buddy ill post MY code below to prive u wrong your two cents wasnt needed... @PFMaBiSmAd: you are a stain on earth! @KingPhilip: they wernt helping they were giving me shit cause im new to php this is a help forum not a dam opinion forum... so i dont need your crappy reply either. @everyone else: thanks for the help from he people who actually tried to help me and not be stuck up idiots. I had two people telling me how to fix the problem hence the errors in the code i was posting... ahhhhhh get a life. i just wanted help and the douchbags started winging about me, hence me telling them to go buy some tampons, is that really that bad? i thought the tampons would help with there pms.
  2. well u were all f#@kin wrong in the end i fixed it my self the errors in code i pasted was me editing to try new things, eg adding the "" quotes and trying new database details, ur all wingers... relax up a bit this is a help forum and what helped in the end was figuring it out myself! You all need to buy some tampons for your big vagina's.
  3. yes but either way i still get the error: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/jswebmed/public_html/SecureIT/v2/mysql.php on line 6 i get this error it has nothing to do with the database connection it has to do with: $r = mysql_fetch_assoc("$q"); so why does: $r = mysql_fetch_assoc("$q"); get the warning php error?
  4. ok below is the php <?php $user_ip = $_SERVER['REMOTE_ADDR']; $conn = mysql_connect("localhost", "user", "pass")or die("cannot connect to database"); // your database connection function $q = mysql_query("select `id` from `allowed_ips` where `validate_ip` = '$user_ip' limit 1"); mysql_select_db("database")or die("cannot select DB"); $r = mysql_fetch_assoc("$q"); @mysql_close($conn); if(!empty($r)){ // ALLOW echo "welcome"; }else{ // DENY echo "go away"; } ?> and below is database export -- -- Database: `jswebmed_test` -- -- -------------------------------------------------------- -- -- Table structure for table `allowed_ips` -- CREATE TABLE IF NOT EXISTS `allowed_ips` ( `id` int(11) NOT NULL auto_increment, `ips` varchar(20) NOT NULL default '', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; can you test it and post the correct php and mysql for me to use? ps: thanks for all the help!!!
  5. im still getting this error i tryed both ways to connect? error: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/jswebmed/public_html/SecureIT/v2/mysql.php on line 6
  6. ok now its connecting i guess but im getting this error Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/jswebmed/public_html/SecureIT/v2/mysql.php on line 6 my code is below <?php $user_ip = $_SERVER['REMOTE_ADDR']; $conn = mysql_connect("localhost", "user", "pass")or die("cannot connect to database"); // your database connection function mysql_select_db("database",$conn)or die("cannot select DB"); $q = mysql_query("select `id` from `allowed_ips` where `validate_ip` = '$user_ip' limit 1",$conn); $r = mysql_fetch_assoc($q); @mysql_close($conn); if(!empty($r)){ // ALLOW echo "welcome"; }else{ // DENY echo "go away"; } ?> and my sql is -- -- Database: `jswebmed_test` -- -- -------------------------------------------------------- -- -- Table structure for table `allowed_ips` -- CREATE TABLE IF NOT EXISTS `allowed_ips` ( `id` int(11) NOT NULL auto_increment, `ips` varchar(200) NOT NULL default '', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; -- -- Dumping data for table `allowed_ips` --
  7. i get a white page saying "cannot select DB"
  8. ok thats easy! but i cant connect to my database <?php $user_ip = $_SERVER['REMOTE_ADDR']; $conn = mysql_connect("localhost", "user name", "database pass")or die("cannot connect to database"); // your database connection function mysql_select_db("database name")or die("cannot select DB"); $q = mysql_query("select `id` from `ips` where `validate_ip` = '$user_ip' limit 1",$conn); $r = mysql_fetch_assoc($q); @mysql_close($conn); if(!empty($r)){ // ALLOW echo "welcome"; }else{ // DENY echo "go away"; } ?>
  9. yea i was going to include the ip's in a file but i thought using a database was more secure? is this true or am i better off just leaving the ip's in a included file? also if i do use a database where would i add in the connection settings eg: localhost user pass and db name? and is it hard to use md5 to encrypt the ips
  10. ahh yes i see, great it worked thanks alot for that !!! how hard would it be for me to request the allowed ip's from a database so its more secure? ill put my whole code below <?php $validate_ip = ($_SERVER['REMOTE_ADDR']); $user_ip = array('110.33.251.66','110.33.251.50'); if(in_array($validate_ip,$user_ip)){ ?> you are allowed <?php } else { ?> go away your not allowed <?php } ?>
  11. hey thanks it helped a bit but im getting a syntax error on this line >> if(in_array($userIP,$allowedIPS);{
  12. hey guys im new to php so dont laugh, i cant get the following code to work <?php $user_ip == "110.00.00.00" || $user_ip == "110.00.00.00"; ?> another file requires $user_ip to be one of the above, it works with just one ip but i want to have multiple ips without having to have $user_ip2 i want $user_ip to have multiple ip's. Hope this makes sense!
×
×
  • 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.