PHP - Hard Php Question, Regarding Files
Please delete my other post as I realized it is not what I needed and I cannot delete it myself.
Here is exactly what I need. I have X amount of text files (with random names) in each text file there is Y amount of lines with one word on each line. I need to open all X amount of files and take the first line from each and save it in a new txt doc. then take the second line of each and save them to a new text doc. and so on. so I have all the line 1's from all the txt files together and all the line 2's together etc. I hope that makes sense. Similar TutorialsSorry this may sound insane. Is there anyway to accomplish this, using paypal you can creat buy it now buttons and whatnot. The problem with these is you set the price of the time when making the button. Is there a way to set the price with php thus creating a dynamic price instead of a static one? I know you can send paypal vars. but is there a way to edit the price? Thanks I hope that makes sense at all I am running to an issue that I have never delt with before and am not sure if there is even a possible solution: I have two files: fileA and fileB fileA contains a loop that loops 30 times each time its called. in the loop there is a 2second delay $i = 1; do { $i++; sleep(2); if(!isset($_SESSION['user']) { break; } } while($i < 31); if fileB i have a simple destroy session $_SESSION = array(); session_destroy(); I call both files via ajax, and that is where i run into my problem. if I call fileA first, then call fileB through ajax, the code in FileB does not execute until fileA has run its course. Is it possible to get around this? Like set the priority of one over the other? In my system I have a collection of php files which handle the requests from my ajax e.g. I have a function which lets users "subscribe" to another user's posts "userConnect()" and another function which lets a user uprate another user's post "uprate()" At the moment the uprate() function uses ajax to pass it's data to a file called "ajax_uprate.php" and the userConnect() function similarly passes it's data to a file called "ajax_userConnect.php". Would I be better to combine these files into one global ajax.php file or is it better to keep them seperate? Basically I am wondering because at the moment I have a tonne of ajax_XXX files for every single function, each containing a very small amount of code. My thinking was that the smaller these files are the faster these ajax processes would take place. Am I right in thinking this or not? Hello I have the following code from php websites
$myfile = fopen("/config.php", "a+") or die("Unable to open file!"); while(!feof($myfile)) { echo fgets($myfile) . "<br>"; $txt = "Mickey Mouse\n"; fwrite($myfile, $txt); }inside config.php is <?php define('script_path', 'files'); ?>How can I replace files with another value? any help would be great thanks. Hello, I never dealt with such a feature before but I found a small script online that I am editing that works just fine. The problem is that it includes all of the directories in the path of my site in the zip. So if the path of my webhost is: /home/bob/files/ the zip will create a folder such as /home (inside that folder) /bob (inside that folder) /files (then the zipped files I wanted). I just want the zip files and I did store them out of the www/public_html directory to prevent people from downloading the files directly from the web but is there no way to make it not include all of those directories in the zip and only show the files? If so I will post the code that I have. Thanks i am trying to make a page to upload music to my website and add the information of the songs into a database, but i cannot get php to let me upload a file bigger than 2mb even after i went into the php.ini and changed the max_upload_size and a few others to 99mb. So i was wondering if i could put my music in a folder on my website and pull the data from the items in the folder and make database entries(probably doubtful) or if i could get some help with getting php to upload bigger files? thanks, Adam I'm a little confused with the use of absolute paths in PHP. I've always used relative paths but it's becoming an issue with some of the apps I'm working with and absolute would solve the problem. The thing is, I'm getting different results in different places and I'm a little confused. With regular HTML I seem to be able to use / as the root of my site. So if I do the following... Code: [Select] <img src="/images/name.jpg" /> That works fine no matter what page it's called from in the site and no matter what directory that page is in. I need to be able to do that same thing with PHP. Now, in my custom 404 page I have the following... Code: [Select] if($AddressURL == 'http://www.domain.com/blog/files/filename.zip') { header('HTTP/1.1 301 Moved Permanently'); header('Location: /download/filename.zip'); exit(); } That actually works just fine. If I go to the /blog/files/filename.zip (which doesn't exist) in a web browser it winds up downloading the file at www.domain.com/download/filename.zip as expected. Now where I get confused is that include files don't seem to work like that with PHP. If I do this... Code: [Select] require_once('/includes/config.php'); That winds up looking for an /includes folder all the way back at the local server root, not just the web root. so it's looking for /var/includes instead of /var/www/includes and of course that doesn't end up working. So, how come the include file paths work differently than regular HTML paths or header redirects in PHP? Is there any simple way I can always refer to the SITE root no matter what server it's running from? I've tried playing with $_SERVER['DOCUMENT_ROOT'] but it only seems to return the root of the current document, not the root of the whole site. So if I use it within a php file located in /var/www/includes/test.php it considers /includes the root which is not what I want. Any information would be greatly appreciated. Thanks! This may sound like a very stupid question, but I can't find a clear answer anywhere. I'm making my first dive in OOP and all the tutorials only really show basic usage. They define a class, and show how to use it in a file. My question is how does it work to use an object throughout a program? Is it available everywhere or do I store things in sessions and start a new object on each page? For example: logging in a user. If I created an instance after confirming the credentials, would that same instance be available for use in say index.php, or would I just pass a session over and create a new instance on each page? Again, sorry if this seems dumb to some people. So say i have this: Code: [Select] <link rel="stylesheet" media="all" type="text/css" href="_css/styles.css" /> now the file that is linking to that is 3 directories deep, besides using a rel or absolute link, could i define the path by using something like this Code: [Select] <link rel="stylesheet" href="<?php require($_SERVER['DOCUMENT_ROOT'] . "/_css/portfolio-styles.css"); ?>" type="text/css" /> but this is actually opening the CSS in the header thanks for any explanation on how to do this I something like this to happen...
A user has a text field and a button, he enters text in the field and clicks the button it will go to a URL. Once it goes to that URL it has a text field, this field would be automatically completed from what the user typed in at the start. On that URL there is also a button, that is automatically clicked once the text field has been automatically entered.
BUT the user only sees the first page where he entered text in the field and clicked the button. Everything that happens after he clicked that button he cannot see.
Is there a particular phrase you would call this from what is happening? If so, what is it and how would I do it? This probably is hard to understand but I tried :/
Thanks
Get a hugh problem with a work in school! We are suposed to optimize a website for moblie devices.. Just by using xhtml, css and php. the problem is that I want the meny to just show at the front page for mobile devices.. I konw that I can choos pic with < img > < media="only screen and (min-width: 640px)" src="bild1.jpg" /> < media="only screen and (min-width: 800px)" src="bild2.jpg" /> </ img > is it possible to do a if construct in any point with using media? please help, Im lost. I get the following error: Quote Parse error: syntax error, unexpected ';' in /hermes/web06/b1946/moo.rghollenbeck/index.php on line 35 But here is the only php code on the whole page: . . .more html code above <?php // PHP version: 5.2.12 // MySQL Version: 5.0.77 $link = mysql_connect('path', 'username', 'pword'); if (!$link) { die('Could not connect: ' . mysql_error()); } mysql_select_db(guestlist); $Users_IP_address = $_SERVER["REMOTE_ADDR"] ; echo "<input type='hidden' name='ip' value="; echo $Users_IP_address; echo ">"; $first_name=mysql_query("SELECT 'fname' FROM tblMain; WHERE 'ip'=" . $Users_IP_address); // pseudocode section: // If $first_name !null{ // echo "Hello " . $first_name; // } // end pseudocode section: // something like that ?> more html code below. . . Thank you. Ok all I need some help with this. I have been stuck for two days. Basically I have a form that asks a registrant their gender and age, then my script spits out a list of race categories they qualify for. The situation calls for the registrant to be able to register for any category YOUNGER than them, but not older. Screen Shot #1 shows my database setup (this can be changed if you have any better ideas...) that holds the race category information. Here is the sql statement I am using to pull a female racer information, where $race_age is their submitted age. "SELECT * from counts where female=1 and $race_age < age_end and $race_age > age_start" This works, but doesn't pull any categories YOUNGER Than their age. I'm stumpped Thanks for any help in advance. Hey guys, this is what I'm trying to do. I want to print on the member's profile page, a list of the products he has bought so far. I've come with two solutions: A) add a new field to the products' table, with the ID of every clients that bought that product; B) add a new field to the members table, with the ID of every products he bought; These are pretty similar approaches, but I've no idea on how can this be done. It would look like: Bought: 2, 3, 4, 5, I dont know how to write this data or how to read it. Any idea? Thanks! hey guys so I have this code: $result = mysql_query("SELECT * FROM pec_mssgs ORDER BY (y / m) DESC, d ASC"); while($row = mysql_fetch_array($result)) { echo "•<a style='text-decoration: underline; font-weight: bold;' href='../index?id=".$row['id']."'>". $row['m']."/".$row['d']."/".$row['y'] . " - ".$row['title']."</a>"; echo "<br /><br />"; } in my database instead of doing date I have 3 rows d, m, y, which correlate to day, month, year. now currently its echo out a list and sorting by year then month then day this way the events which are happening soonest will be at top. the problem is it shows events that has already passed. what do I do? It will be way to much work to to back and recode the application to just use date. is there a way I can create a var. using my d/m/y then compare that var. to the current date or something? thanks for the help. In ubuntu 18.10 , i created a folder name db in the external usb hard dirve changed the ownership to the www-data the apache2 server and set the permissions to 777 , i run this php code and get the permission error: <php chdir('/media/user/e46cafba-2656-4e42-b1c9-6417f28839df/db/'); system('./rs'); ?> but the php code cannot change to the dir and get the error: [21-Feb-2019 10:43:26 UTC] PHP Warning: chdir(): Permission denied (errno 13) in /home/user/www/html/rse4db.php on line 5
I'd like to detect emails that hard bounce after i send out my newsletter, and then delete them from the table that stores them in my database. Any ideas? Thank you. Hi guys, Here's my problem. My company wants to use SSRS to generate reports. The backend, what stores the data for the report is MS SQL 2005 (and no, I can't upgrade it to 2008, we don't have the licenses for it). When I used one of their examples to login, I got an error stating that the URL, username or password might not be correct. But when I do this, I connect just fine: Code: [Select] $client = new SoapClient("http://sampleURL/reportserver/reportexecution2005.asmx?wsdl", array('login' => "lmaster\SVCWEBDOCS", 'password' => "pdfconverter")); Now, honestly, I don't know much about this and I'm still doing some research, has anyone tried to make this SDK spit out a report? I'd appreciate some guidance/direction as to what to do next. Also, if you could tell me about some of your experiences in getting to work, I'd really appreciate it. This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=328677.0 Hi all, I have created a successful registration and login page for what will eventually be a squash league website. I am struggling with the following issue. When a player logs in using their email address and password I want to populate some drop down boxes which are relevant to the person who has just logged in. These drop downs should show all the leagues the logged in user belongs to and the other drop down should show all the players the currently logged in player has ever played against so that they could view a head to head. So my code works but currently I have the id of the player who has logged in hard coded in my sql statements. I'm wondering if anyone can help me so that I can pass in the id of the player who is logged in as obviously the whole site is not going to work with hard coded values. The code is as follows: Code: [Select] <?php include_once $_SERVER['DOCUMENT_ROOT'] . '/includes/magicquotes.inc.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/access.inc.php'; if (!userIsLoggedIn()) { include 'login.html.php'; exit(); } if (!userHasRole('Squash Administrator')) { $error = 'This page is only for Squash Administrators.'; include 'accessdenied.html.php'; exit(); } if(isset($_REQUEST['email'])) { include $_SERVER['DOCUMENT_ROOT'] . '/includes/db.inc.php'; $email = mysqli_real_escape_string($link, $_REQUEST['email']); $sql = "SELECT id, firstname, lastname, email FROM player WHERE email = '$email'"; $result = mysqli_query($link, $sql); if(!$result) { $error = 'Unable to select players firstname from the database.' . mysqli_error($link); include 'error.html.php'; exit(); } while($row = mysqli_fetch_array($result)) { $players[] = array('id' => $row['id'], 'firstname' => $row['firstname'], 'lastname' => $row['lastname'], 'email' => $row['email']); } // //POPULATE THE OPPONENTS DROP DOWN BOX TO SHOW ALL PREVIOUS OPPONENTS // $sqlid = "SELECT id FROM player WHERE email = '$email'"; $playerid = mysqli_query($link, $sqlid); $sql = "SELECT DISTINCT player.firstname, game.player2_id AS opponent_id FROM player INNER JOIN game ON player.id = game.player2_id WHERE player1_id = '$row['id']' UNION SELECT DISTINCT player.firstname, game.player1_id AS opponent_id FROM player INNER JOIN game ON player.id = game.player1_id WHERE player2_id = '$row['id']'"; $result = mysqli_query($link, $sql); if(!$result) { $error = 'Unable to populate the players dropdown from the database.' . mysqli_error($link); include 'error.html.php'; exit(); } while($row = mysqli_fetch_array($result)) { $opponents[] = array('id' => $row['opponent_id'], 'firstname' => $row['firstname']); } include 'squash.html.php'; } ?> Thanks for your help and time in advance. |