PHP - Getting Info From Csv File
Hi Ive currently developed a script that connects via an API to send a message, and tested it with one user and it works perfectly. But now im bit stuck to send it to multiple users. All my visitors unique IDs are being stored into a file called unique.csv all in 1 column under each other. But what im currently trying to do is to recall the info from the csv and make a contact list to broadcast the message to.
The csv file looks like:
27823116700
m59317461002
Similar TutorialsHi, I was wondering if this is possible as I've been tasked (uni project) with creating a blog site that displays entries in order of creation. From what I've seen, when modifying the file I can only add entries from the bottom line and not from the top without replacing the previously stored content. Thank you. I've created a function to update the database with the information from the text file...I've already got additional code (not posted here) that displays the orders that have NOT been shipped (and works beautifully). Then when they click the button it should process the text file and update the database (input the tracking number into the database) and change the order status and send an email to the customer, I know I've got something mixed up because it's not working... function process_shipping($ordernumber, $status=''){ $order_updated = false; $check_status_query = tep_db_query("select customers_name, customers_email_address, orders_status, date_purchased from " . TABLE_ORDERS . " where orders_id = '" . $ordernumber . "'"); $check_status = tep_db_fetch_array($check_status_query); $orders_statuses = array(); $orders_status_array = array(); $orders_status_query = tep_db_query("select orders_status_id, orders_status_name from " . TABLE_ORDERS_STATUS . " where language_id = 1"); while ($orders_status = tep_db_fetch_array($orders_status_query)) { $orders_statuses[] = array('id' => $orders_status['orders_status_id'], 'text' => $orders_status['orders_status_name']); $orders_status_array[$orders_status['orders_status_id']] = $orders_status['orders_status_name']; } if ($status!==''){ if ($check_status['orders_status'] !== $status) { tep_db_query("update " . TABLE_ORDERS . " set fedex_track_num = '" . $tracking . "'orders_status = '". $status . "', last_modified = now() where orders_id = '" . $oID . "'"); $customer_notified = '0'; $notify_comments = ''; $email = STORE_NAME . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_TEXT_ORDER_NUMBER . ' ' . $oID . "\n" . EMAIL_TEXT_INVOICE_URL . ' ' . tep_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . $oID, 'SSL') . "\n" . EMAIL_TEXT_DATE_ORDERED . ' ' . tep_date_long($check_status['date_purchased']) . "\n\n" . $notify_comments . sprintf(EMAIL_TEXT_STATUS_UPDATE, $orders_status_array[$status]); tep_mail($check_status['customers_name'], $check_status['customers_email_address'], EMAIL_TEXT_SUBJECT, nl2br($email), STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); $customer_notified = '1'; tep_db_query("insert into " . TABLE_ORDERS_STATUS_HISTORY . " (orders_id, orders_status_id, date_added, customer_notified, comments) values ('" . (int)$oID . "', '" . tep_db_input($status) . "', now(), '" . tep_db_input($customer_notified) . "', '" . tep_db_input($comments) . "')"); $order_updated = true; } } } if ($_POST['update']=='1') { echo '<div class="dataTableContent" align="left">'; $arr=file("/home/onest4/public_html/beta/fedex.txt"); $x=1; foreach($arr as $str){ if (trim($str) != ''){ if ($x > 3){ list($tracking,$oID)=explode(" ",$str); if(ctype_digit($tracking)){ echo "Order# $oID, <b>$tracking</b> (DATABASE UPDATED)<br>"; } }else{ $x++; continue; } } } } Hello,
Trying to rearrange a data on the website. Looks normal when looking through preview on IE and chrome. But once moved to live website, the whole alignment changes from left to center , including the text that needs to show up. I am a newbie to coding and dont have a clue. tried puttng something together based on what i foud on the web. attaching screenshot and the code that i did. any help is highly appreciated. also attached is a screenshot of what happens when the php file is uploaded. Prior to doing that, the menu on the left is aligned properly and the assets that we have show properly.
What we are trying to do is rearrage the whole assets into different categories.
many thanks
Attached Files
portfolio.php 3.27KB
2 downloads
noalignment.png 11KB
0 downloads Okay, I'll make this short and sweet, and all side comments are irrelevant. I'm doing this for my own happies So using Facebook.com's API you can extract all of a specific user's friends in an array. Well I'm making a array check to see who on that users friend list was removed or deleted them that week using array_dif(); in this method: 1) User allows the application 2) Application catches the user's friends_id's in an array and stores them // this is where i'm having trouble, i'll come back to it 3) User then waits a few days and notices their friend count is no longer 400, it's now 399! 4) User logs into my application, and checks the previously uploaded array against their current array of friends. Okay now to the part i'm struggling with is, what would you do? Should i store them each uniquely in a database? Because some users have 4,000+ friends and that gets quite strenuous. OR! Should i save them into a txt file unique to that person's user_id. I kind of like the 2nd option, however it's less ( to my newbish mind ) customizable versus the sql_queries. Once again, i'd like to reiterate, i don't care that this is again Facebooks terms of service, it's for my own personal gain and just enjoy taking on projects in my spare time that force my brain to work hard. That's all, hope you excuse the typos and poor grammar. Typed this pretty quickly, any questions - feel free to ask! hello dear PHP-experts have set up a server at localhost with phpMyAdmin i get back the site " it works " if i type in localhost i get access to the phpMyAdmin if i type localhost/phpMyAdmin so far so good now i wanted to go ahead: i ve uploaded a file called php_info.php to the htdocs folder. i changed permissions accordingly. (see below) linux-c5sz:/srv/www/htdocs # ls -l insgesamt 28 -rwxrwxrwx 1 root root 302 13. Mär 2006 favicon.ico drwxrwxrwx 2 root root 4096 6. Nov 2013 gif -rwxrwxrwx 1 root root 45 11. Jun 2007 index.html -rwxrwxrwx 1 root root 2356 28. Sep 2013 info2html.css -rwxrwxrwx 1 martin users 188 3. Dez 19:07 php_info.php drwxrwxrwx 6 root root 4096 3. Nov 17:40 phpMyAdmin -rwxrwxrwx 1 root root 26 13. Okt 15:32 robots.txt linux-c5sz:/srv/www/htdocs #what makes me wonder is - i cannot see the content of the file of php_info.php - why is this so see below <?php // Zeigt alle Informationen (Standardwert ist INFO_ALL) phpinfo(); // Zeigt nur die Modul-Informationen. // phpinfo(8) führt zum gleichen Ergebnis. phpinfo(INFO_MODULES); ?>well i wonder why i cannt see any information in thebrowser is this a bug ? Hi.. been a while since I have touched php and need some help. What I am trying to do is have my links pull text from separate php files, and load them into main table. Here is my old php code..used to work.. I had my index.php with my website template on it. In the table I want my info to appear i put this code. <?php /* START MAIN AREA HERE */ if($news) include("news.php"); elseif($bio) include("bio.php"); elseif($draw) include("draw.php"); elseif($pic) include("pic.php"); else include("news.php"); /* END HERE */?> My link looks like this. <A HREF="?news=x" ONMOUSEOVER="changeImages('home', 'images/home-over.gif'); return true;" ONMOUSEOUT="changeImages('home', 'images/home.gif'); return true;"> <IMG NAME="home" SRC="images/home.gif" WIDTH=69 HEIGHT=31 BORDER=0 ALT=""></A> Any help much appreciated! Hey guys, It's been awhile since I've coded in PHP and I can not for the life of me remember how to do this. Say I have http://www.example.com/search.php?name=joe&size=small What the PHP code to grab the ?name=joe&size=small part? thanks Very simple question. I have a table with courses and a table with students registered for those courses. I have a page where I can change the course name. What I want to do is, when changing the course name in the course table, I want all students in the students table who are already registered for that course to have that course name updated as well in the student table. I'm currently using a field cid to update the courses in the course table however, the student table doesn't have a cid field rather a cname ( course name) which I want to use to update the fields in the student table. Is it possible to use Code: [Select] <a href=\"editcourse.php?cid=" for more than one field of info? i.e transfer the cid + cname and so you can use $_GET[cid]"; and $_GET[cname]"; ? Something like this maybe ( dont know how the code will go) "editcourse.php?cid=&cname=" ? Do I have the right idea for how to go about this? This is a multiplication test for students to take and when they finish they click the score button. after they click the score button it tells them what their score is, with the opportunity to take it again. What I am trying to do is make this able to keep the recent score and just post the next score. Right now my app just gives the first score and then when I take the test again it just refreshes and gives the new score. I want it to play the new score under the old score. I can't seem to figure out how to do this. If someone could help point me in the right direction. Would appreciate the help. Here is my code for my app.... Code: [Select] <?php require_once('database.php'); define ('ROWS', 3); define ('COLS', 3); define ('MAX_NUMBER', 12); date_default_timezone_set('America/New_York'); if (isset($_POST['btn_score'])) { $result_name= $_POST['result_name']; $correct = 0; //print_r ($_POST); $time1 = $_POST['ts']; $time1_object = new DateTime($time1); $now = new DateTime(); $time_span = $now->diff($time1_object); $minutes = $time_span->format('%i'); $seconds = $time_span->format('%s'); $seconds+= $minutes * 60; echo "It took $seconds seconds to complete the test<hr />"; foreach ($_POST as $problem => $answer) { if ($problem <> "btn_score" && $problem <> "ts" && $problem <> "result_name") { //echo "$problem -- $answer <br />"; $problem = explode('_', $problem); $num1 = $problem[2]; $num2 = $problem[3]; $right = $num1 * $num2; if ($answer != $right) { echo "$num1 * $num2 = $answer , The right answer is $right<br />"; }else { $correct = $correct + 1; } } } $result_score= 0; $result_score= ($correct / 9) * 100; echo "your score is <br/>$result_score<br/>"; } $sql = "INSERT INTO results (result_name, result_score, result_date_time) VALUES ('$result_name','$result_score', NOW());"; ?> <h1>Multiplication Test</h1> <form name="lab5" method="post" action="lab5b.php"> <?php $now = new DateTime(); //echo $now->format('Y-m-d H:i:s'); echo "<input type='hidden' name='ts' value='" . $now->format('Y-m-d H:i:s') . "'>"; ?> <table border="1" cellspacing="5" cellpadding="5"> <?php $no_of_problems = 0; for ($row=0; $row<ROWS; $row++) { echo "<tr>"; for ($col=0; $col<COLS; $col++) { $num1 = mt_rand(1,MAX_NUMBER); $num2 = mt_rand(1,MAX_NUMBER); echo "<td>$num1 * $num2 </td>"; echo "<td><input type='text' size='2' name=${no_of_problems}_mult_${num1}_${num2}></td>"; $no_of_problems++; } echo "</tr>"; } $colspan = 2 * COLS; echo "<tr><td colspan=$colspan align='right'><input type='submit' value='Score' name='btn_score'></td></tr>"; ?> Ok so for some reasons on my register and edit profile page when i hit submit it says that i have not filled in all the info i need.. Even after i fill all of them in.. but heres the code for the register form.. Code: [Select] <?php require("top.php"); ?> <div id='homeright'> <?php echo "<font size='6'>Sign up</font>"; echo "<hr width='75%' align='left'/>"; $form = "<form action='index.php' method='post'> <table cellspacing='5px'> <tr> <td>First Name:</td> <td class='register'><input type='text' name='firstname' class='textbox' size='35'></td> </tr> <tr> <td>Last Name:</td> <td><input type='text' name='lastname' class='textbox' size='35'></td> </tr> <tr> <td>Username:</td> <td><input type='text' name='username' class='textbox' size='35'></td> </tr> <tr> <td>E-mail:</td> <td><input type='text' name='email' class='textbox' size='35'></td> </tr> <tr> <td>Password:</td> <td><input type='password' name='password' class='textbox' size='35'></td> </tr> <tr> <td>Confirm Password:</td> <td><input type='password' name='repassword' class='textbox' size='35'></td> </tr> <tr> <td></td> <td><input type='submit' name='submitbtn' value='Register' class='button'></td> </tr> </table> </form>"; if ($_POST['submitbtn']){ $firstname = fixtext($_POST['firstname']); $lastname = fixtext($_POST['lastname']); $username = fixtext($_POST['username']); $email = fixtext($_POST['email']); $password = fixtext($_POST['password']); $repassword = fixtext($_POST['repassword']); $website = fixtext($_POST['website']); $youtube = fixtext($_POST['youtube']); $bio = fixtext($_POST['bio']); $name = $_FILES['avatar'] ['name']; $type = $_FILES['avatar'] ['type']; $size = $_FILES['avatar'] ['size']; $tmpname = $_FILES['avatar']['tmpname']; $ext = substr($name, strrpos($name, '.')); if ($firstname && $lastname && $username && $email && $password && $repassword){ if ($password == $repassword){ if (strstr($email, "@") && strstr($email, ".") && strlen($email) >= 6){ require("scripts/connect.php"); /*$query = mysql_query("SELECT * FROM users WHERE username='$username' ");*/ $query=mysql_query("SELECT * FROM users WHERE username='$username' ") or die(mysql_error()); $numrows = mysql_num_rows($query); if ($numrows == 0){ /*$query=mysql_query("SELECT * FROM users WHERE email='$email' ");*/ $query=mysql_query("SELECT * FROM users WHERE email='$email' ") or die(mysql_error()); $numrows=mysql_num_rows($query); if ($numrows == 0){ $pass = md5(md5($password)); $date = date("F d, Y"); if($name){ move_uploaded_file($tmpname, "avatars/$username.$ext"); $avatar = "$username.$ext"; } else $avatar = "/avatars/default_avatar.png"; $code = substr (md5(rand(11111111111, 999999999999999)), 2, 25); mysql_query("INSERT INTO users (`first_name`,`last_name`,`username`,`email`,`password`,`avatar`,`bio`,`website`,`youtube`,`last_login`,`active`,`code`,`locked`,`date`) VALUES ( '$firstname', '$lastname', '$username', '$email', '$pass', '$avatar', '$bio', '$website', '$youtube', '', '0', '$code', '0', '$date')"); /*mysql_query("INSERT INTO users (Field, Type) VALUES ('', '$firstname', '$lastname', '$username', '$email', 'pass', '$avatar', '$bio', '$website', '$youtube', '', '0', '$code', '0', '$date')");*/ $webmaster = "Admin@trucksite.com"; $subject = "Activate Your Account!"; $headers = "From: Admin <$webmaster>"; $message = "Hello $firstname.\n\nWelcome to trucksite below is a link for you to activate your account!.\n http://tprofiletesting.net23.net/activate.php?code=$code"; mail($email, $subject, $message, $headers); echo "Your activation email has been sent to <b>$email</b>."; } else echo "That email is currently in use."; } else echo "That username is currently in use."; } else echo "You did not enter a vaild email."; } else echo "Your passwords did not match."; } else echo"You did not fill in all the required fields."; } echo "$form"; ?> </div> <div id='homeleft'> <center><font size='6'>Create! Showoff! Educate!</font></center> <hr /> </div> </body> </html> hello, i am transferring the post number from a forum page, to a non-forum page via url variables.. how do i stop someone editing the url variable and viewing the posts concerned? i thought i could possibly use cookies/or a kind of auto-post form.. please help if you can.. just what to google would be appreciated hello guys i heard there is a way that you can make something like a database on a text editor and when ever u want to change the info you just open a text editor and change the information How is this called? where can i find a tutorial? any tips? thanks you very much In my script, users login with their Username & Password. However, I'd like to be able to echo the email address used on their account.
I've tried adding the email to the session I'm not having much luck... Here's a piece of the login code(untouched); $username = $_POST['name']; $passwd = $_POST['passwd']; $query = "SELECT name,passwd FROM users WHERE CONCAT('0x', hex(passwd)) = '{$salt}'"; $result = mysql_query($query); $login_ok = false; if(mysql_num_rows($result) > 0) { $login_ok = true; } if($login_ok) { $row = mysql_fetch_array($result, MYSQL_NUM); $_SESSION['user'] = $row;I've also tried messing around with this piece below in a few different ways but still nothing. <?php echo htmlentities($_SESSION['user']['email'], ENT_QUOTES, 'UTF-8'); ?>Any help is greatly appreciated.. I am parsing an rss feed from my flickr photostream using this:-
<?php $url = "http://api.flickr.com/services/feeds/photos_public.gne?id=49466419@N05&lang=en-us&format=rss_200"; $rss = simplexml_load_file($url); if($rss) { echo '<h1>'.$rss->channel->title.'</h1>'; echo '<li>'.$rss->channel->pubDate.'</li>'; $items = $rss->channel->item; foreach($items as $item) { $title = $item->title; $link = $item->link; $published_on = $item->pubDate; $description = $item->description; echo '<h3><a href="'.$link.'">'.$title.'</a></h3>'; echo '<span>('.$published_on.')</span>'; echo '<p>'.$description.'</p>'; } } ?>which gives me this as the description for each image:- public 'description' => string ' <p><a href="http://www.flickr.com/people/alfthomas/">Alf Thomas</a> posted a photo:</p> <p><a href="http://www.flickr.com/photos/alfthomas/14064465890/" title="harlaw_12"> <img src="http://farm6.staticflickr.com/5077/14064465890_83c02ecec6_m.jpg" width="240" height="110" alt="harlaw_12" /> </a> </p> <p>A view of Harlaw Reservoir.</p>' (length=338)What I actually want is the photo (linked back) without the "Alf Thomas posted a photo" bit, does anyone have any idea how I would go about cloning that bit out? Edited by foucquet, 31 May 2014 - 08:14 AM. Hi guys I need some info Am doing an upload page for pictures, that crops images to two different sizes which works fine with small images. However some larger images it doesn't work (locally it works but not on the my server provider). I can upload the file (3481 * 2346 at 300 dpi) no problem but it actually never executes the imagecreatefromjpeg($myUploadedFile). Is there any issues with large file. I've been doing some recherches but can't seem to find any answer. The obvious idea is to have people upload photos without asking them to resize them. Thanks When I get a hit on my site I like to see where they came from and if they came from a search engine what keywords they used. So here is the refer info: http://www.google.com/search?q=dog+training&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a I guess I need to split everything into an array or something. Has anyone done this? Any Ideas? Thank you! let's say I have 100,000 users on my forum i want to cache there PROFILE INFO (About me) in .php files which is easy/etc but would that be more space than 100k rows in a db table, or 100k .php files? just wondering, prob a stupid question but atm I cache some lottery info and some other stuff, but that's only 1 .php it would be dumb to cache info and have 100k .php's for each user ID right? or maybe story it all in 1 .php? would be a HUGE Filesize? rather just keep the data in MYSQL right? For some odd reason, my MySQL array is not returning any data. I echo'd the query and it is correct, I looked at the database and that row is in there, but when I print_r the array, nothing. Here is the code. $infoquery = "SELECT * FROM '$endotype' WHERE ID = '$typeid' ORDER BY ID DESC LIMIT 1"; $info = mysql_query($infoquery); echo $infoquery; $infoout = mysql_fetch_array($info); print_r($infoout); Its a very simple query and its driving me nuts. Hello Guys... I'm new to php & mySQL... I need help... Need something to know... please help me... I'm using ubuntu 11.10, Aptana Studio 3, xampp 1.7.7. Also i'm using windows 7, notepad++ & wamp. When I visit "localhost" on my firefox. I saw a xampp or wamp welcome page. The name of the file is "index.php". 1. I need to know can I delete this file ? Bcoz i'm working on another file but it's the same file name. 2. When I upload my site on host like hostgator. How do i edit my live site? And preview it. 3. How do i store my post on database ? Like fb status update, blogger post or forum post I wanna write a site that i can post something without using html <p></p>. The main problem when i need to post something then everytime I need to edit the source code. Example:<p>some text here</p>. I don't wanna edit source everytime. Another Ques: Is Aptana Studio and notepad++ enough to write a site or I need another tool ? Any book suggestion ? please guys help me i'm new to php & mySQL.. Hi. I have built a form on a page call join.php On this form I pass a variable in this manner; $url = "thankyou.php?val_id=".$validation.""; header("Location: {$url}"); So on the next page (which is the thankyou for registering page I want this page on load to find the user from the $validation and then email the user. I have done this many times but for some reason this time the output is "No database selected!" There really is though. Also I can see in the browser window the code I have passed so its not like that is not working! Here is the code, can anyone see my error because I just have no idea whats up! <?php include(thedatabase.php'); session_start(); $val_id = $_GET['val_id']; $FullRec__query=sprintf("SELECT * FROM users WHERE val_id= %s", $val_id); $FullRec = mysql_query($FullRec__query) or die(mysql_error()); $userInfo = mysql_fetch_array($FullRec); $user = $userInfo['username']; mail($userInfo['email'],"Validation Link From Us","Dear ".$userInfo['username'].",\n\nThank you for signing up to www.thesite.co.uk. Please find below you validation link to gain access to the site.\n\n link:\nhttp://www.thesite.co.uk/val_entrance.php?validation_id=" . $_GET['val_id'] . "\n\nTeam site\n\n\n\nFor a full list of terms and conditions please go to the main area on your page and click the terms at the bottom of the page!"); ?> |