-
Posts
2,000 -
Joined
-
Last visited
-
Days Won
1
Everything posted by Andy-H
-
If I blacklist proxys it denies access for AOL users, that could be a pretty big user loss and I duno if they use proxys, he said they change their IP so it could be either.
-
A friend of mine has a game with two really annoying users which he IP banned, however they keep accessing his site via proxy's or changing their IP. Is there a better way to get rid of them? I have already been researching and found the function gethostbyaddr(), would banning that just affect them? Thanks for replys.
-
[SOLVED] A function is trying to redeclare itself on top of itself
Andy-H replied to jordanwb's topic in PHP Coding Help
Use include_once -
I see (said the blind man who couldn't see at all), lol. I took your advice on the return part and am looking into the extract function (after I go for a smoke lol) as I have never heard of it. Thanks for the help =D
-
<?php require_once("db_conn.inc"); $username = mysql_real_escape_string($_SESSION['username']); function userVars($vars){ if ( !is_array($vars) ){ trigger_error( $vars . ' - Invalid input for function(userVars), please use arrays only...' ); }else{ if ( count($vars) == 0 ){ trigger_error( $vars . ' - Array empty, non-usable for function(userVars).'); }else{ $string = implode(",", $vars); $_query = "SELECT " . $string . " FROM users WHERE username = '" . $username . "' LIMIT 1"; $_result = mysql_query($_query)or trigger_error('Query failed in function(userVars).'); global $_userVars = mysql_fetch_row($_result); } } } ?> Any better??? //////////////////////////////////////////// IMO you should simply be returning the array of information - i'm not sure why you'd put it into a global variable. furthermore, leaving it as a numerically-keyed array doesn't really help, nor does extracting into local variables. /////////////////////////////////////////// I dont really know what you mean by that? :S I wrote the function because I'm lazy and I though it would be an easier way to run my querys that I would use alot. With them being numerically keyed, the array would be defined in the script which the function is used in so it wouldnt be so hard to refer to...
-
I did have the $_query and $_result variables declared as global scope originally but wasnt sure if this was neccessary and removed them. ???
-
OK, I don't have this script running, I was just curious to weather it would work because I may use it in future projects if it does. Also if you see any bad practice in the code please let me know. Ok, so imagine this file is "req/functions.inc" and there is a db connection file called "req/db_conn.inc". <?php require_once("db_conn.inc"); $username = (string)mysql_real_escape_string($_SESSION['username']); function userVars($vars){ global $username; if ( !is_array($vars) ){ echo $vars . ' - Invalid input for function(userVars), please use arrays only...'; }else{ $num = (int)count($vars); for ($i = 0; $i < $num; $i++){ $string .= $vars[$i] . " , "; } $_query = "SELECT " . $string . " FROM users WHERE username = '" . $username . "' LIMIT 1"; $_result = mysql_query($_query)or trigger_error('Query failed in function(userVars).'); global $_userVars = mysql_fetch_row($_result); } } ?> And this is some file I need to fetch the users info in... <?php require_once("req/functions.inc"); $_vars = array("username", "password", "email", "money", "status"); userVars($_vars); $realname = $_uservars[0]; $pass = $_userVars[1]; $email = $_userVars[2]; $money = $_userVars[3]; $status = $_userVars[4]; ?>
-
:s my bad, long time since I used implode/explode lol
-
Ooh, that is slick! Yeh I just tested it and it worked, but I dont get how imploding an array works :S
-
Line breaks lol
-
You can redirect it to page.php#errors and add else { echo '<div align="center" name="errors">The following errors have occurred:<br /><br />'; for ($i=0; $i < count($errors); $i++){ echo '<font color="red">' . $errors[$i] . '</font><br />'; } echo '</div>'; } } ?>
-
<?php $array = array('Dogs', 'Cats', 'Squirrels', 'Mice', 'Rats'); for ($i = 0; $i < count($array); $i++){ $n = $i + 1; echo $n . '.' . $array[$i] . '<br />'; } ?> Personally I would do it that way...
-
Where is the data coming from, an array? A database? If a database is it stored in seperate fields, exploded from one field??? Please give more info...
-
<?php if (isset($_POST['submit'])) { // Get Information from form $FirstName=$_POST['requiredFirstName']; $MiddleInitial=$_POST['requiredMiddleInitial']; $LastName=$_POST['requiredLastName']; $TelephoneNumber=$_POST['requiredTelephoneNumber']; $EmailAddress=$_POST['requiredEmailAddress']; $HomeAddress=$_POST['requiredHomeAddress']; $SecurityClearance=$_POST['requiredSecurityClearance']; $Education=$_POST['requiredEducation']; $ProfessionalExperience=$_POST['requiredProfessionalExperience']; $ProfessionalLicenses=$_POST['requiredProfessionalLicenses']; $ComputerProficiency=$_POST['requiredComputerProficiency']; $Miscellaneous=$_POST['Miscellaneous']; $errors = array(); $EmailAddress = trim($EmailAddress); $_name = "/^[-!#$%&\'*+\\.\/0-9=?A-Z^_`{|}~]+"; $_host = "([-0-9A-Z]+\.)+"; $_tlds = "([0-9A-Z]){2,4}$/i"; if (trim($_POST['requiredFirstName']) == "") { $errors[] = "First name is required."; } if (trim($_POST['requiredMiddleInitial']) == "") { $errors[] = 'You did not fill in your middle initial.'; } if (trim($_POST['requiredLastName']) == "") { $errors[] = 'You did not fill in your last name.'; } if (trim($_POST['requiredTelephoneNumber']) == "") { $errors[] = 'You did not fill in your telephone number.'; } if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['requiredEmailAddress'])){ $errors[] = "The email you have entered is not a valid email format."; } if (trim($_POST['requiredEmailAddress']) == ""){ $errors[] = 'You did not fill in your email address.'; } if (trim($_POST['requiredHomeAddress']) == "") { $errors[] = 'You did not fill in your home address.'; } if (trim($_POST['requiredEducation']) == "") { $errors[] = 'You did not fill in the education field.'; } if (trim($_POST['requiredProfessionalExperience']) == "") { $errors[] = 'You did not list your professional experience.'; } if (trim($_POST['requiredProfessionalLicenses']) == "") { $errors[] = 'You did not list your professional licenses and certifications.'; } if (trim($_POST['requiredComputerProficiency']) == "") { $errors[] = 'You did not state your computer proficiency.'; } if (count($errors) == 0) { // no errors, send emails //verify EmailAddress is actually valid $to = "[email protected]"; $subject = "Online Resume Submittion"; $EmailAddress=$_POST['EmailAddress'];//reset EmailAddress $from = "From: ".$EmailAddress; $message = "First Name: \n".$FirstName." "; $message .= "\n\n\nMiddle Initial: \n".$MiddleInitial." "; $message .= "\n\n\nLast Name: \n".$LastName." "; $message .= "\n\n\nTelephone Number: \n".$TelephoneNumber." "; $message .= "\n\n\nEmail Address: \n".$EmailAddress." "; $message .= "\n\n\nHome Address: \n".$HomeAddress." "; $message .= "\n\n\nSecurity Clearance: \n".$SecurityClearance." "; $message .= "\n\n\nEducation: \n".$Education." "; $message .= "\n\n\nProfessional Experience: \n".$ProfessionalExperience." "; $message .= "\n\n\nProfessional Licenses: \n".$ProfessionalLicenses." "; $message .= "\n\n\nComputer Proficiency: \n".$ComputerProficiency." "; $message .= "\n\n\nMiscellaneous: \n".$Miscellaneous." "; mail($to, $subject, $message, $from); //Send Email echo "Thank you for your application, we will be in contact with you shortly if you meet the job description requirements."; echo '<meta content="4; URL=index.htm" http-equiv="Refresh" />'; //go back to homepage after they read the thank you message } else { echo '<center>The following errors have occurred:<br /><br />'; for ($i=0; $i < count($errors); $i++){ echo '<font color="red">' . $errors[$i] . '</font><br />'; } echo '</center>'; } } ?>
-
add this to your script (above where you call the alert() functions): function alert($msg){ $msg = htmlentities($msg, ENT_QUOTES); if (!empty($msg)){ echo '<script type="text/javascript"> alert("Error: ' . $msg . '") </script>'; }} EDIT: NVM that was for your original script lol
-
You wouldnt need to echo the function in the second example, it is already echoed within the function so to get the output of 2 it would simple be: add(1,1);
-
Thanks Not sure weather to carry on with it lol I'm sick of text based games now but cant think of any decent site ideas...
-
thanks,getting lazy coding :| lol
-
Does index1.php happen to have the lines: if ( (!session_is_registered("myusername")) || (!session_is_registered("mypassword")) ){ Header("Location: index.php"); } If so change it to: if ( (empty($_SESSION["myusername"])) || (empty($_SESSION["mypassword"])) ){ Header("Location: index.php"); } Why do you have their password as a session variable anyway? You also need to update the timeout as every page loads...
-
[SOLVED] Column count doesn't match value count at row 1 please help
Andy-H replied to fantomel's topic in PHP Coding Help
$sql = mysql_query("INSERT INTO `news_comments` VALUES ('$id', '$name', '$comment', '$date', '$ip')") or die(mysql_error()); Is it that? -
NVM lol User Rating: 952 | Rate This User Report this Post to a Moderator | Link Sander Moderator - Web Development Member since: 4/19/2002 From: Den Bosch, Netherlands Posted - 10/31/2005 1:36:42 AM I think I got it. libxlst needs to be installed on your server (ask your admin) and it needs to be enabled in the PHP configuration. Create a file with only the phpinfo() command and see if the --with-xsl configuration directive is set. If not, then the XLST processor is not available. Bug your admin to enable it.
-
I have downloaded and installed the Orca 1.1 AJAX forum script but it had a few errors, I have fixed a couple but am stuck at this one... Fatal error: Class 'XsltProcessor' not found in /usr/home/mafiaworld/domains/mafia-world.net/public_html/hooligan/forum/classes/BxXslTransform.php on line 91 <?php if (((int)phpversion()) >= 5) { $xml = new DOMDocument(); $xml->loadXML($this->_xml); $xsl = new DomDocument(); $xsl->load($this->_xsl); $proc = new XsltProcessor(); /// line 91 $proc->importStyleSheet($xsl); $res = $proc->transformToXML($xml); } ?> I have echoed the PHP version as an integer to check and it came up as 5, any help apperciated... =P
-
Or it can be a result of a mysql_fetch_object() call... $query = mysql_query("SELECT * FROM table WHERE field = '$value' LIMIT 1")or die(mysql_error()); $fetch = mysql_fetch_object($query); $someVar = $fetch->someField;
-
Yes, both varchar(255) and I added it to that script 4 u...
-
if ($killss > 5){ $kills = 5; } $bulletneed = abs((($drankpos + 4) / ($rankpos + 4)) * ((((30000 - ($kills * 1000)) - ($wep * 1000)) + ($def * 1000)))); $new = ($bulls / $bulletneed) * 100; $newhealth = round($health - $new); That was my formula for my old mafia game... $drankpos = defender rank position, $rankpos = attacker rankposition, $bulls = bullets shot Rank positions were 1-22... Weapon/Protection were 0-4