PHP - Why The Hell Is This Script Not Loading The Links?
<?php
# Game Info # $game_link = "http://mob-dynamic-lb".rand(1,5).".mobsters0".rand(1,9).".com/mob/"; //$id2 = 548685167; # ID / Auth Key file info # $filename = "auth-keys111.txt"; $fp = file($filename); foreach($fp as $cwb){ list($id,$auth) = explode(" ",$cwb); $a = file_get_contents($game_link."attack?user_id=".$id."&target_id=548685167&punch_in_face=true&auth_key=".$auth); echo "WTF!"; //////////////////////////////////////////// //////////////////////////////////////////// $a = file_get_contents($game_link."attack?user_id=".$id."&target_id=548685167&punch_in_face=true&auth_key=".$auth); $b = file_get_contents($game_link."top_mob_gift?user_id=".$id."&target_id=".$id."&auth_key=".$auth); $c = file_get_contents($game_link."remove_top_mob?user_id=".$id."&target_id=548685167&auth_key=".$auth); echo "WTF?!";} ?> everything is correct for $game_link and all that.. but its not workin.. Any ideas? Similar TutorialsHey guys, Problem: php script keeps loading and i dont know why. What I've done so far is commenting out line-by-line so I found out that the problem is somewhere he Code: [Select] <div id="wrapper"> <div id="inner"> <div id="top"> <?php require 'basic/logo.php';?> <?php require 'basic/header.php';?> </div> its not working - keeps loading. Commenting out the 'required' stuff it works... error_reporting(E_ALL); is on... what the hell is the problem?! the files are there in /basic. Just dont know any further! I have a php script that I am trying to run ( I dindt write it) but the index.php file loads basically all of the php file in plain text instead of running it. Any sugguestions? PHP is isntalled since other php scripts work.
Thanks
So I wrote this code, what its supposed to do is draw an image on a grid space, based on its X,Y coordinates from a mySql database, compared to the player X,Y. Heres the code: Code: [Select] <table> <tr> <td> <?php //northwest echo "nw"; $x1 = $_SESSION[x] - 1; $y1 = $_SESSION[y] + 1; $hasobject1 = mysql_query("SELECT * FROM objects WHERE x='$x1' && y='$y1'"); while($row = mysql_fetch_array($hasobject1)) { $image = "space_228.gif"; $image = $row[image]; } if(!empty($image)){ echo "<IMG SRC=$image WIDTH=64 HEIGHT=64 onerror='onImgError(this)>'"; } else{ echo "<IMG SRC='space_228.gif' WIDTH=64 HEIGHT=64>"; } ?></td> <td><?php //north echo "n"; $x2 = $_SESSION[x]; $y2 = $_SESSION[y] + 1; $hasobject2 = mysql_query("SELECT * FROM objects WHERE x='$x2' && y='$y2'"); while($row = mysql_fetch_array($hasobject2)) { $image = "space_228.gif"; $image = $row[image]; } if(!empty($image)){ echo "<IMG SRC=$image WIDTH=64 HEIGHT=64 onerror='onImgError(this)>'"; } else{ echo "<IMG SRC='space_228.gif' WIDTH=64 HEIGHT=64>"; } ?></td> <td><?php //northeast echo "ne"; $x3 = $_SESSION[x] + 1; $y3 = $_SESSION[y] + 1; $hasobject3 = mysql_query("SELECT * FROM objects WHERE x='$x3' && y='$y3'"); while($row = mysql_fetch_array($hasobject3)) { $image = "space_228.gif"; $image = $row[image]; } if(!empty($image)){ echo "<IMG SRC=$image WIDTH=64 HEIGHT=64 onerror='onImgError(this)>'"; } else{ echo "<IMG SRC='space_228.gif' WIDTH=64 HEIGHT=64>"; } ?></td> </tr> <tr> <td><?php //wesr echo "w"; $x4 = $_SESSION[x] - 1; $y4 = $_SESSION[y]; $hasobject4 = mysql_query("SELECT * FROM objects WHERE x='$x4' && y='$y4'"); while($row = mysql_fetch_array($hasobject4)) { $image = "space_228.gif"; $image = $row[image]; } if(!empty($image)){ echo "<IMG SRC=$image WIDTH=64 HEIGHT=64 onerror='onImgError(this)>'"; } else{ echo "<IMG SRC='space_228.gif' WIDTH=64 HEIGHT=64>"; } ?></td> <td><?php echo "p"; //player echo "<IMG SRC='spaceship_wire5.jpg' WIDTH=64 HEIGHT=64>"; ?></td> <td><?php //east echo "e"; $x5 = $_SESSION[x] + 1; $y5 = $_SESSION[y]; $hasobject5 = mysql_query("SELECT * FROM objects WHERE x='$x5' && y='$y5'"); while($row = mysql_fetch_array($hasobject5)) { $image = "space_228.gif"; $image = $row[image]; } if(!empty($image)){ echo "<IMG SRC=$image WIDTH=64 HEIGHT=64 onerror='onImgError(this)>'"; } else{ echo "<IMG SRC='space_228.gif' WIDTH=64 HEIGHT=64>"; } ?></td> </tr> <tr> <td><?php //southwest echo "sw"; $x6 = $_SESSION[x] - 1; $y6 = $_SESSION[y] - 1; $hasobject6 = mysql_query("SELECT * FROM objects WHERE x='$x6' && y='$y6'"); while($row = mysql_fetch_array($hasobject6)) { $image = "space_228.gif"; $image = $row[image]; } if(!empty($image)){ echo "<IMG SRC=$image WIDTH=64 HEIGHT=64 onerror='onImgError(this)>'"; } else{ echo "<IMG SRC='space_228.gif' WIDTH=64 HEIGHT=64>"; } ?></td> <td><?php //south echo "s"; $x7 = $_SESSION[x]; $y7 = $_SESSION[y] - 1; $hasobject7 = mysql_query("SELECT * FROM objects WHERE x='$x7' && y='$y7'"); while($row = mysql_fetch_array($hasobject7)) { $image = "space_228.gif"; $image = $row[image]; } if(!empty($image)){ echo "<IMG SRC=$image WIDTH=64 HEIGHT=64 onerror='onImgError(this)>'"; } else{ echo "<IMG SRC='space_228.gif' WIDTH=64 HEIGHT=64>"; } ?></td> <td><?php //southeast echo "se"; $x8 = $_SESSION[x] + 1; $y8 = $_SESSION[y] - 1; $hasobject8 = mysql_query("SELECT * FROM objects WHERE x='$x8' && y='$y8'"); while($row = mysql_fetch_array($hasobject8)) { $image = "space_228.gif"; $image = $row[image]; } if(!empty($image)){ echo "<IMG SRC=$image WIDTH=64 HEIGHT=64 onerror='onImgError(this)>'"; } else{ echo "<IMG SRC='space_228.gif' WIDTH=64 HEIGHT=64>"; } ?></td> </tr> </table> Now what happens is it draws the image on a bunch of different spots. The object is at 0,0. It doesnt display the object if the object is out of range of the player, or the player is at 0,0. But if the player is near the object, it draws it on like half the grid spaces, and on some places everywhere but the players. Heres the page, login with test, password test. http://spacetimemmo.webuda.com/login.php Short version of my question is going to be "why are my session variables vanishing?" [ START not important Stuff ] My (simplified) site layout looks like login_page.php ->page1.php->page2.php login_page.php connects to mysql, to check login/pwd, and, if valid, sets the _SESSION id's/other credentials and then redirects to page1.php. page1.php has link to page2.php. Both page1 and page2 check against (require_once) an auth.php (authorization) and redirect to login_page.php if not logged in. The auth.php file has the structu session_start(); if(!isset($_SESSION['SESS_USER_ID'])|| other parameters){ //code } page2 has an AJAX load that pulls in a php file that includes various content (XML,text,.htm,etc.) That php file also requires auth.php All of these things work. [ END not important stuff ] [Start important part] Everything works. Session variables persist and are readable/accessible via all pages, as well as a Debug link (pop window that echos the $_SESSION vars.) UNLESSS the user is inactive for more than a minute or two; At which point the session variables vanish. Again, I can log in, Set the session variables, load multiple pages via AJAX (all of which are checked against the session variables...which means they have to exist) and generally everything works as expected. However, if I stop navigating/interacting with the site for more than a minute, or so, the session variables vanish (user id / other user credentials) and the I'm kicked back to the login the next time I click a link. There is nothing but the initial mysql login that writes to the session variables. No code, on any other page, does anything but read the session. My php ini file appears to have the correct location for my session.save_path. The garbage collection is the defualt 1440 and the cache_expire is also the default 180 I'm hosted with fatcow (starting to regret that) with Debian/Apache/php5 Oh and, this happens on every browser on Linux, Mac, and Windows. But it doesn't seem to occur if I run it locally from xampp/lampp. I'm at a total loss as to ideas for my next debugging step and any suggestions would be much appreciated. Ok, I will explain first what I am trying to do, and show you how I am going about it, which isn't working I have a table set up. It has missing ID numbers, such as, 1 2 3 6 7 8 11 12 ..etc. I am trying to pull a random ID number from all valid ID numbers. (Meaning, I don't want to get an ID of a record that is no longer there, so skip all the missing ID's) This is for a cron job to change which record is being shown each day, randomly. I figured, logically, the best way to do this would be to pull all the valid ID's into an array, and then use array_rand($id_array,1); to pull one random ID number out of the array. So, I tried using this code: Code: [Select] //Set variable as an array $id_array = array(); //Populate array with valid ID's $sql="SELECT ID FROM riddles"; $result=mysql_query($sql,$db) or die(mysql_error()); while($row = mysql_fetch_array($result,$db)) { $id_array[] = $row['ID']; }; print_r(array($id_array)); $new_rotd=(array_rand($id_array[0],1)); I am running into 2 problems with this code. First, when I print_r the array, I get the following: Quote Array ( => Array ( => [1] => [2] => [3] => [4] => [5] => [6] => [7] => [8] => [9] => [10] => [11] => [12] => [13] => [14] => [15] => [16] => [17] => [18] => [19] => [20] => [21] => [22] => [23] => ) ) The numbers are not correct. It is the correct number of total records, but it is not putting the correct ID number in there. 2) When I try and pull a random number out of the array, I get an error saying the First argument has to be an array. It IS an array?! I need to get this working, so any help would be much appreciated. To summarize I need to: Pull all valid ID #'s out of the table and put them in an array. Pull one random number out of that array and set it as variable: $new_rotd Hey guys havent coded in a while and im stumped. Ive checked google but to no avail lol i wanna include my config file and have an IF statement to run/include another file IE... <?php include("config/config.php"); If File(Not Exist); include("install/config.php"); ?> If someone can put me back on track it would be greatly epreciated Hello guys i want your help in adfly clone script , i have it installed it but i have problem - shrinking links not working on main page, but working good when user logged in all server Requirements are ok my website: adglo.be script: mediafire vt: virustotal regards, Edited by ForexSon, 09 August 2014 - 06:49 PM. <html> <?php $id = $_GET['id']; $dbusername="web148-matt"; $dbpassword="matt"; $dbdatabase="web148-matt"; mysql_connect(localhost,$dbusername,$dbpassword); @mysql_select_db($dbdatabase) or die( "Unable to select database"); mysql_query("UPDATE count SET clicks=clicks+1 WHERE id='$id'"); $sql = mysql_query("SELECT link FROM count WHERE id='$id'"); $fetch = mysql_fetch_row($sql); $result = mysql_query("SELECT * FROM count"); while($row = mysql_fetch_array($result)) { echo "<a href=" .$row['link']. ">Link</a>"; } ?> <a href='http://www.google.com'>Google</a> <a href='/index.php?id=2'>link2</a> </html> So I have been working on my website for a while which all is php&mysql based, now working on the social networking part building in similar functions like Facebook has. I encountered a difficulty with getting information back from a link. I've checked several sources how it is possible, with title 'Facebook Like URL data Extract Using jQuery PHP and Ajax' was the most popular answer, I get the scripts but all of these scripts work with html links only. My site all with php extensions and copy&paste my site links into these demos do not return anything . I checked the code and all of them using file_get_contents(), parsing through the html file so if i pass 'filename.php' it returns nothing supposing that php has not processed yet and the function gets the content of the php script with no data of course. So my question is that how it is possible to extract data from a link with php extension (on Facebook it works) or how to get php file executed for file_get_contents() to get back the html?
here is the link with code&demo iamusing: http://www.sanwebe.c...-php-and-jquery
thanks in advance.
(I looked at the appropriate forums to put this in, but it seems I couldn't find a forum section specifically for this problem) Yesterday PHP on WAMP was working perfectly. So I shutdown the computer, go to sleep, and wake up and turn WAMP on. But for some odd reason, when none of my PHP files are loading properly. It just shows all the code as if it were a .txt file. Any reasons for this? I seem to have a problem with a PHP page I made. When executed on the server, it loads with a filesize 0 and for some browsers, says it does not exist. I believe that the cause is because it is not parsing due to a syntax error. I've busted my @$$ over this code, trying to find the issue, but cannot find it. Here is the whole page's code on pastie: http://pastie.org/1064160 I got problem with one of my php page. Mozilla browser keeps on loading although it shows the page, i am not really sure which part is wrong. But i don't find any problem with other browsers lol. Can anyone help me please thanks in advance Hi I have website where users can upload pictures on server. Sometimes it take 4-5 seconds until the upload it's finish. What can I do that when I click on upload button an icon appear in middle of the screen and disappear then the pictures was finish uploading. Thanks Hello everyone, I have a PHP shopping cart I am working on. I have all my pictures stored in a folder url directory of my project. In my SQL database I have an image table that holds all of the image names. When I load the picture names with my php It somehow adds some extra random characters to the directory path: /img/%7B$row_product_image[name]%7D 404 (Not Found) If I hardcode the image directory img/picturename.jpg It works. Here is what I have. <?php include_once "objects/database.php"; include_once "objects/product.php"; include_once "objects/product_images.php"; // object instances $database = new Database(); $db = $database->getConnection(); $product = new Product($db); $product_image = new ProductImage($db); $recordsPerPage = 1; while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { extract($row); echo '<div class="col-md-4 mb-2">'; echo '<div class="product-id d-none">{$id}</div>'; echo '<a href="product.php?id={$id}" class="product-link">'; $product_image->product_id = $pid; $stmt_product_image = $product_image->readFirst(); while($row_product_image = $stmt_product_image->fetch(PDO::FETCH_ASSOC)) { echo '<div class="mb-1">'; echo '<img src="img/{$row_product_image[name]}" class="w-100" />'; echo '</div>'; } echo '<div class="product-name mb-1">{$name}</div>'; echo '</a>'; echo '</div>'; } class ProductImage { private $pdoConn; private $table_name = "product_images"; public $id; public $product_id; public $name; public $timestamp; public function __construct($dbconn) { $this->pdoConn = $dbconn; } function readFirst() { // SELECT query $query = "SELECT id, pid, name " . "FROM " . $this->table_name . " " . "WHERE pid = ? " . "ORDER BY name DESC " . "LIMIT 0, 1"; // prepare query statement $stmt = $this->pdoConn->prepare($query); // sanitize $this->product_id=htmlspecialchars(strip_tags($this->product_id)); // bind variable as parameter $stmt->bindParam(1, $this->product_id); // execute query $stmt->execute(); // return values return $stmt; } } ?>
Hi! This code, which is basically HTML and Javascript, echoed in PHP (as you can see in the attached image), has functioned well for a long time. It still does, if put in a page by itself. The problem now is when it is integrated in other PHP scripts. It does not work this way on either the live server or on WAMP anymore. This script is normally setup to be execute about half way through the complete script of the page and has functioned well, showing approx. the top half of the page, as well as a loading gif. When the PHP workload is complete, the loading gif is removed and the rest of the page is displayed. Now with the later versions of PHP, all I see is a blank page until all the script is executed, which can take about 15 seconds or more. PHP does not release the information to Apache, or if it does, Apache does not do anything with it. I have tried different approaches, using ob_flush() and so on, but it just will not function. I would like to know if someone else has had this issue, or knows about it and if there is any current solution. I have not managed to find any working solution that will work with PHP 7.4 and in the future, on the net. I know one cannot predict all the changes that will occur with PHP in the future, but I would like the solution to function for at least 3-5 future versions. I am now going to try something completely different outside the box and create a start page instead. If it does work, it will just be a temporary solution though. Thanks for any assistance beforehand. Mac Edited October 24, 2020 by MacDknife spelling error I have a script which registers people to a database, however it doing something very strange. Whenever I place it into even a single CSS div it adds the registration to the dabase but stops loading the next page (index.php) I find this totally bizarre as I haven't seen anything like this behave before. With CSS affecting how PHP works. Especially when the CSS is not inside the <php> of <form> tags. Code: [Select] <?php include("connect.php"); if($_POST['submit']) { $username = mysql_real_escape_string(trim($_POST['username'])); $password = trim($_POST['password']); $password2 = trim($_POST['password2']); $email = mysql_real_escape_string(trim($_POST['email'])); $error = false; if(!isset($username) || empty($username)) { $error = "You need to enter a username."; } $query = mysql_query("SELECT id FROM users WHERE username = '".$username."' LIMIT 1"); if(mysql_num_rows($query) > 0 && !$error) { $error = "Sorry, that username is already taken!"; } if((!isset($password) || empty($password)) && !$error) { $error = "You need to enter a password."; } if((!isset($password2) || empty($password2)) && !$error) { $error = "You need to enter your password twice."; } if($password != $password2 && !$error) { $error = "The passwords you entered did not match."; } if((!isset($email) || empty($email)) && !$error) { $error = "You need to enter an email."; } if(preg_match("/[a-zA-Z0-9-.+]+@[a-zA-Z0-9-]+.[a-zA-Z]+/", $email) == 0 && !$error) { $error = "The email you entered is not valid."; } $query = mysql_query("SELECT id FROM users WHERE email = '".$email."' LIMIT 1"); if(mysql_num_rows($query) > 0 && !$error) { $error = "Sorry, that email is already in use!"; } if(!$error) { $query = mysql_query("INSERT INTO users (username, password, email) VALUES ('".$username."', '".mysql_real_escape_string(md5($password))."', '".$email."')"); if($query) { $message = "Hello ".$_POST['username'].",\r\n\r\nThanks for registering! We hope you enjoy your stay.\r\n\r\nThanks,\r\nJohn Doe"; $headers = "From: ".$website['name']." <".$website['email'].">\r\n"; mail($_POST['email'], "Welcome", $message, $headers); setcookie("user", mysql_insert_id(), $time); setcookie("pass", mysql_real_escape_string(md5($password)), $time); header("Location: index.php"); } else { $error = "There was a problem with the registration. Please try again."; } } } ?><html> <head> <title>Register</title> </head> <body> <form action="" method="post"> <?php if($error) echo "<span style=\"color:#ff0000;\">".$error."</span><br /><br />"; ?> <label for="username">Username: </label> <input type="text" name="username" value="<?php if($_POST['username']) echo $_POST['username']; ?>" /><br /> <label for="password">Password: </label> <input type="password" name="password" value="<?php if($_POST['password']) echo $_POST['password']; ?>" /><br /> <label for="password2">Retype Password: </label> <input type="password" name="password2" value="<?php if($_POST['password2']) echo $_POST['password2']; ?>" /><br /> <label for="email">Email: </label> <input type="text" name="email" value="<?php if($_POST['email']) echo $_POST['email']; ?>" /><br /><br /> <input type="submit" name="submit" value="Register" /> </form> </body> Okay the reason I'm doing it this way is because I work locally and then transfer them to the production site. For some reason, this isn't working even though when I view the page source, it has the right URL, but when it's clicked it goes to a blank page, but when I copy and paste, it goes to the right page. Anywho, this is what I'm trying: Code: [Select] <?php $homeURL = 'localhost:90/Elvonica'; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Elvonica</title> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <link rel="stylesheet" type="text/css" href="<?php echo $homeURL; ?>/template/css/skySpirit.css" /> I didn't plug in the rest to ignore it since it's not part of the problem. It's printing: localhost:90/Elvonica/template/css/skySpirit.css, but when it's clicked, goes to blank page. When it is copied and pasted, it goes to the right page. I have a feeling you can't include PHP inside a link rel or any sort of that header information. If anyone could please help me how to do this, I would appreciate it. FYI: I did have just template/css/skySpirit.css and it worked until I go into a another directory like forums/index.php. Then it tries to go localhost:90/Elvonica/forums/template/css/skySpirit.css and it's not in there obviously. Thank you for anything that you can offer! I know how to do the includes with the dirname(__FILE__). Hello,
I've got an overlay on my website which loads up when a button is clicked. Once the button it clicked, it parses a PHP file into a div which generates the content to be shown in the div. However, I can't seem to get the jQuery to work on buttons which are imported unless I call another Javascript file while populating the div. Does anyone know how I can get this so that it will work weather the buttons are there as the page is loaded or after extra content is brought in?
I'm presuming it's due to the
$(document).ready(function(){ });Current jQuery $(document).ready(function() { $('.CloseOverlay').click(function() { $('.OverlayContainer').hide(); }); $('.Approve').click(function() { var UserID = $(this).val(); var Status = "GetData"; $.post('/Admin/Users/Verified/approveUser.php', { UserID: UserID, Status: Status }, function(data) { $('.OverlayWrapper').html(data); }); $('.OverlayContainer').show(); }); });P.S - I'm pretty shocking at jQuery/Javascript! Thanks in advance, Andy Edited by Andy11548, 25 August 2014 - 08:31 AM. Hi All,
Don’t know if any of you have any experience with PHPWord (actually a pretty cool library I stumbled upon), but worth a shot!
So either I’m missing something very obvious, or else I just have terrible luck. I am attempting to load a .docx file with PHPWord, set a value in it, and save the file. The issue is the saved file comes out as a blank word document, 7kb in size. The document I put in is large and has multiple pages. Obviously its not loading it right. My code is as follows:
$PHPWord = new \PhpOffice\PhpWord\PhpWord(); $document = $PHPWord->loadTemplate('Resources/documents/test.docx'); $document->setValue('theDate', '2014-07-25'); $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, 'Word2007'); $xmlWriter->save("php://output");I have tried with multiple test.docx files of different sorts, but the output file is always blank. so I am about to start on a small object oriented project, for practice/learning etc. I have 5 files in a folder called "objects" : (obj1.php obj2.php obj3.php obj4.php obj5.php) . I then created a "classloader.php" with the following code: Code: [Select] <?php include "objects/obj1.php"; include "objects/obj2.php"; include "objects/obj3.php"; include "objects/obj4.php"; include "objects/obj5.php"; ?> and then finally my main page (for the sake of testing): Code: [Select] <!DOCTYPE HTML> <head> <title>...</title> </head> <?php include "classloader.php"; ?> <body> <header></header> <nav></nav> <section> <?php object1(); object2(); object3(); object4(); object5(); ?> </section> <footer></footer> </body> What is the best way to handle the loading of objects in php? I think I am doing it somewhat wrong. Anyone lend me some more info here? thanks much. |