PHP - Called Value Functions Different From Calling Values
Hi I call a function with values of 51 and 100 but the function receives values 1 and 50
<?php // EmilyMoor Version 1.0.0 05-07-2019 Desmond O'Toole. ini_set('display_errors', 1); error_reporting(E_ALL); require("../secure/SecureFunctions.php"); require("secure/SecureFunctionsEmilyMoor.php"); $page = "Emily Moor"; session_start(); $Browser = $_SERVER['HTTP_USER_AGENT']; if (!isset($_SESSION["PageValue"])) $_SESSION["PageValue"] = '1'; $_SESSION["PageValue"] = 2; // Keeps going back to 1 if($_SESSION["PageValue"] == 1) { $_SESSION["StartValue"] = 1; $_SESSION["EndValue"] = 50; } if($_SESSION["PageValue"] == 2) { $_SESSION["StartValue"] = 51; $_SESSION["EndValue"] = 100; } if($_SESSION["PageValue"] == 3) { $_SESSION["StartValue"] = 101; $_SESSION["EndValue"] = 150; } if($_SESSION["PageValue"] == 4) { $_SESSION["StartValue"] = 151; $_SESSION["EndValue"] = 200; } if($_SESSION["PageValue"] == 5) { $_SESSION["StartValue"] = 201; $_SESSION["EndValue"] = 250; } if($_SESSION["PageValue"] == 6) { $_SESSION["StartValue"] = 251; $_SESSION["EndValue"] = 300; } echo $_SESSION["PageValue"] . " - " . $_SESSION["StartValue"] . " - " . $_SESSION["EndValue"] . "<br>"; $qStationDetails = GetChanelInfo($_SESSION["StartValue"],$_SESSION["EndValue"]); $rs = mysql_fetch_array($qStationDetails) or die ("E3001-101A"); $Name = $rs['Description']; ?> function GetChanelInfo($StartCH, $EndCH) // E2004 { echo "Channels = " . $StartCH . " " . $EndCH . "<br>"; // values are 1 and 50 $sqlChanelInfo = "SELECT * FROM TV_EmilyMoor WHERE ID >= $StartCH and ID <= $EndCH"; echo $sqlChanelInfo . "<br />"; $qChanelInfo = mysql_query($sqlChanelInfo) or die ("E3004-01A"); return $qChanelInfo; }
Similar TutorialsI have this script Code: [Select] <?php header("content-type: image/png"); include '../../api/config.php'; include "../../api/api.php"; $gamercard = getInfo($_GET['gamertag']); updateStats($gamercard['Gamertag'], "Nxe", 75); $type = $_GET['type']; switch ($type) { case "dark": $type = "dark.png"; break; case "light": $type = "light.png"; break; default: $type = "dark.png"; break; } $image = imagecreatefrompng("$type"); $img = imagecreatetruecolor(imagesx($image), imagesy($image)); $avatar_l = imagecreatefrompng($gamercard["Avatarpic-l"]); $avatar_body = imagecreatefrompng($gamercard["Avatarpic-body"]); imagecopy($img, $image, 0, 0, 0, 0, imagesx($image), imagesy($image)); imagecopy($img, $avatar_l, 64, 7, 0, 0, imagesx($avatar_l), imagesy($avatar_l)); imagecopy($img, $avatar_body, 175, -40, 0, 0, imagesx($avatar_body), imagesy($avatar_body)); for($i = 1; $i <=count($gamercard["RecentGames"]); $i++) { $gameimg = imagecreatefromjpeg($gamercard["RecentGames"][$i]["Icon"]); $x = ($i-1)*35 + 10; imagecopy($img, $gameimg, $x, 77, 0, 0, imagesx($gameimg), imagesy($gameimg)); } $ColorText = imagecolorallocate($img, 255, 255, 255); ImageTTFText($img, 10, 0, 10, 127, $ColorText, "font.ttf", $gamercard['Gamertag']); ImageTTFText($img, 10, 0, 135, 127, $ColorText, "font.ttf", $gamercard['Gamerscore']); imagepng($img); imagedestroy($img); ?> which is made to call the updateStats() function 1 time everytime the page loads. Heres the function (its in api.php) Code: [Select] function updateStats($gamertag, $type, $size) { $query = mysql_query("SELECT * FROM loadstats where Gamertag = '$gamertag' && Type = '$type'") or die(mysql_error()); $exists = mysql_num_rows($query); if ($exists == 0) { mysql_query("INSERT INTO loadstats (Gamertag, Type, Loads, Data) VALUES('$gamertag', '$type', '1', '$size' )") or die(mysql_error()); } else { $row = mysql_fetch_array($query); $newloads = $row['Loads'] + 1; $newdata = $row['Data'] + $size; mysql_query("UPDATE loadstats SET Loads = '$newloads' WHERE gamertag = '$gamertag' && Type = '$type'") or die(mysql_error()); mysql_query("UPDATE loadstats SET Data = '$newdata' WHERE gamertag = '$gamertag' && Type = '$type'") or die(mysql_error()); } } The wierd thing that is happening is, When i have the Header() set in the script, the updateStats() function appears to be called twice, but when the header is commented out, it is only called once. I can tell this by the change of data in the MYSQL database, the Loads value increases by 2 when the header is set, and it only creases by 1 when it isnt set. Any insight as to why this is happening would be greatly appreciated. I teaching myself php, but I am coming from java and other compiled languages, so the process has been a little bumpy. I am trying to do something like this: Code: [Select] class my_class { function one () { $two = two (); $three = three (); $five = $two + $three; return $five; } function two () { $two = 2; return $two; } function three () { $three = 3; return $three; } } Unfortunately, I keep getting an error message saying that my call to two () is an undefined function. I am gathering from this that the scope of one () is not aware of the existence of two (). Is there a way to get around this so I can call two () and three () from one ()? I have a user form with a dete button on a dropdown. When you click said button this runs function deleteUser(){ var e = event.target var uid = e.getAttribute("data-id"); console.log(e) console.log(uid) $.ajax({ type: 'post', data: {"ajax" : 'delUser', "id" : uid} }) } which goes into this if(isset($_POST['ajax'])){ switch($_POST['ajax']) { case 'newUserMod': exit(popNewUserModal()); break; case 'userMod': exit(popUserModal($_POST['id'])); break; case 'deleteUser': exit(deleteUser($_POST['id'])); break; } }; which calls this function in another file function deleteUser($id){ include 'includes/dbconn.php'; $stmt = $conn -> prepare("DELETE FROM user WHERE id = ?"); $stmt -> bind_param('i', $id); $stmt -> execute(); header('Location: manage-users'); } I know that i am getting the correct id in the ajax and i can see that the post happens correctly. Any ideas why the users are not being deleted? This is a bit of a more advanced question so I am hoping there are some advanced programmers online at this time . Anyways basically I want to be able to "queue" functions from a class in a single call and am wondering if I am doing it correctly or if there is a better way to do it. Here is my code: <?php class test { private static $one; private static $two; private static $three; public function callOne($val){ $one .= $val; return $this; } public function callTwo($val){ $two .= $val; return $this; } public function callThree($val){ $three .= $val; return $this; } public function print(){ echo $this->one.' '.$this->two.' '.$this->three; } } ?> now when I want to call this I can do: $test = new test(); $test->callOne('one')->callTwo('two')->callThree('three'); $test->callOne('another one'); $test->print(); Is there a better way to do this or is there a different method of doing this? Just wanna make sure I am doing it right lol. Hello, I am having some trouble with calling certain array values while a condition equals something. I have called values from a database table into an array: $result = mysql_query("SELECT `TeamID`, `ScoreA`, `ScoreB`,`TeamPlayed`, `RoundNum` FROM `scores` WHERE `CompID` = 4 ORDER BY `RoundNum` ASC") or die(mysql_error()); while($row = mysql_fetch_assoc($result)) { print_r($row); } Code: [Select] Array ( [TeamID] => 3 [ScoreA] => 16 [ScoreB] => 4 [TeamPlayed] => 4 [RoundNum] => 1 ) Array ( [TeamID] => 1 [ScoreA] => 16 [ScoreB] => 1 [TeamPlayed] => 6 [RoundNum] => 1 ) Array ( [TeamID] => 2 [ScoreA] => 16 [ScoreB] => 14 [TeamPlayed] => 5 [RoundNum] => 1 ) Array ( [TeamID] => 4 [ScoreA] => 16 [ScoreB] => 0 [TeamPlayed] => 6 [RoundNum] => 2 ) Array ( [TeamID] => 1 [ScoreA] => 10 [ScoreB] => 16 [TeamPlayed] => 2 [RoundNum] => 2 ) Array ( [TeamID] => 5 [ScoreA] => 14 [ScoreB] => 16 [TeamPlayed] => 3 [RoundNum] => 2 ) From here I want to able to get display certain values while RoundNum = $value So while RoundNum = 1 display the array values of: Code: [Select] TeamID V TeamPlayed ScoreA - ScoreB Hope you can decipher what I am asking, don't think I have worded it very well :S. Thanks for anyhelp! hi guys im back for more php questions hope you dont get annoyed <?php function getvalue($num) { echo "<input type='text' name='txt1' value='$num'>"; } ?> <html> <head> <title>Home</title> </head> <body> <form action="" method="POST"> <input type="text" name="txt1" id="txt1" value="0"> <input type="button" name="btn1" id="btn1" value="1" onclick="getvalue(1);"> <input type="button" name="btn2" id="btn2" value="2" onclick="getvalue(2);"> </form> </body> </html> here is my code my question is how can i pass the values at the php function? how can i display the passed value to the textbox txt1? is this code correct? echo "<input type='text' name='txt1' value='$num'>"; I have a script I am putting together that simulate a cricket game. The only issue is, that there are a huge number of functions because there doesn't seem to be any other way to do this properly. As well as this, there a while() loop and all this seems to be leading to the page reaching a max 30 second timeout when generating the result. My code is attached below, it is quite messy at the moment because i've just be working on it, but I was wondering if anyone has any solutions of how I can speed this up or change to prevent a timeout: <?php // Error reporting error_reporting(E_ALL); // Connect DB mysql_connect("wickettowicket.adminfuel.com", "rockinaway", "preetha6488") or die(mysql_error()); // Select DB mysql_select_db("wickettowicket") or die(mysql_error()); // MySQL queries to find batsmen and bowlers $array_batsmen = mysql_query('SELECT id, name, ability, strength FROM wtw_players WHERE team_id = 1 ORDER BY id ASC'); $array_bowlers = mysql_query('SELECT id, name, ability, strength FROM wtw_players WHERE team_id = 2'); // Start table for data $data = '<table width="600px">'; // Create blank scorecard while ($array_bat = mysql_fetch_array($array_batsmen)) { $data .= '<tr><td>'.$array_bat['name'].'</td><td></td><td></td><td>0</td></tr>'; } // Set up arrays for players $current_batsman = $current_bowler = array(); // Reset query mysql_data_seek($array_batsmen,0); $in_one = $in_two = $it = ''; function currentBatsman($id, $name, $ability, $strength, $out, $in, $runs) { global $current_batsman; $current_batsman = array ( 'id' => $id, 'name' => $name, 'ability' => $ability, 'strength' => $strength, 'out' => $out, 'in' => $in, 'runs' => $runs ); echo 'set current'; } // Set up arrays of batsmen while ($array = mysql_fetch_array($array_batsmen)) { if ($it < 3 && $in_one == '') { currentBatsman($array['id'], $array['name'], $array['ability'], $array['strength'], 0, 1, 0); $batsmen[$array['id']] = array ( 'id' => $array['id'], 'name' => $array['name'], 'ability' => $array['ability'], 'strength' => $array['strength'], 'out' => 0, 'in' => 1, 'runs' => 0 ); $in_one = $array['id']; $current = $array['id']; $it++; } else if ($it < 3 && $in_two == '') { $batsmen[$array['id']] = array ( 'id' => $array['id'], 'name' => $array['name'], 'ability' => $array['ability'], 'strength' => $array['strength'], 'out' => 0, 'in' => 1, 'runs' => 0 ); $in_two = $array['id']; $it++; } else { $batsmen[$array['id']] = array ( 'id' => $array['id'], 'name' => $array['name'], 'ability' => $array['ability'], 'strength' => $array['strength'], 'out' => 0, 'in' => 0, 'runs' => 0 ); } } // Bowler Array while ($array = mysql_fetch_array($array_bowlers)) { $bowlers[] = array ( 'name' => $array['name'], 'ability' => $array['ability'], 'strength' => $array['strength'] ); } // Reset both queries mysql_data_seek($array_bowlers,0); mysql_data_seek($array_batsmen,0); function changeBatsman($just_out) { global $array_batsmen, $batsmen; //Update array $batsmen[$just_out] = array ( 'in' => 1, 'out' => 1 ); while ($array = mysql_fetch_array($array_batsmen)) { if ($just_out != $array['id'] && $batsmen[$array['id']]['out'] != 0) currentBatsman($array['id'], $array['name'], $array['ability'], $array['strength'], 0, 1, 0); } // Reset query mysql_data_seek($array_batsmen,0); echo 'change batsman'; } function swapBatsman($other_batsman) { global $array_batsmen, $batsman; while ($array = mysql_fetch_array($array_batsmen)) { if ($other_batsman != $array['id'] && $batsman[$array['id']]['out'] != 0 && $batsman[$array['id']]['in'] == 1) currentBatsman($array['id'], $array['name'], $array['ability'], $array['strength'], 0, 1, 0); } // Reset query mysql_data_seek($array_batsmen,0); echo 'swap batsman'; } $runs = $outs = $balls = $overs = 0; $played = array(); function selectBowler() { global $bowlers, $current_bowler; // Select random bowler $choose_bowler = array_rand($bowlers, 1); $current_bowler = array ( 'name' => $bowlers[$choose_bowler]['name'], 'ability' => $bowlers[$choose_bowler]['ability'], 'strength' => $bowlers[$choose_bowler]['strength'] ); } /* function selectBatsman(); { global $array_batsmen; while ($array_batsmen[]['out'] != 1) { }*/ function bowl() { global $batsmen, $bowlers, $current_bowler, $current_batsman, $data, $balls, $outs, $runs; if ($current_batsman['out'] == 0) { echo 'bowling'; // Set the initial number $number = rand(0, 190); // Ability of batsman if ($current_batsman['ability'] > 90) $number += 30; else if ($current_batsman['ability'] > 70) $number += 15; else if ($current_batsman['ability'] > 50) $number += 2; else $number = $number; // Strength of batsman if ($current_batsman['strength'] > 90) $number += 15; else if ($current_batsman['strength'] > 70) $number += 10; else if ($current_batsman['strength'] > 50) $number += 5; else $number = $number; // Depending on overs if ($balls > 270) $number += 30; else if ($balls > 120) $number -= 10; // Ability if ($current_bowler['ability'] > 90) $number -= 30; else if ($current_bowler['ability'] > 70) $number -= 15; else if ($current_bowler['ability'] > 50) $number -= 2; else $number = $number; // If batsman has made a huge total of runs, we need to knock some numbers off - more likely to get out if ($current_batsman['runs'] > 200) $number -= 70; else if ($current_batsman['runs'] > 100) $number -= 30; // Finally sort out runs if ($number > 190) $run = 6; else if ($number > 170) $run = 4; else if ($number > 160) $run = 3; else if ($number > 100) $run = 2; else if ($number > 50) $run = 1; else if ($number > 10) $run = 0; else if ($balls > 120 && $number > 0) $run = 0; else $run = -1; // Increase number of balls $balls += 1; // Are they out? if ($run == -1) { $current_batsman['out'] = 1; $played[] = $current_batsman['id']; $find = '<tr><td>'.$current_batsman['name'].'</td><td></td><td></td><td>0</td></tr>'; $replace = '<tr><td>'.$current_batsman['name'].'</td><td></td><td>'.$current_bowler['name'].'</td><td>'.$current_batsman['runs'].'</td></tr>'; $data = str_replace($find, $replace, $data); changeBatsman($current_batsman['id']); echo 'out'; } else { $current_batsman['runs'] += $run; $runs += $run; if ($run == 1 || $run == 3) { swapBatsman($current_batsman['id']); echo 'time to swap'; } echo $run; } // Count outs if ($current_batsman['out'] == 1) $outs += 1; } } function game() { global $main, $batsmen, $bowlers, $data, $batted, $balls, $outs, $current_batsman; // Check if possible while ($balls <= 295 && $outs < 10) { selectBowler(); // Actually bowl now bowl(); } } game(); echo $data; It's a little difficult for me to explain but, when a website loads another site (For example with Curl or something) How is the site able to keep a header or some part of original site 'attached' to the site they loaded..for example, say you're redirected, the site you redirected to loads, but you still see the site you redirected from header on at the top of the page. How is this done? What is it called? Do you need me to clear it up a bit better? I can try to find an example. I've been trying to find tutorials/coding today related to controlling the ability to download files. The problem I think I'm having because I know it exists is I don't actually know what it's called. Below is kind of a basis for a tutorial or describing what I'm trying to do. I'm trying to find a tutorial or a how to on storing downloadable files either in a Mysql Database &/or on the file server system. I want to make it so that only users that are stored within the user database who have certain rights or a field can be able to download a file. Those users who don't have the proper permissions in the user table will not be able to and those who do when they go to download a file, will be able to. I know these scripts use PHP but am not really sure where to begin on my search because I don't even know what file permissions coding they are using. Here's some of my code. The fault is when AJAX sends the dataString to sendpm.php, it should call the function. But nothing is happening. If i put the sendprivatemessage query in sendpm.php page, the data is sent to mysql. What is the solution, so i don't have to put the query on sendpm.php? jquery - some of it Code: [Select] $.ajax({ type: "POST", url: "/sendpm.php", data: dataString, success: function() { window.location.href = 'http://www.stackway.com/cp/messages=outbox'; } }); sendpm.php Code: [Select] include "database.php"; $to = $_POST['to']; $from = $_POST['from']; $subject = $_POST['subject']; $body = $_POST['body']; $database2 = new Database(); $database2->opendb(); $database2->sendprivatemessage($to,$from,$subject,$body); $database2->closedb(); sendprivatemessage function Code: [Select] function sendprivatemessage($to,$from,$subject,$body) { $insert = mysql_query("INSERT INTO privatemessage VALUES ('','$subject','$body','$to','$from','1',NOW(),'','','')",$this-connect); } Hey guys, I am still kinda new to php and I can't seem to get this to work. Basically I am calling a script and first I need it retrieve certain values which is working fine, but then after that is called I need it to clear those values it just displayed. To do that I am using UPDATE but it doesn't seem to be calling the UPDATE part. Any ideas? Here is the code: Code: [Select] @mysql_select_db("$db_name") or die ("No DataBase Found"); $result = mysql_query("SELECT * FROM members WHERE id='$_POST[id]'"); while ($row = mysql_fetch_array($result)) { $message = $row['message']; $sender = $row['sender']; echo $message . "\n" . $sender; } mysql_query("UPDATE memebers SET message='' WHERE id='$_POST[id]'"); //These never get mysql_query("UPDATE memebers SET sender='' WHERE id='$_POST[id]'");//called or so it seems hi, i just wanted to know... $arr[0] $arr[1] $arr[2] also this $arr[1] would be called a value, but how are the numbers 0,1 and 2 called? are that keys? didn't know where else to post this question. I have 2 forms on a page, 1 with a selection of newly registered accounts and another that displays the information on the user. What I need to happen is when a user is selected from the first form, the second form is populated with the data. I'm trying to do this with a combination of php and javascript, however whenever a user is selected the function isn't being called at all as far as I can tell. Can anyone help me get this working please? Code: [Select] <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Fearless Bandits :: Admin Control Panel</title> </head> <body> <?php //Check for config file and initiate session. require("config.php"); session_start(); //Connect to DB if(!$con) die('Could not connect: ' . mysql_error()); mysql_select_db("$dbname") or die("Cannot select DB"); //Check user authorisation if(!isset($_COOKIE['user'])) { echo "Error: Cookies must be enabled. Please enable cookies in your browser and try again.<br>"; return; } else { $user=$_SESSION['user']; $sql="SELECT * FROM users WHERE username='$user' and access='2'"; $result=mysql_query($sql); $count=mysql_num_rows($result); if($count == 0) { echo "Error: Unauthorised access detected."; return; } } include("header.php"); echo "Admin Control Panel<br>"; //Check for mode, if no mode set to 0 if(isset($_GET['mode'])) $mode=$_GET['mode']; else $mode=0; //Display information based on mode switch($mode){ //Check for new applications case 1: echo "<a href=\"admin.php?mode=0\">Back</a><br>"; $sql="SELECT * FROM users WHERE newreg='1'"; $result=mysql_query($sql); $count=mysql_num_rows($result); $newuser = NULL; $newuid = NULL; $newapi = NULL; $newmember = 0; //If there is more than one load results into an array if($count > 0) { echo "There is at least 1 new user:<br>"; $i = 0; while($row=mysql_fetch_array($result)) { $newaccounts[$i] = $row['username']; $i++; } for($i=0; $i < $count; $i++) { echo "User " . $i . ": " . $newaccounts[$i] . "<br>"; } //Select user echo "<form name=\"selectuser\" action=\"\">"; echo "<select name=\"username\" onChange=\"newaccntsUpdate(this);\">"; echo "<option value=\"\" selected=\"selected\"></option>"; for($i=0; $i < $count; $i++) { echo "<option value=\"" . $newaccounts[$i] . "\">" . $newaccounts[$i] . "</option>"; } echo "</select><br>"; echo "</form>"; //Output array into form. echo "<form name=\"newaccnts\" method =\"post\" action=\"verify_admin.php?form=1\">"; echo "Username: <input name=\"newuser\" type=\"text\" id=\"newuser\" value=\"" . $_SESSION['newuser'] . "\">"; echo "UID: <input name=\"newuid\" type=\"text\" id=\"newuid\" value=\"" . $_SESSION['newuid'] . "\">"; echo "API: <input name=\"newapi\" type=\"text\" id=\"newapi\" value=\"" . $_SESSION['newapi'] . "\">"; if($newmember == 0) echo "Member: <input name=\"newmember\" type=\"checkbox\" id=\"newmember\" value=\"1\"><br>"; else echo "Member: <input name=\"newmember\" type=\"checkbox\" checked= \"checked\" id=\"newmember\" value=\"1\"><br>"; echo "<input name=\"submit\" type=\"submit\" value=\"Submit\">"; echo "</form>"; } break; //Select a mode default: echo "Please select a function below:<br>"; echo "<ul>"; echo "<li><a href=\"admin.php?mode=1\">Check for new applications</a></li>"; echo "<li><a href=\"admin.php?mode=2\">Modify an existing account</a></li>"; echo "<li><a href=\"admin.php?mode=3\">Reset a password</a></li>"; echo "<li><a href=\"admin.php?mode=4\">Delete an account</a></li>"; echo "<ul>"; break; } mysql_close($con); //Update newaccnts function. Pull user info from databse and then run javascript function newaccntsUpdate() { echo "newaccntsUpdate executed<br>"; //Error checking //Identify username $newuser=identifyUser(); //If username is NULL or blank return if($newuser == NULL || $newuser == "") return; $sql = ("SELECT * FROM users WHERE username='$newuser'"); $result = mysql_query($sql); $row = mysql_fetch_array($result); $_SESSION['newuser'] = $newuser; $_SESSION['newuid'] = $row['uid']; $_SESSION['newapi'] = $row['api']; $_SESSION['newmember'] = $row['member']; //Update form with details updateForm(); return; } ?> <script language = "Javascript"> //Identify which user has been selected function identifyUser() { $newuser = document.selectuser.username.value; alert('identifyUser executed'); //Error checking return($newuser); } //Update form function updateForm() { document.newaccnts.newuser.value = $newuser; document.newaccnts.newuid.value = $_SESSION['newuid']; document.newaccnts.newapi.value = $_SESSION['newapi']; alert('updateForm executed'); //Error checking return; } </script> </body> </html> I apologise if I've butchered the code, I'm still learning. Hi guys, What is it called when you have a long paragraph shoretend, With php of course, To make it like haljh;lajbsdg... For example, I have this paragraph: Code: [Select] Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus placerat consequat enim, pretium viverra massa cursus nec. Sed in pharetra magna. Aliquam egestas vehicula mi, sed pellentesque ligula suscipit a. Donec lectus velit, luctus sed lobortis vitae, sollicitudin in sem. Ut facilisis, velit in accumsan porttitor, libero neque molestie leo, ac vulputate eros libero eget mauris. Ut nec justo augue. How to I make it so PHP detects if it is too long and trims it down like: Code: [Select] Lorem ipsum dolor sit amet, consectetur adipiscing elit... If I can find what this is called then I can google it to find it and use it on my site. Thanks in advance! This might be more than just a php question but here goes anyways. I have designed a php chat room page on my home Apache server just for a few friends & family. The problem I have is the only way for me to know if anyone is on the chat room page is if I'm actually viewing the php page. Is there a way that I can have the page alert me when someone accesses it? I was thinking something like activating a popup in my browser or even a beep so as long as I'm at my computer with my browser open that I will know someone has accessed the page. Hi all, I want to be able to have one file (configuration file i guess) where i set the phone number, address, staff names and positions, etc. and then have them display at different places on various pages. I thought they were inc files, but all i can find is the likes of headers and footers. Any help much appreciated. I just don't know what it's called, if someone can point me in the right direction, thanks. MsKazza Hello I have a php website. I am trying to trace (find out) which files are called when a page is displayed. For example on certain pages that get displayed it may call up to 6-7 files. I would like to know the name of the files and the order they are called. As through out the code there is a lot of include_once("global/global.libs.php"); Is there any may to easily trace this without having to go through page by page on the code and try to figure out what is happening. Essentially I just want the file name eg global/global.libs.php logged somewhere Thanks in advance Here is my code which i use to recieve uploaded files.
$filepath = $_SERVER['DOCUMENT_ROOT'] . "file/"; $fileunzippath = $filepath."unzipped/"; $exclude_list = array(".", "..", "...", "index.php", ".php", ".htaccess"); if($_FILES["zip_file"]["name"]) { $filename = $_FILES["zip_file"]["name"]; $source = $_FILES["zip_file"]["tmp_name"]; $type = $_FILES["zip_file"]["type"]; $name = explode(".", $filename); $accepted_types = array('application/zip', 'application/x-zip-compressed', 'multipart/x-zip', 'application/x-compressed'); foreach($accepted_types as $mime_type) { if($mime_type == $type) { $okay = true; break; } } $continue = strtolower($name[1]) == 'zip' ? true : false; if(!$continue) { $message = "The file you are trying to upload is not a .zip file. Please try again."; } $string = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $filename); $clean_name = strtr($string, array('Š' => 'S','Ž' => 'Z','š' => 's','ž' => 'z','Ÿ' => 'Y','À' => 'A','Á' => 'A','Â' => 'A','Ã' => 'A','Ä' => 'A','Å' => 'A','Ç' => 'C','È' => 'E','É' => 'E','Ê' => 'E','Ë' => 'E','Ì' => 'I','Í' => 'I','Î' => 'I','Ï' => 'I','Ñ' => 'N','Ò' => 'O','Ó' => 'O','Ô' => 'O','Õ' => 'O','Ö' => 'O','Ø' => 'O','Ù' => 'U','Ú' => 'U','Û' => 'U','Ü' => 'U','Ý' => 'Y','à' => 'a','á' => 'a','â' => 'a','ã' => 'a','ä' => 'a','å' => 'a','ç' => 'c','è' => 'e','é' => 'e','ê' => 'e','ë' => 'e','ì' => 'i','í' => 'i','î' => 'i','ï' => 'i','ñ' => 'n','ò' => 'o','ó' => 'o','ô' => 'o','õ' => 'o','ö' => 'o','ø' => 'o','ù' => 'u','ú' => 'u','û' => 'u','ü' => 'u','ý' => 'y','ÿ' => 'y')); $clean_name = strtr($clean_name, array('Þ' => 'TH', 'þ' => 'th', 'Ð' => 'DH', 'ð' => 'dh', 'ß' => 'ss', 'Œ' => 'OE', 'œ' => 'oe', 'Æ' => 'AE', 'æ' => 'ae', 'µ' => 'u')); $clean_name = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $clean_name); $target_path = $filepath.$clean_name; // change this to the correct site path if(move_uploaded_file($source, $target_path)) { echo "Source: ".$source."<br/>"; echo "Type: ".$type."<br/>"; echo "Filename: ".$filename."<br/>"; $zip = new ZipArchive(); $x = $zip->open($target_path); if ($x === true) { $zip->extractTo($fileunzippath.$clean_name); // change this to the correct site path $zip->close(); $exclude_list; $dir_path = $_SERVER['DOCUMENT_ROOT']; $dir_path .= "/file/unzipped/"; $directories = array_diff(scandir($fileunzippath.$clean_name), $exclude_list); foreach($directories as $entry) { if(is_dir($dir_path.$entry)) { if($entry != 'part0' || $entry !='part1') { rmdir($entry); } } } } $message = "Your .zip file was uploaded and unpacked."; } else { $message = "There was a problem with the upload. Please try again."; } }Specifically i want to highlight this part: $exclude_list; $dir_path = $_SERVER['DOCUMENT_ROOT']; $dir_path .= "/file/unzipped/"; $directories = array_diff(scandir($fileunzippath.$clean_name), $exclude_list); foreach($directories as $entry) { if(is_dir($dir_path.$entry)) { if($entry != 'part0' || $entry !='part1') { rmdir($entry); } } }When I upload a zip file containing 2 directories(one called 'part0', and one called 'bad'), they get unzipped correctly and it gives no errors, however the fake directories(not called part0 or part1) I put in there are still there. Any Help? ERROR 0 Fatal error: Call to a member function execute() on a non-object ... i've tested the $mysqli and $stmt, both are objects, i have other requests that work well and are built the same way (copy - paste) all vars on the query are also ok. There are working functions over and under this part of my code, if i remove it everything works fine. Code: [Select] $query2 = "INSERT INTO TABLE_NAME(accountSmtp, passwordSmtp, merchantID, adsPrice, adsWidth, adsHeigh, adsAmount, email, emailFrom, adsSense) VALUES('$gmailUser', '$gmailPassword', '$merchantID', '$prix', '$width', '$height', '$adsAmount', '$email', '$from', '$sense')"; if (!$stmt = $mysqli->prepare($query2)) { printf("Erreur : %d.\n", $stmt->errno); print_r($query2); } /* execute statement */ $stmt->execute(); //close statement $stmt->close(); Getting a bit desperate as I've tried a lot of things, so any help very appreicated! The concept im struggling with works like this: 1.) There are graphics of people on a page. There is a textbox to the right of the screen which outputs data that corresponds to the tutor. 2.) What i want is that when a user rolls his mouse over the picture, the data in the textbox immediately updates, which is done via php 3.) The issue is thus calling a php function within onmouseover="" from a javascript command. 4.) The function only changes the values that should be displayed (but doesnt work anyway) - is there a way to test whether a php function is being called correctly? And do i need to include some kind of page refresher? Thanks a lot for your help ****************************************** The code as I have it currently is this. ... Code: [Select] // Default setting to display a random persons data at page startup <? $username="removedforprivacy"; $password="removedforprivacy"; $database="tutors"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM tutors"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); $i=rand(0,5); $id=mysql_result($result,$i,"id"); $name=mysql_result($result,$i,"name"); $degree=mysql_result($result,$i,"degree"); $ib=mysql_result($result,$i,"ib"); $subjects=mysql_result($result,$i,"subjects"); $experience=mysql_result($result,$i,"experience"); $style=mysql_result($result,$i,"style"); $pic=mysql_result($result,$i,"pic"); ?> //This bit outputs all the graphics. Only the first immage calls the php updater function. $whichpic defines the flag for the person, which is passed to the updater function. </p> <p class="bodytext"><a href="" onclick="" onmouseout="MM_swapImgRestore()" onmouseover="<? php updater($whichpic=1); ?>"><img src="../Tutors/Photos/tim2.gif" name="Image15" width="100" height="100" border="0" id="Image15" /></a><a href="max.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image16','','../Tutors/Photos/max1.gif',1)"><img src="../Tutors/Photos/max2.gif" alt="max" name="Image16" width="100" height="100" border="0" id="Image16" /></a><a href="nico.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image17','','../Tutors/Photos/nico1.gif',1)"><img src="../Tutors/Photos/nico2.gif" alt="nico" name="Image17" width="100" height="100" border="0" id="Image17" /></a><a href="sasha.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image18','','../Tutors/Photos/sasha1.gif',1)"><img src="../Tutors/Photos/sasha2.gif" alt="sasha" name="Image18" width="100" height="100" border="0" id="Image18" /></a> </p> //Where the php data is output <p class="sideheader">FEATURED TUTOR</p> <p><img src="<? echo " $pic"; ?>" width="200" height="200"></p> <p><strong>Name: </strong> <? echo "$name"; ?></p> <p><strong>Degree: </strong> <? echo "$degree"; ?></p> <p><strong>IB: </strong> <? echo "$ib"; ?></p> <p><strong>Subjects Taught: </strong> <? echo "$subjects"; ?></p> <p><strong>Teaching Experience: </strong> <br /> <? echo "$experience"; ?> </p> <p><strong>Teaching Style:<br /> </strong><? echo "$style"; ?> .</strong> </p> <p><!-- end .sidebar2 --></p> </div> // The updater function to call, which changes the information displayed <? php function updater($whichpic) { $i = $whichpic; $id=mysql_result($result,$i,"id"); $name=mysql_result($result,$i,"name"); $degree=mysql_result($result,$i,"degree"); $ib=mysql_result($result,$i,"ib"); $subjects=mysql_result($result,$i,"subjects"); $experience=mysql_result($result,$i,"experience"); $style=mysql_result($result,$i,"style"); $pic=mysql_result($result,$i,"pic"); } ?> |