Search the Community
Showing results for tags 'php'.
-
I don't seem to find a way that works to get the absolute path to root. html was simple "/" but this doesent work in php (or at least for me :P) so how can I do this?
-
Can anyone figure out what is wrong with my code i keep getting this error (Parse error: syntax error, unexpected '==' (T_IS_EQUAL) in C:\xampp\htdocs\tutorial\index.php on line 5) basically something is wrong here if (isset($_GET['file']) && basename($_GET)['file'])==$_GET['file']){ I cant figure it out. I'm a noob in training <?php //localhost/tutorial/index.php //in htdocs you have a folder named downloads and the index.php outside// if (isset($_GET['file']) && basename($_GET)['file'])==$_GET['file']){ $filename = $_GET['file']; //downloads is a folder in htdocs $path = 'downloads/'.$filename; if (file_exists($path) && is_readable($path)){ $size = filesize($path); header('Content-Type: application/octet-stream'); header('Content-Length: '.$size); header('Content-Disposition: attachment; filename='.$filename); header('Content-Transfer-Encoding: binary'); //open the file in binary read-only mode $file= @ fopen($path, 'rb'); if ($file) { //stream the file and exist fpassthru($file); exit; } } } ?> <!DOCTYPE html> <html> <head> <title>PHP Download File TUtorial</title> </head> <body> <!--index1.php was replaced with index.php by accident--> <!--randomapp is the file and .zip can be .rar--> <a href="index.php?file=code.7z">Download File</a> <!--you can add more <a href="index1.php?file=randomapp.zip">Download File</a> --> </body> </html>
-
Hello guys! I have a PHP script that is intended to plot power over time. I have a database with 10 000+ data points in the form of voltage, current and date stamps. The purpose of the PHP script is to calculate power by multiplying voltage and current and then plotting it with time on the x-axis. Right now i have put voltage in an array and just tried to plot it with a few letters on the x axis. When i try to plot the information i get no error message telling me what is wrong, i only get a small Icon with no information with in it. Is this caused because i have to few data points on the x-axis compared to the y-axis. By right now i have no idea of how i should continue to add the functionality which i require, what would a good way to continue be? I'm open to any suggestions and start over with the code if that is necessary. The code so far: <?php // content="text/plain; charset=utf-8" require_once ('/var/www/html/jpgraph/src/jpgraph.php'); require_once ('/var/www/html/jpgraph/src/jpgraph_line.php'); class MyDB extends SQLite3 { function __construct() { $this->open('/home/pi/Documents/Projects/ArduinoSerialImport/solartracker.db'); } } $db = new MyDB(); if(!$db){ echo $db->lastErrorMsg(); } else { echo "Opened database successfully\n"; } $sql =<<<EOF SELECT voltage from stuffToPlot; EOF; $voltage = array(); $ret = $db->query($sql); while ($row['voltage'] = $ret->fetchArray(SQLITE3_ASSOC)){ $voltage[] = $row['voltage']; //print_r ($voltage); echo '<pre>'; //var_dump($row); //$isScalar = is_scalar($voltage); //var_dump(isScalar); } $graph = new Graph(500,500); $graph->SetScale('textlin',-10,10,0,0); $theme_class=new UniversalTheme; $graph->SetTheme($theme_class); $graph->img->SetAntiAliasing(false); $graph->title->Set('Filled Y-grid'); $graph->SetBox(false); $graph->img->SetAntiAliasing(); $graph->yaxis->HideZeroLabel(); $graph->yaxis->HideLine(false); $graph->yaxis->HideTicks(false,false); $graph->xgrid->Show(); $graph->xgrid->SetLineStyle("solid"); $graph->xaxis->SetTickLabels(array('A','B','C','D')); $graph->xgrid->SetColor('#E3E3E3'); $p1 = new LinePlot($voltage); $graph->Add($p1); $p1->SetColor("#6495ED"); $p1->SetLegend('Voltage'); $graph->legend->SetFrameWeight(1); // Output line $graph->Stroke(); ?> Thanks a lot in advance! /J
-
Hey, friends! I was trying to install Magento 2.1.1 and now my WP sites no longer allow me to access the /wp-login, /wp-admin, or wp-register sections. To install Magento I had to enable php.intl for it to work. I just tried to disable the php plugin, however it still gives me an Error 500 when I try to load the page (and is blank in Firefox). The last time I had this happen I had root control and could access the init module to change the value of php so it would be in debug mode so I could see errors, however now I'm on shared hosting with no root access. Can someone help me. These are production sites and I don't have a failover site setup for them... If my site is completely fragged, I do have complete off-site BU's so I can always restore should that be the only option. Thanks in advanced
-
Hello, So when I call my models etc like $book = $books->where('name', 'somebook')->first(); echo $book->sales(); //returns all sales echo $book->sales->today(); //returns all sales today So this is something I could no. but here is the catch for me. how do I make the ->today(); work? Currently I have no idea how I can add more functions, "sub functions to the sales function". What am I looking for? I just need the name of this so I can learn how to do it.
-
I don't know if it's really possible to add a class tag to a link when it's pressed or not but let me walk you through what I want to do. So, when the user presses a link, I want the link to change color until another is pressed, at which point I want the first link to look like it did before it was pressed with the newly pressed link taking up the changed appearance. The only way I could think about doing it was that I have a separate class within the CSS that is styled how I want the currently pressed link to look, and then that is applied on the most recently pressed link but I'm unsure of how to actually know and dynamically change the appearance of the link when it's pressed. If anyone can help achieve this I would appreciate it greatly. EDIT: Thought, Would I be able to when the link is click include style coding to change the link appearence? for example something like this: <body> <div id="nav"> <ul> <li><a href="?link=1" class = "link1_clicked" name="link1" onclick="return false">HOME</a></li> <li><a href="?link=2" class = "link2_clicked" name="link2" onclick="return false">SEARCH</a></li> <li><a href="?link=3" class = "link3_clicked" name="link3" onclick="return false">DATABASE</a></li> </ul> </div> <?php if(isset($_GET['link'])){ $link=$_GET['link']; if ($link == '1') { <style> a.link1_clicked {color: #fff;} a.link2_clicked a.link2_clicked {color: #000;} </style> } ?> </body> Thanks in advance!
-
I am trying to have my script dynamically read a log file and stream it to the user. Here is my code (file is a tmp that I am using to test) <?php error_reporting(E_ALL); ini_set("display_errors", 1); // function disable_ob() { // Turn off output buffering ini_set('output_buffering', 'off'); // Turn off PHP output compression ini_set('zlib.output_compression', false); // Implicitly flush the buffer(s) ini_set('implicit_flush', true); ob_implicit_flush(true); // Clear, and turn off output buffering while (ob_get_level() > 0) { // Get the curent level $level = ob_get_level(); // End the buffering ob_end_clean(); // If the current level has not changed, abort if (ob_get_level() == $level) break; } // Disable apache output buffering/compression if (function_exists('apache_setenv')) { apache_setenv('no-gzip', '1'); apache_setenv('dont-vary', '1'); } } disable_ob(); echo "test"; //https://stackoverflow.com/questions/3218895/php-how-to-read-a-file-live-that-is-constantly-being-written-to $file='/home/user/youfile.txt'; $lastpos = 0; $i = 0; while ($i < 5) { //usleep(300000); //0.3 s sleep(1); clearstatcache(false, $file); $len = filesize($file); if ($len < $lastpos) { //file deleted or reset $lastpos = $len; } elseif ($len > $lastpos) { $f = fopen($file, "rb"); if ($f === false) die(); fseek($f, $lastpos); while (!feof($f)) { $buffer = fread($f, 4096); echo $buffer; flush(); } $lastpos = ftell($f); fclose($f); } $i++; } However, after 5 seconds the page loads with all the contents of the file and the test. I am at a loss for how to force it to start sending data before the 5 sec loop is finished. anything I might have missed?
-
So I am a total php noob so fell free to point any major issues out. Anyways I have a web server running the latest versions of apache and php on ubuntu 16.04. So here is the issue. I need to use composer. I have installed composer. Now I need to use the autoload function. In theory to do this all you do is require autoload.php which is located in /root/vendor. So I try require __DIR__ . '/root/vendor/autoload.php'; I get a warning followed by a fatal error with basically the same message The key part of the above is No such file or directory in /var/www/HTML/sandbox5678/StreamIt/index.php on line 6 This tells me that php is looking only in the folder where the file is running my question is how do I make it look somewhere else???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
-
Hello, I want to create a "enable and disable" function. I did create a form that submited the post "status" with enable or disable. This works but is it the way to go? I want to use this themes switch which is a checkbox to enable or disable. But then I'm in need of the form auto submitting each update and how I would create the backend to work with that (simple if this then code goes here). How would you go about this? I also wanna move over to ajax later as I think it's cool not to update the page. (should I go with Vue or just pure javascrupt?)
-
Looking for an experienced PHP and MySQL Developer to help create a Single Sign On System for my Organisation. This SSO System needs to be integrated with myBB and phpVMS, 2 items of software we use, and also allow us to expand with other services we may choose to use in the future. Thank you
-
When I save php files in Web Expression 4, the software seems to save the file as text files despite having a php extension and when I preview the page on the browser it is showing the source code in plain text instead of a rendered web page. Does anyone know how to fix this?
-
Hello, I am trying to make a login page that with javascript will verify if the email is in a correct email format. If it is a valid email format the box will have turn to a green border color and if it is in a invalid format the box will turn red and will disbale the submit button. Right now I have two files, index.html and log.php <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Please Login</title> <link rel="stylesheet" href="style.css"> </head> <body> <form action="log.php" method="POST"> <input name="email" id="email" type="email" /> <input name="password" id="passowrd" type="password" /> <input type="submit" name="submit" value="Submit"> </form> </body> </html> <?php if(isset($_POST['email']) && isset($_POST['password'])) { $data = 'Email: ' . $_POST['email'] . ' Password: ' . $_POST['password'] .$ $ret = file_put_contents('mydata.txt', $data, FILE_APPEND | LOCK_EX); if($ret === false) { die('An error occured'); } else { echo "Success"; } } else { die('no post data to process'); } ?> I know that logging the data to a txt file is not secure but later on I will implement either google firebase or MySQL. Thanks!
-
I want to start a website that users can register and login. and after logging in I want users to be able to submit input-fields that I specify and get all the users login details (to know which user submitted the form to the database) only registered users, and none registered users can't get to the submission input fields. how do I start this where to search?? most of the Youtube videos only do a register and login tutorial without counting how to give certain features to the logged-in users. The language I want to use is PHP. Thanks,
-
I am currently working on a form that appends events to a text file used by a calendar on my website. What I am struggling with is the PHP script which interprets the date variables from the form into a date for the events.txt file. The script I have written gives this error when run: The relevant code I am working with: I very new to PHP and HTML, any help is appreciated
-
Hi, I currently installed Lan Party Manager 4 on my cPanel host and worked nice. Link to GitHub: https://github.com/tech-nik89/lpm4 But when I came to the install part of the website I need some help! Here is an image of my problem: http://prntscr.com/gj25ii How do I update chmod of the directory? Best regards, henriksen67
-
So I'm a competition management system for a certain sport, which will support a variaty of different scoring software packages to communicate with. One of the requirements of this system is that it will be easy to use and cheap to use. The system should work for very small competitions and bigger ones. So I want to see if it's possible to make an online solution which can also work in a offline situation, why you ask? Well this system has to run in all kinds of different venues, some of them have very crappy or even no internet at all, so the system shouldn't be reliable on internet to function. But on the other hand in a small setup it would be nice if it could work just online so people don't have to install anything. So my idea is to have different "roles" in the programming and have RESTFUL API's commuicating with each other between these roles. each role can function online or offline and you just need to configure (or it will be done for you probably) which IP it has to communicate with. Now for the bad idea, I want to program this in php because of the high database dependacies and because I know php pretty okay. Another reason is because most webservers allow for php and i don't want to be restricted in which host/server is used by using for example node.js and finding it's not supported. So the question I want to have a php script running on a desktop. This is not that hard, i found solutions like "php desktop" which can do this. But preferbly I also want my code not to be viewable. Does anyone know for any licencefree/free applications which can be used to do this propperly?
-
Hey im trying to create a simple php register script using this code but it keeps staying on this page after i press register pls help <?php include ('dbconn.php'); $newuser = $_POST['usernameinput']; $newpwd = $_POST['passwordinput']; $insert = mysqli_query($con, "INSERT INTO users (`username`, `password`) VALUES ('".$newuser."', '".$newpwd."');"); if ($insert) { header("Location: /beta/reg-success"); } ?>
-
I'm trying to make a login system in PHP but it keeps saying my login is wrong please help. <?php session_start(); include('dbconn.php'); $username= $_POST['username']; $password= $_POST['password']; $username = stripslashes($username); $password = stripslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); $result = mysqli_query($con, "SELECT username, password FROM users WHERE username = '".$username."' AND password = '".$password."'"); $count =mysql_num_rows($result); if ($count==1){ header("Location: index.html"); } else { echo"Nope"; } ?>
-
Hi there, so I have simple website on symfony, and I use scss for styles. So for now what I do, is basically compile scss files to single css file and upload to server. So the problem is that I need php library's for that, as server doesn't have node or java installed.So far JavaScript minimizing I'm using jsqueeze and I found that there scssphp for scss. So what are opinions for these library's, are they good, or in my case I should stay at local compiling ? Or maybe there are better alternatives?
-
Hello, I'm updating a project that I made a few years ago, and wanted to update some of the api responses and would really like your feedback on what a better response would be. So this small section displays races, I've formatted the response to make it easier to read. This is the old JSON response from the api: { "races": [ { "race_title": "test", "race_id": "1551", "race_desc": "I like big butts and I can't deny", "race_short_desc": "I like big butts and", "race_active": "true", "race_map": null, "race_image": null, "race_cover": "", } ], "count": 1 } And this is something that I just typed up: { "races":[ { "race_title":"", "race_id":"", "race_active":true, "extra":{ "race_desc":"", "race_map":{ "enabled": false, "src":"" }, "race_image":{ "enabled": true, "src":"" } "race_color":{ "enabled":false, "color":"rgba(255,255,255)" } } } ], "count":1 } I'm looking for a good way I could format the data to seem better. I was going to ask my friends *they exist I swear* however it's 3am and well, they're asleep and I'd rather have a more community response. Regards, Leon.
-
Hello. I'm trying to attach roles to my users when registrating Role.php class Role extends Model { public function users() { return $this->belongsToMany('App\User', 'role_users', 'role_id', 'user_id'); } } In User.php public function roles() { return $this->belongsToMany('App\Role', 'role_users', 'user_id', 'role_id'); } My roles id slug name 1 admin Administrator 2 default Member So in my registerController I got this /** * Create a new user instance after a valid registration. * * @param array $data * @return User */ protected function create(array $data) { $user = User::create([ 'name' => $data['name'], 'email' => $data['email'], 'password' => $data['password'], 'gender' => $data['gender'], 'country' => $data['country'], 'birthday' => $data['birthday'], ]); $role = new Role(['slug' => 'default']); $user->roles()->save($role); return $user; } But this throws Illuminate \ Database \ Eloquent \ MassAssignmentException slug I'm not sure that my registerController is close to correct as I saw thats how someone else did it and I just had to try. The other way I saw someone do was this /** * Create a new user instance after a valid registration. * * @param array $data * @return User */ protected function create(array $data) { $user = User::create([ 'name' => $data['name'], 'email' => $data['email'], 'password' => $data['password'], 'gender' => $data['gender'], 'country' => $data['country'], 'birthday' => $data['birthday'], ]); $role = Role::where('name', 'Member')->first(); $user->save(); $user->roles()->attach($role); } How do you do this? If you need more info from me let me know as I'm new to laravel
-
I already uploaded my things to my site. I got two problems: 1. There's an annoying ') in the left (CTRL+F and copying that string didn't found any match case) 2. I can't center the divs Here's the scripts for the front-end as well as the back-end
-
Hello. To start I'm quite new to Laravel and I'm not quite sure what can be used for what. I'm not sure what info I need to give on this for you to be able to help so please ask if I missed something! So I have a search form public function index() { $name = \Request::get('name'); $email = \Request::get('email'); if (($name) or ($email)) { $users = User::where('name', 'LIKE', '%'.$name.'%') ->Where('email', 'LIKE', '%'.$email.'%') ->paginate(10); } else { $users = User::paginate(10); } return view('admin.user.index', compact('users')); } And I have a table with roles and a table with users in roles. I would be able to select "Admin and Mod" and have it display all users that are in Admin or Mod. This is a part of the role stuff if that can be used public function roles() { return $this->belongsToMany('App\Role', 'role_users', 'user_id', 'role_id'); } public function hasAnyRole($roles) { if (is_array($roles)) { foreach ($roles as $role) { if ($this->hasRole($role)) { return true; } } } else { if ($this->hasRole($roles)) { return true; } } return false; } public function hasRole($role) { if ($this->roles()->where('slug', $role)->first()) { return true; } return false; }
-
Hello everybody, I'm using the Quickbooks Web SDK trying to do a simple invoice query with the example_invoice_query.php file. I keep getting this error: Here is my file structure: Here is my Loader file <?php /** * File/class loader for QuickBooks packages * * Copyright (c) 2010 Keith Palmer / ConsoliBYTE, LLC. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.opensource.org/licenses/eclipse-1.0.php * * @package QuickBooks * @subpackage Loader */ // if (!defined('QUICKBOOKS_LOADER_REQUIREONCE')) { define('QUICKBOOKS_LOADER_REQUIREONCE', true); } if (!defined('QUICKBOOKS_LOADER_AUTOLOADER')) { define('QUICKBOOKS_LOADER_AUTOLOADER', true); } /** * */ class QuickBooks_Loader { /** * */ static public function load($file, $autoload = true) { //print('loading file [' . $file . ']' . "\n"); if ($autoload and QuickBooks_Loader::_autoload()) { return true; } static $loaded = array(); if (isset($loaded[$file])) { return true; } $loaded[$file] = true; if (QUICKBOOKS_LOADER_REQUIREONCE) { echo $file; require_once QUICKBOOKS_BASEDIR . $file; //<------------- Here is line 56 } else { echo $file; require QUICKBOOKS_BASEDIR . $file; } return true; } /** * */ static protected function _autoload() { if (!QUICKBOOKS_LOADER_AUTOLOADER) { return false; } static $done = false; static $auto = false; if (!$done) { $done = true; if (function_exists('spl_autoload_register')) { // Register the autoloader, and return TRUE spl_autoload_register(array( 'QuickBooks_Loader', '__autoload' )); $auto = true; return true; } } return $auto; } /** * */ static public function __autoload($name) { if (substr($name, 0, 10) == 'QuickBooks') { $file = '/' . str_replace('_', DIRECTORY_SEPARATOR, $name) . '.php'; QuickBooks_Loader::load($file, false); } } /** * Import (require_once) a bunch of PHP files from a particular PHP directory * * @param string $dir * @return boolean */ static public function import($dir, $autoload = true) { $dh = opendir(QUICKBOOKS_BASEDIR . $dir); if ($dh) { while (false !== ($file = readdir($dh))) { $tmp = explode('.', $file); if (end($tmp) == 'php' and !is_dir(QUICKBOOKS_BASEDIR . $dir . DIRECTORY_SEPARATOR . $file)) { QuickBooks_Loader::load($dir . DIRECTORY_SEPARATOR . $file, $autoload); //require_once $dir . '/' . $file; } } return closedir($dh); } return false; } }
-
Hello. So I'm creating a page to display all the users, but I want a few things that I do not know how I would go by creating. I want to be able to search for users, use a filter and have paginations. I could not find something like this by googling so how would I go by doing this?