PHP - I Think Is Php Code Is Causing A Bug In My Application
So I have an webapp which has a built in proxy checker. However because I didn't write the code I am kind of confused on whats going on. I have a small amount of knowledge on php been looking all over the net to find a solution. So this file called (proxy_check.php) keeps causing my index.php to show the 404 designed page. The file is required in the index.php file. I believe its something to do with the $reponse variable. Please help <?php # Visitor proxy check snippet $v_ip = $_SERVER['REMOTE_ADDR']; $arContext['http']['timeout'] = 10; $context = stream_context_create($arContext); $response = file_get_contents('http://www.shroomery.org/ythan/proxycheck.php?ip='.$v_ip, 0, $context); if ('Y' === $response) { echo "<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'> <meta http-equiv='Content-Type' content='text/html;charset=UTF-8'> <head> <title> The page you were looking for doesn't exist (THIS BUG)</title> <style type='text/css'> body { background-color: #efefef; color: #333; font-family: Georgia,Palatino,'Book Antiqua',serif;padding:0;margin:0;text-align:center; } p {font-style:italic;} div.dialog { width: 490px; margin: 4em auto 0 auto; } img { border:none; } </style> </head> <body> <div class='dialog'> <a><img src='assets/img/404.png'></a> <p>It looks like that page you were looking has been mislaid, sorry.</p> </div> </body> </html>"; die(); }
Similar TutorialsI've been developing a php application that runs my entire company for the last 4 years. One of the things I never thought of until now is that the server guys or anyone else could copy the source code and db and be able to start up another company which brings up my question to you.... How would you protect your application? My thought is to create one small php file that is encrypted with something that is required to make the entire site run (not sure at this point what it would be that they couldn't just rebuild). Then if this file sees it's on a different domain/ip it requests data from my site which logs the info for me to look at. If I find out it's something not approved, it would then not allow the program to run and will give a error. What is your idea? Hey, I'm writing an application that tracks attendance. There are multiple events ('events' table), in which members that are present will be found. (When an event file is uploaded, it has all members that attended the event, and adds the event entry in 'events', as well as adding each member to the 'attendance' table, with event_id(eid) and the 'did_attend' value as '1'. When the event is edited, it needs to find the other members that AREN'T in the events table, and add them to the 'attendance' table. When I use this code, it apparently keeps adding the same members. Will a LIMIT 1 stop this? I has about 65,000+ entries added before I stopped the execution of the script. Thanks! Code: [Select] $sql2 = mysql_query("SELECT * FROM members WHERE status=1 ORDER BY mid ASC"); while($row = mysql_fetch_assoc($sql2)){ $sql3 = mysql_query("SELECT * FROM attendance WHERE event='$eid' ORDER BY member ASC"); while($row2 = mysql_fetch_assoc($sql3)){ if($row2[mid] == $row[mid]){ // if the member is in the attendance db, skip }else{ //if member is not in attendance, write zero--- causing multiple entries (50,000+) $qry = mysql_query("INSERT INTO attendance (member,event,did_attend) VALUES ('$row[mid]','$eid','0')"); if(!$qry){ die("SQL: ".mysql_error()); }else{ $msg = "<br />Member ".$row[mid]." marked as absent."; } } } }
I have this function which works except it throws a Notice regarding the 3rd line of the function. The Notice reads "Only variables should be passed by reference..." What am I doing wrong in that 3rd line—$caller = next(debug_backtrace()) [‘function’]; ? //EMAIL_ADMIN //Sends email to site admin if email testing services fail. //Only occurs if both primary and secondary services have failed. //Calls no other function. //Called by test_email function. //*************************************************************** function email_admin($email){ global $full_site_url;//used in links. global $site_title;//used in confirmation messages. $caller = next(debug_backtrace())['function']; //assigns calling function name to $caller. if ($caller == 'alt_test_email'){ //used in email message to provide links for checking services. $primary_service = 'http://www.quickemailverification.com';//used in email message. $secondary_service = 'http://www.neverbounce.com';//used in email message. $to = get_bloginfo('admin_email'); $subject = 'EMAIL TESTING SERVICES HAVE FAILED!'; $message = 'Both email testing services have failed. Go to ' . $primary_service . ' and ' . $secondary_service . '.'; dw_send_email($to, $subject, $message);//call email sending function. } if ($caller == 'unsubscribe'){ $to = get_bloginfo('admin_email'); $subject = $site_title . " unsubscribe"; $message = $email . " has unsubscribed."; dw_send_email($to, $subject, $message);//call email sending function. } if ($caller == 'subscribe_form_display'){ $to = get_bloginfo('admin_email'); $subject = "New " . $site_title . " subscriber"; $message = $email . " has subscribed to " . $site_title . "."; dw_send_email($to, $subject, $message);//call email sending function. } }
I have several pages on my site using the exact same code at the very top, which works fine except for one page: <?php include_once("../members/dbinfo.php"); The top of dbinfo looks like this: <?php session_start(); And then the connection strings for the database However it is giving me this error on this one page: Quote Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\Inetpub\WebSites\premierathome_com\products\FrenchTalkingDictionary.php:1) in C:\Inetpub\WebSites\premierathome_com\members\dbinfo.php on line 1 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\Inetpub\WebSites\premierathome_com\products\FrenchTalkingDictionary.php:1) in C:\Inetpub\WebSites\premierathome_com\members\dbinfo.php on line 1 Now the session does actually start and doesn't prevent anything from working, I just get those messages. I'm at a loss as to why a different page with the exact same code, save for searching the database for a different product version would have this problem. I have had this code in place as well which works fine on other pages but doesn't help my problem at all: if(!isset($_SESSION['OK'])){ session_start(); } OK being a variable I set up during log in. I'm at a loss, is anyone able to help me out with this? Okay, I have no idea how this works out but this is really getting on my nerves. Here is my logic for the following code. I manually register a user, It goes into the database and dispatches an email notification explaining that a user must activate their account and change their user name (OPTIONAL) and password. In the email, There is an automatically generated password with the username, And a link to activate the account. This leads to stage 1 of the activation process, In this stage the user is accepted, Registered as a verified user and then is sent to another page to change the details like login and password. As far as I know this page works except through trial and error I found that this little snippet of code is causing browsers to show an error 500 page, If I remove this the page works: <?php if($messages){ displayErrors($messages); } else { echo("<p align=\"center\" class=\"standard\">Your account has been activated.</p><p align=\"center\" class=\"standard\">You now need to change your password. If you like you can also change your username, Remember that you only have 3 days to do so and this change will be permanent.</p>"); } ?> and this is the displayErrors function: <?php function displayErrors($messages) { print("<p align=\"center\" class=\"standard\">"."<b>There were problems with the previous action:</b>\n<ul>\n"); foreach($messages as $msg){ print("<li>$msg</li>\n"); } print("</ul>\n"."</p>"); } ?> The displayErrors function is in a file called functions.php, Which is included in config.php, Which is included in every page including this one. The entire "Change password and login page thingie" is he <?php include("config.php"); global $link, $messages; require_once('recaptchalib.php'); if($_GET['error']){ $id=$_GET['id']; $messages[]="There is more than one or no accounts with the verification code you are using. <a href=\"mailto:rentals@nivso.co.uk?subject=Two or no accounts with activation ID of $id\">Click here to email us about this and have the problem sorted.</a>"; doIndex(); exit; } if(isset($_POST['submit'])){ if(!isset($_POST['activationid'])){ die("Doesn't exist -.- might as well quit this is *STUFF* -.-"); } $privatekey = "YOUR NOT HAVING THIS"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { $messages[]="The code you entered is incorrect. Please go back and try again!"; doIndex(); exit; // exit or the below lines will be processed. } else { //This is where the fun starts! $login=$_POST['login']; $passw=$_POST['password']; $passc=$_POST['passwordc']; $id2=$_POST['activationid']; $changinglogin=false; $get1=excDB("SELECT * FROM `users` WHERE `activeID`='$id2'"); if($get1[0]){ $get1=$get1[1]; } else { die($get1[2]); } $pro1=mysql_fetch_array($get1); if($pro1['login']!=$login){ $changinglogin=true; field_validator("Login", $login, "alphanumeric", 4, 15); } field_validator("Password", $passw, "string", 6, 20); if($passw!=$passc){ $messages[]="The passwords do not match, Please make sure that the passwords are the same!"; } if($messages){ doIndex(); exit; } $passcl=mysql_escape_string($passw); $passen=md5($passcl); if($changinglogin){ $wri1=excDB("UPDATE `users` SET `login`='$login', `password`='$passen', `passchange`='1', `loginchange`='1' WHERE `activeID`='$id2';"); if($wri1[0]){ $wri1=$wri1[1]; } else { die($wri1[2]); } header("Location: login.php?created"); } else { $wri1=excDB("UPDATE `users` SET `password`='$passen', `passchange`='1', `loginchange`='0' WHERE `activeID`='$id2';"); if($wri1[0]){ $wri1=$wri1[1]; } else { die($wri1[2]); } header("Location: login.php?created2"); } } } else { doIndex(); } function doIndex(){ ?> <!DOCTYPE html> <head> <title>Family Rental System! - Rent your DVDs here - Design by Alex, Coding by Gergy008</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link type="text/css" href="css/main.css" rel="stylesheet"> <style type="text/css"> <!-- body { background-color: #333333; } --> </style></head> <body style="text-align:center;"> <div class="first"> <div class="backgrounder1"></div> <div class="headerbar1"></div> <div class="headerbar2"></div> </div> <div align="center"> <table border="0" cellpadding="0" cellspacing="0" width="900"> <tr> <td><img src="images/spacer.gif" width="52" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="123" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="352" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="33" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="55" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="110" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="110" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="50" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="15" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="1" height="1" border="0" alt="" /></td> </tr> <tr> <td colspan="9" background="images/template.slice.1.png"> </td> <td><img src="images/spacer.gif" width="1" height="20" border="0" alt="" /></td> </tr> <tr> <td colspan="5" background="images/template.slice.2.png"> </td> <td colspan="2" rowspan="2" background="images/template.slice.3.png"><span class="login"><?php echo(loginHandler()); ?></span></td> <td colspan="2" rowspan="3" background="images/template.slice.4.png"> </td> <td><img src="images/spacer.gif" width="1" height="30" border="0" alt="" /></td> </tr> <tr> <td rowspan="8" background="images/template.slice.5.png"> </td> <td colspan="2" background="images/template.slice.6.png"><form> <div align="center"> <input name="textfield" type="text" id="textfield" size="40" style="height:16px;"> <input type="submit" name="button" id="button" value="Search" style="height:20px;"> </div> </form></td> <td colspan="2" rowspan="2" background="images/template.slice.7.png"> </td> <td><img src="images/spacer.gif" width="1" height="30" border="0" alt="" /></td> </tr> <tr> <td colspan="2" rowspan="3" background="images/template.slice.8.png"><p> </p> <p> </p></td> <td colspan="2" background="images/template.slice.9.png"> </td> <td><img src="images/spacer.gif" width="1" height="70" border="0" alt="" /></td> </tr> <tr> <td rowspan="2" background="images/template.slice.10.png"> </td> <td colspan="4" background="images/template.slice.11.png"> </td> <td rowspan="6" background="images/template.slice.12.png"> </td> <td><img src="images/spacer.gif" width="1" height="30" border="0" alt="" /></td> </tr> <tr> <td colspan="4" background="images/template.slice.13.png"></td> <td><img src="images/spacer.gif" width="1" height="8" border="0" alt="" /></td> </tr> <tr> <td rowspan="4" background="images/template.slice.14.png"> </td> <td colspan="4" background="images/template.slice.15.png"> </td> <td colspan="2" rowspan="4" background="images/template.slice.16.png"> </td> <td><img src="images/spacer.gif" width="1" height="35" border="0" alt="" /></td> </tr> <tr> <td colspan="4" background="images/template.slice.17.png"> </td> <td><img src="images/spacer.gif" width="1" height="37" border="0" alt="" /></td> </tr> <tr> <td colspan="4" align="center" valign="top" background="images/template.slice.18.png" style="vertical-align:top;"><p class="standard"> </p> <table width="80%" border="0"> <tr> <td colspan="2"> <?php if($messages){ //displayErrors($messages); } else { //echo("<p align=\"center\" class=\"standard\">Your account has been activated.</p><p align=\"center\" class=\"standard\">You now need to change your password. If you like you can also change your username, Remember that you only have 3 days to do so and this change will be permanent.</p>"); ?></td> </tr> <form name="ChangeDetails" method="post" action="<?=$_SERVER['PHP_SELF']?>"> <input type="hidden" name="activationid" value="<?php if($_GET['id']){ $id=$_GET['id']; echo($id); } elseif($_POST['activationid']){ $id=$_POST['activationid']; echo($id); } else { die("No ID") } ?>" /> <tr> <td width="50%"><div align="right" class="standard">New Username: </div></td> <td width="50%"><input name="login" type="text" id="login" size="35" maxlength="30" /></td> </tr> <tr> <td><div align="right" class="standard">New Password:</div></td> <td><input name="password" type="password" id="password" size="35" maxlength="30" /></td> </tr> <tr> <td><div align="right" class="standard">Re-enter password:</div></td> <td><input name="passwordc" type="password" id="passwordc" size="35" maxlength="30" /></td> </tr> <tr> <td><div align="right" class="standard">Please enter the code: </div></td> <td> <?php require_once('recaptchalib.php'); $publickey = "6Le4fsESAAAAAKMOHb8aaiyDfGRJyr0y0EU7dXm-"; // you got this from the signup page echo recaptcha_get_html($publickey); ?> </td> </tr> <tr> <td> </td> <td><input type="submit" name="submit" id="submit" value="Change your details" /></td> </tr> </form> </table> </td> <td><img src="images/spacer.gif" width="1" height="450" border="0" alt="" /></td> </tr> <tr> <td colspan="4" background="images/template.slice.19.png"> </td> <td><img src="images/spacer.gif" width="1" height="50" border="0" alt="" /></td> </tr> <tr> <td colspan="9" background="images/template.slice.20.png"> </td> <td><img src="images/spacer.gif" width="1" height="40" border="0" alt="" /></td> </tr> </table> </div> </body> </html> <?php } ?> Thanks to all you kind people that take your time to read and help me with this problem. I'm sorry if it is a really simple problem I missed out that makes me look like a right idiot and wasted your time, but that's me I'm always missing stuff out like that, I do proof read though just sometimes not good enough. Thanks in advance! Hi, For about a month, I have been trying to figure out why my code will not return anything after posting a wwwForm (I have also tried the newer equivalent of this function but I had no luck with that either.) The nameField and passwordField are taken from text boxes within the game and the code used in my login script is copied and pasted from a Register script but I have changed the file location to the login.php file. The register script works fine and I can add new users to my database but the login script only outputs "Form Sent." and not the "present" that should return when the form is returned and it never gets any further than that point meaning that it lets the user through with no consequence if they use an invalid name because the script never returns an answer. What should I do to fix this? Thanks, Unity Code: using System.Collections; using UnityEngine; using UnityEngine.UI; using UnityEngine.Networking; public class Login : MonoBehaviour { public InputField nameField; public InputField passwordField; public Button acceptSubmissionButton; public void CallLogInCoroutine() { StartCoroutine(LogIn()); } IEnumerator LogIn() { WWWForm form = new WWWForm(); form.AddField("username", nameField.text); form.AddField("password", passwordField.text); WWW www = new WWW("http://localhost/sqlconnect/login.php", form); Debug.Log("Form Sent."); yield return www; Debug.Log("Present"); if (www.text[0] == '0') { Debug.Log("Present2"); DatabaseManager.username = nameField.text; DatabaseManager.score = int.Parse(www.text.Split('\t')[1]); Debug.Log("Log In Success."); } else { Debug.Log("User Login Failed. Error #" + www.text); } } public void Validation() { acceptSubmissionButton.interactable = nameField.text.Length >= 7 && passwordField.text.Length >= 8; } } login.php: <?php echo "Test String2"; $con = mysqli_connect('localhost', 'root', 'root', 'computer science coursework'); // check for successful connection. if (mysqli_connect_errno()) { echo "1: Connection failed"; // Error code #1 - connection failed. exit(); } $username = mysqli_escape_string($con, $_POST["username"]); $usernameClean = filter_var($username, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH); $password = $_POST["password"]; if($username != $usernameClean) { echo "7: Illegal Username, Potential SQL Injection Query. Access Denied."; exit(); } // check for if the name already exists. $namecheckquery = "SELECT username, salt, hash, score FROM players WHERE username='" . $usernameClean . "';"; $namecheck = mysqli_query($con, $namecheckquery) or die("2: Name check query failed"); // Error code # 2 - name check query failed. if (mysqli_num_rows($namecheck) != 1) { echo "5: No User With Your Log In Details Were Found Or More Than One User With Your Log In Details Were Found"; // Error code #5 - other than 1 user found with login details exit(); } // get login info from query $existinginfo = mysqli_fetch_assoc($namecheck); $salt = $existinginfo["salt"]; $hash = $existinginfo["hash"]; $loginhash = crypt($password, $salt); if ($hash != $loginhash) { echo "6: Incorrect Password"; // error code #6 - password does not hash to match table exit; } echo "Test String2"; echo"0\t" . $existinginfo["score"]; ?>
Hi, I need a small help. Here is my situation. I am using a MVC application (e.g. Joomla or Drupal) which has a .htaccess redirect rule that all requests are passed through index.php file. That's normal and this is my main application. Now I installed another application within the application folder structure. What I want do do here is to allow opening the third party application URLs after one logged into my main application. Can anybody provide me some pointers to do the same? Please let me know if you need any further information on this. Any solution irrespective of framework will work. Thanks! Anupam Hi, I need to develop a module called chat with doctor. User can able to chat with the doctor for that he has to pay some amount to website. Say example user got purchase the Package worth : 2$ =>5min. After 5 min chat will be closed , timer should be shown while chatting. How can we do this? I am urgently looking for a junior PHP web application developer with a portfolio of your code experience, no commercial experience will be considered to.
Please contact me to find out more!
Exciting opportunity for someone wanting to get a foot in the door in the world of IT!!
There are ten list or bookmarks from Prof. Horner's Bible-Reading System found (http://www.facebook.com/group.php?gid=46416541831) each having set number of books from the Bible. One is to read ten chapters a day, one chapter from each of the bookmarks. Type in what day you are on and the program will show you on each of the lists as to what chapter you are suppose to be on. Also want to show statistics that will display how many times the Bible has been read with a break down of all 66 books of the Bible. Started a git respo http://github.com/Kutakizukari/Prof-Horners-Bible-Reading-System Bookmark list as follows: //List 1 $Matthew = 28; $Mark = 16; $Luke = 24; $John = 21; //List 2 $Genesis = 50; $Exodus = 40; $Levitieus = 27; $Numbers = 36; $Deuteronomy = 34; //List 3 $Romans = 16; $I_Corinthians = 16; $II_Corinthians = 13; $Galatians = 6; $Ephesians = 6; $Philipians = 4; $Colossians = 4; $Hebrews = 13; //List 4 $I_Thessalonians = 5; $II_Thessalonians = 3; $I_Timothy = 6; $II_Timothy = 4; $Titus = 3; $Philemon = 1; $James = 5; $I_Peter = 5 ; $II_Peter = 3 ; $I_John = 5; $II_John = 1; $III_John = 1; $Jude = 1; $Revelation = 22; //List 5 $Job = 42; $Ecclesiastes = 12; $Songs_of_Solomon = 8; //List 6 $Psalms = 150; //List 7 $Proverbs = 31; //List 8 $Joshua = 24; $Judges = 21; $Ruth = 4; $I_Samuel = 31; $II_Samuel = 24; $I_Kings = 22; $II_Kings = 25; $I_Chronicles = 29; $II_Chronicles = 36; $Ezra = 10; $Nehemiah = 13; $Esther = 10; //List 9 $Isaiah = 66; $Jeremiah = 52; $Lamentations = 5; $Ezekiel = 48; $Daniel = 12; $Hosea = 14; $Joel = 3; $Amos = 9; $Obadiah = 1; $Jonah = 4; $Micah = 7; $Nahum = 3; $Habakkuk = 3; $Zephaniah = 3; $Haggai = 2; $Zechariah = 14; $Malachi = 4; so on day 1 it should readout Matthew Chapter 1 Genesis Chapter 1 Romans Chapter 1 I Thessalonians Chapter 1 Job Chapter 1 Psalms Chapter 1 Proverbs Chapter 1 Joshua Chapter 1 Isaiah Chapter 1 Acts Chapter 1 on the second day it should all say Chapter two but Matthew reaches day 28 it should move on to Mark Chapter 1 and so on and so on and with each bookmark list. Hi all, this is my first time on this forum! I have a background with HTML and CSS but have recently started a Masters in Computer Science hoping to come out of it with the tools to get a job with PHP development. Our first assignment has somewhat 'thrown me in the deep end' as we have to construct a search engine that indexes the words of a number of documents and rank them using the TF*IDF algorithm along with the log rule associated with Information retrieval. I am completely new to PHP so the past week has been something of a crash course - This is the code I have so far: Code: [Select] <?php $filename = 'airlines.txt'; $fp = fopen( $filename, 'r' ); $file_contents = fread( $fp, filesize( $filename ) ); fclose( $fp ); //$new_contents = ereg_replace("[^A-Za-z0-9]", "", $file_contents); /*$file_contents = trim($file_contents); $file_contents = preg_replace('/\h+/', ' ', $file_contents); $file_contents = preg_replace('/\v{3,}/', PHP_EOL.PHP_EOL, $file_contents); */ $pat[0] = "/^\s+/"; $pat[1] = "/\s{2,}/"; $pat[2] = "/\s+\$/"; $rep[0] = ""; $rep[1] = " "; $rep[2] = ""; $new_contents = preg_replace("/[^A-Za-z0-9\s\s+]/","",$file_contents); $new_contents = preg_replace($pat,$rep,$new_contents); //preg_replace('~\s{2,}~', ' ', $text); $commonWords = array('a','able','about','above'........and another few hundreds cut out of this not to hurt your eyes!); $lines = explode ( "\n", $new_contents); $lines2 = implode (" ", $lines); $words = explode ( " ", $lines2 ); $useful_words = array_diff( $words, $commonWords ); /*for($i = 0; $i < count($lines); $i++) { echo "Piece $i = $lines[$i] <br />"; }*/ for($i = 0; $i < count($useful_words); $i++) { echo "Words $i = $useful_words[$i] <br />"; } //$arr=array("blah1","blah2","blah3"); file_put_contents("demo2.txt",implode(" ",$useful_words)); //$file_c = file_get_contents("demo.txt"); //$colms = explode(",",trim($file_c)); //print_r($colms); //echo $lines[2]; ?> I've got to the stage where that strips out most of the stop words when the final array is printed, but they have been replaced with spaces or something that I have not come acoss because as you may see I had a bit of trouble originally stripping the punctuation marks. I'm hoping someone can point me in the direction as to how to organise the words I have left after the stripping of stop words which are of no use during the search. I need to store those words into another array and index them which says how many times they appear in that document. I've come across the function array array_count_values ( array $input ) on the manual but I'm not sure about the best way to use it. I've attached the files I've used if that helps. Any help would be greatly appreciated! i got this application more then 10 years, all this years nothing happend, untill prev week, someone to lazzy to filled all the info required, but after submitting the form, their uncomplete info just being printed on the database. Which mean the required field code didnt work 2 all, all this year,.. what a dissapointment. Can someone take a look at my scripts and fixed please [attachment deleted by admin] Hey all I have an error in my Facebook application and I'm not sure what's wrong (New to PHP). The error output is: Code: [Select] Warning: array_rand() [function.array-rand]: Second argument has to be between 1 and the number of elements in the array in /home/app/view.php on line 15 And the PHP lines are as follows: $friends = $facebook->api('/me/friends'); print_r(array_rand($friends, 3)); I am building program to manage payment/monthly payments. I've ran into an issue that I haven't been able to overcome and need some help. I've been lurking for a while and decided it was time to ask you guys...Here's the issue: I have a table 'payments' that contains scheduled payments that looks like: id clientid paymentduedate balance expected pending 367 112233 4/16/2011 1030.00 257.50 Y 368 112233 5/16/2011 1030.00 257.50 Y 369 112233 6/16/2011 1030.00 257.50 Y 370 112233 7/16/2011 1030.00 257.50 Y What I need to do that I haven't figured out is to adjust the expected amount according to the payment, update the status to N (not pending) without affecting the later expected payments. For example: they make a payment of $257.50, applies that to row 367, sets the status to N, but leaves the other status' to Y (for obvious reasons). the make a payment of $250.00, leaving the balance at $7.50, so lets add $7.50 to row 368, mark 367 status to N the make a payment of $300.00, leaving the expected balance at $0.00 for row 367, but adjust the balance for row 368 to $215.00 Any ideas? Thanks I typically structure my applications something like the following. I lump general functionality into a given component. For instance, I might have com_users component which deals with user administration, and implements the ability to view a list of users, view a given user, delete a user, edit a user, etc. This structure was borrowed long ago from my learning PHP Joomla days which I no longer use. index.php figures out which component is being accessed, evokes the controller which gets data from the model and sends the data to the view. The view defined in each component only deals with the central content, and mainTemplate.php deals with the peripheral. First question. Is there anything inherently wrong with this approach? Second question. I am looking to start using Twig. Would this same structure work? I would replace /var/www/html/lib/templates/mainTemplate.php with a Twig file, and replace var/www/components/component1/views/view-1-1.php, etc with Twig files which extends the main Twig template. /var/www/components/component1/controllers/controller-1-1.php /var/www/components/component1/controllers/controller-1-2.php /var/www/components/component1/models/model-1-1.php /var/www/components/component1/views/view-1-1.php /var/www/components/component2/etc/etc /var/www/html/lib/templates/mainTemplate.php /var/www/html/lib/templates/mainCSS.css /var/www/html/lib/js/someJSforAllComponents.js /var/www/html/lib/components/component1/js/someJSForComponent1.js /var/www/html/index.php My application has 3 user types. Admin , User and Super Admin. Users can register as either Admin or User. Each user type has different UI and functionality. The problem: If a particular type of user reports a problem/bug in his/her login, it is difficult to pin point to the exact problem. So if I could able to login as that user, then it will be very easy to point out the bug/problem. So I'm looking for some kind of master password. Using any username and the master password I should be able to login AS that user. Any suggestions..? I am looking to save the user's access of an application. For instance, when they log in, I create a record in the "track_login" table which includes information such as the requesting IP, the user's ID, the date, (not the user's password), etc. And then for every page they visit, I store a record in the "track_page_viewed" table which includes a FK to the "track_login" table and also includes additional information about their request.
Both the track_login and track_page_viewed tables are currently in the same database as used by the primary application.
So far, so good.
Next, I want to start tracking when a user does special tasks such as when they forget their password and request that a new one be emailed to them. Or maybe when they attempt to login with an invalid username and password. Currently, I just included another table called "track_special" which includes the data, the type of special request, etc.
Now, I am thinking of adding three other things to track:
General PHP errors
MySQL errors
Try/Catch errors which I did not expect to happen
One option is just to add these to my "track_special" table or maybe make one or three new tables in the same database.
But is this a good idea? If I have a SQL error, do I really want to store the error in the same database? Maybe I should use a separate database called "myTrackerDB", and include all the above tables in that database? Or maybe I should just write the data to a flat file, and parse the file on a regular basis, and then store the information in the database?
Please provide any recommendations, guidance, suggestions, criticism, etc. Thank you
Hello I am making a game trading web application for class. Here are the requirements: You must be able to register and log in, you must be able to list games you have to trade and games you want, you must be able to search users that want games you have and users that have games you want, you must be able to accept and make trades, on trade finalization screen you must be able to rate user 1-5, view the users shipping address, and leave a comment on the users page. You do not have to be able to view other users pages, but on your home page you must be able to view your average rating. I am the most advanced programmer in my group so this has been a little tough. I have a login page and a registration page, I have a user home page, a add games page, a view feedback/ratings page, and a my games page where you can delete games. What I'm stuck on is the page that allows you to search users by games they want and games you want, and the trade finalization page. On the search page I would like to combine the functionality of searching for users with games you want and games they want with the ability to make a trade offer. The way we have it drawn up is using radio buttons to select either show people with games I want and show people wanting my games. When one is selected it will populate a list of usersnames in a drop down menu that fit whichever choice was made. We drew up four list boxes that populate lists when we select a user name, one box populates the games they have, one populates the games they want, one populates the games I have and one populates games I want. We want to be able to select game titles and move them to a list box of games I want and another to a list box of games willing to trade, lastly a submit offer button. We are debating on if this is the best set up given the requirements needing to be met. I think there is more here than what we need, we have 1 week to do this and I am doing all the programming so I am looking for the easiest way to search users that want games I have/have games I want and display the results giving me the option to select games to trade and make an offer. We are also arguing on if we have to use JavaScript to do this or if it can all be done within php. The trade finalization page would have a drop down menu where you select the user name of completed trades and upon selection lists will be populated of games they gave, games I gave and the address to send the game. It will also have a form where we can rate the user and leave a comment. This page I need help with cause again we disagree on having to use JavaScript or not. We are using phpMyAdmin and the db tables we have a tblgame - list of games I have added tblgamestatuscode - gives game a code that determines if it is wanted, to trade, or traded tblmember - member registration tblplatform - platform the game is on (Xbox, Xbox 360, Playstation2, Playstation3, PC, and Wii) tbltransaction - date traded and a status change code tbltransactiondetail - gameID and trans ID tbltransactionparty - memberID, transID, rating, comments, status change accepted We are also using adodb. Please help if you can. I will gladly give more information if needed. |