PHP - Yahoo Finance And Php Script Issue
It seems something has changed at Yahoo Finance. I use a Stock quote script (micro stock) to post stock
quotes from specific tickers on my website. It worked fine for years until recently. Now i am unable to access any data directly from any Yahoo finance URL. Hereafter my script which comes from 1) Micro Stock : http://www.phptoys.com/product/micro-stock.html or 2) Getting Stock Quote : http://www.phptoys.com/tutorial/getting-stock-quote.html <?php function getStockSite($stockLink){ if ($fp = fopen($stockLink, 'r')) {$content = ''; while ($line = fread($fp, 1024)) {$content .= $line;}} return $content;} function processStockSite($wurl){ $wrss = getStockSite($wurl); $text = ''; if (strlen($wrss)>100){ // Get text $spos = strpos($wrss,'</span>:',$spos)+3; $spos = strpos($wrss,'<big>',$spos); $epos = strpos($wrss,'</div><h1>',$spos); if ($epos>$spos){ $text = substr($wrss,$spos,$epos-$spos);} else {$text = '-';}} // Get results $result['text'] = $text; return $result;} <html> <head> <title>Get Stock tutorial</title> </head> <body> <?php // Get stock data $data = processStockSite('http://finance.yahoo.com/q?s=GOOG'); echo $data['text']; ?> I am not php programmer and i hope someone can help me in this matter since that script was a marvel. Thank in advance. Similar TutorialsI am attempting to add a estimated payment on my website, getting stuck on the interest amount.
Here's what I'd like to do:
(These will vary based on the year of the car, here for demonstration purposes)
Hi every one I've downloaded some classes but they weren't work . How do I send a private message? thanks If your working with Yahoo API, or Yahoo Scraping, is there a way to detect the 999 error. I have an App that deals heavily with Yahoo scraping. However, Yahoo after awhile has the 999 error. What I want to do is detect when it returns the error, serialize all the arrays up into a database, and allow the client to try it again later when Yahoo has removed it's blocking restriction (after about an hour). So, what I have thought about is doing a standard detection script. Just to see if the text 999 was found. SO the function that I use to get data from Yahoo, after awhile it returns: Quote Warning: file_get_contents(http://siteexplorer.search.yahoo.com/search?p=http://http://www.seomarketing.com&bwm=i&bwmf=u&bwms=p&fr2=seo-rd-se&b=1501) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 999 Unable to process request at this time -- error 999 in /var/www/vhosts/seomarketing.com/httpdocs/seotools/competitiveanalysis/functions.php on line 86 What I want to do is supress that error (Which I can do with Error Reporting, or the @ symbol. That is easy. What I also want to do is put up a conditional. if (file_get_contents($url) throws a warning) { // Do some database work. } I can't figure out the best way to approach this. Any advice? Hello, everyone. I'm still kind of new at this, so please bear with me. I've customized a website (hosted by Yahoo Small Business) which is now fully functional aside from the "Contact Us" page. I have a PHP file named "send_email.php" uploaded to my root directory which has the following code: <?php $contact_name = $_POST['name']; $contact_email = $_POST['email']; $contact_subject = $_POST['subject']; $contact_message = $_POST['message']; if( $contact_name == true ) { $sender = $contact_email; $receiver = "my@email.com"; $client_ip = $_SERVER['REMOTE_ADDR']; $email_body = "Name: $contact_name \nEmail: $sender \n\nSubject: $contact_subject \n\nMessage: \n\n$contact_message \n\nIP: $client_ip \n\nFlash Contact Form provided by http://www.flashmo.com"; $extra = "From: $sender\r\n" . "Reply-To: $sender \r\n" . "X-Mailer: PHP/" . phpversion(); if( mail( $receiver, "Flash Contact Form - $contact_subject", $email_body, $extra ) ) { echo "success=yes"; } else { echo "success=no"; } } ?> I went ahead and changed "my@email.com" to my actual email address. The problem I'm having, though, is that the form fails every time...except if I enter my own email address in the "Email" field which should be filled in by the customer. I can't figure this out. It's probably something simple that I'm doing wrong, or perhaps it has something to do with Yahoo Web Hosting. I'm also thinking I have to fill something in the "Client IP" section of the code...but I'm not sure what should go there. I'd really appreciate your time and responses. Thanks so much. Hello, For months I'm looking for a weather script for my modest blog I finally have a php script that displays yahoo weather (5 days) in English (TUE, WEN, THU, ...) It would be nice if someone can tell me if there is a way, function or script, to translate these days in French Yahoo team says that it is not possible :http://developer.yahoo.com/forum/General-Discussion-at-YDN/Can-Yahoo-Weather-API-show-by/1275022713000-d78748d9-0247-313b-ad9e-3503b8ea3d07 Cordially, Kim. Hey guys, newbie here love the site, lots of great info, hopefully one of u guys can help me out. i have adapted code from http://www.singhvishwajeet.com/2009/06/25/using-php-to-get-stock-quotes-from-yahoo-finance/ (which is free to use) i have been working on a way to enter a company code, e.g. BARC -barclays bank, on one page then on another im trying to serahc the yahoo csv for a number of specific numbers that are "live" and then output them on my site, which in turn i shall work with but i cant seem to out put the data, its the $stat bit im struggling with i will attach the files, hopefully someone can help me I'm using a simple form to grab an email address and send the person who signs up and automatic response. It was working for a while and now it's not. Not sure what happened. My hosting company told me to look into my headers. Can anyone help? Here is my code. Thanks, Code: [Select] <?php /* Set e-mail recipient */ $subject = "Sign Up"; $headers = "From: admin@xxx.com" . "\r\n" . "CC: admin@xxx.com"; /* Check all form inputs using check_input function */ $sign_up_email_address = check_input($_POST['sign_up_email_address'], "Please enter your email address."); /* If e-mail is not valid show error message */ if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $sign_up_email_address)) { show_error("E-mail address not valid"); } /* Let's prepare the message for the e-mail */ $response_message = "Sample Message"; /* Send the message using mail() function */ mail($sign_up_email_address, $subject, $response_message, $headers); /* Functions we used */ function check_input($data, $problem='') { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); if ($problem && strlen($data) == 0) { show_error($problem); } return $data; } function show_error($myError) { ?> <?php echo $myError; ?> Thank you, I have successfully used the Yahoo local search API and received results in XML format. I am trying to use PHPs Simple XML to parse the data into an array so I can loop through and print specific elements. I cannot get to specific elements and I have read several threads online. Below is some code and below that is the XML. I am trying to get to the elements like title, address, etc. Code: [Select] $url = 'http://local.yahooapis.com/LocalSearchService/V3/localSearch?appid=<my yahoo api key>&category=Casinos&query=blackjack&zip=95035&radius=20&results=10'; $xml = file_get_contents($url); $phpobject = simplexml_load_string($xml); foreach($phpobject->attributes() as $name=>$attr) { $res[$name]=$attr; } Code: [Select] <ResultSet xsi:schemaLocation="urn:yahoo:lcl http://local.yahooapis.com/LocalSearchService/V3/LocalSearchResponse.xsd" totalResultsAvailable="48" totalResultsReturned="10" firstResultPosition="1"> − <ResultSetMapUrl> http://maps.yahoo.com/broadband/?q1=Milpitas%2C+CA+95035&tt=poker&tp=1 </ResultSetMapUrl> − <Result id="34179399"> <Title>Bay Area Poker Chip</Title> <Address>1274 Piper Dr</Address> <City>Milpitas</City> <State>CA</State> <Phone>(408) 263-8611</Phone> <Latitude>37.412359</Latitude> <Longitude>-121.891794</Longitude> − <Rating> <AverageRating>5</AverageRating> <TotalRatings>1</TotalRatings> <TotalReviews>1</TotalReviews> <LastReviewDate>1198993183</LastReviewDate> − <LastReviewIntro> I bought 100% real clay chips from here and obsolutely love it. I had a poker game that night and needed chips and a table. They had everything in stock and saved me time to look around. Great products and great service and I highly recommend this place to anybody </LastReviewIntro> </Rating> <Distance>1.33</Distance> − <Url> http://local.yahoo.com/info-34179399-bay-area-poker-chip-milpitas </Url> − <ClickUrl> http://local.yahoo.com/info-34179399-bay-area-poker-chip-milpitas </ClickUrl> − <MapUrl> http://maps.yahoo.com/maps_result?q1=1274+Piper+Dr+Milpitas+CA&gid1=34179399 </MapUrl> <BusinessUrl>http://bayareapokerchip.com/</BusinessUrl> <BusinessClickUrl>http://bayareapokerchip.com/</BusinessClickUrl> − <Categories> <Category id="96928631">Graphic Design</Category> </Categories> </Result> − <Result id="44540748"> <Title>Bay Area Poker Chip</Title> <Address>519 Montague Expy</Address> <City>Milpitas</City> <State>CA</State> <Phone>(408) 263-8611</Phone> <Latitude>37.409925</Latitude> <Longitude>-121.89489</Longitude> − <Rating> <AverageRating>NaN</AverageRating> <TotalRatings>0</TotalRatings> <TotalReviews>0</TotalReviews> <LastReviewDate/> <LastReviewIntro/> </Rating> <Distance>1.48</Distance> − <Url> http://local.yahoo.com/info-44540748-bay-area-poker-chip-milpitas </Url> − <ClickUrl> http://local.yahoo.com/info-44540748-bay-area-poker-chip-milpitas </ClickUrl> − <MapUrl> http://maps.yahoo.com/maps_result?q1=519+Montague+Expy+Milpitas+CA&gid1=44540748 </MapUrl> <BusinessUrl>http://www.bayareapokerchip.com/</BusinessUrl> <BusinessClickUrl>http://www.bayareapokerchip.com/</BusinessClickUrl> − <Categories> <Category id="96925976">Sporting Goods</Category> <Category id="96935378">Games</Category> </Categories> </Result> − <Result id="67710717"> <Title>Poker Da Vinci</Title> <Address>51 E Campbell Ave</Address> <City>Campbell</City> <State>CA</State> <Phone>(408) 866-4446</Phone> <Latitude>37.287157</Latitude> <Longitude>-121.94942</Longitude> − <Rating> <AverageRating>NaN</AverageRating> <TotalRatings>0</TotalRatings> <TotalReviews>0</TotalReviews> <LastReviewDate/> <LastReviewIntro/> </Rating> <Distance>10.40</Distance> − <Url> http://local.yahoo.com/info-67710717-poker-da-vinci-campbell </Url> − <ClickUrl> http://local.yahoo.com/info-67710717-poker-da-vinci-campbell </ClickUrl> − <MapUrl> http://maps.yahoo.com/maps_result?q1=51+E+Campbell+Ave+Campbell+CA&gid1=67710717 </MapUrl> <Categories/> </Result> − <Result id="21599986"> <Title>Bay 101 Banquet Facilities</Title> <Address>1801 Bering Dr</Address> <City>San Jose</City> <State>CA</State> <Phone>(408) 451-8888</Phone> <Latitude>37.373044</Latitude> <Longitude>-121.912125</Longitude> − <Rating> <AverageRating>4</AverageRating> <TotalRatings>2</TotalRatings> <TotalReviews>2</TotalReviews> <LastReviewDate>1200040214</LastReviewDate> − <LastReviewIntro> If youre looking for high limit action Bay 101 is the place to go in San Jose. You can regularly find limit games up to $80-$160 in their spacious high ceiling room. </LastReviewIntro> </Rating> <Distance>4.13</Distance> − <Url> http://local.yahoo.com/info-21599986-bay-101-banquet-facilities-san-jose </Url> − <ClickUrl> http://local.yahoo.com/info-21599986-bay-101-banquet-facilities-san-jose </ClickUrl> − <MapUrl> http://maps.yahoo.com/maps_result?q1=1801+Bering+Dr+San+Jose+CA&gid1=21599986 </MapUrl> <BusinessUrl>http://bay101.com/</BusinessUrl> <BusinessClickUrl>http://bay101.com/</BusinessClickUrl> − <Categories> <Category id="96929273">Casinos</Category> </Categories> </Result> − <Result id="21401964"> <Title>Thwart Poker Incorporated</Title> <Address>525 Lincoln Ave</Address> <City>Palo Alto</City> <State>CA</State> <Phone>(650) 329-9627</Phone> <Latitude>37.444049</Latitude> <Longitude>-122.151513</Longitude> − <Rating> <AverageRating>NaN</AverageRating> <TotalRatings>0</TotalRatings> <TotalReviews>0</TotalReviews> <LastReviewDate/> <LastReviewIntro/> </Rating> <Distance>14.09</Distance> − <Url> http://local.yahoo.com/info-21401964-thwart-poker-incorporated-palo-alto </Url> − <ClickUrl> http://local.yahoo.com/info-21401964-thwart-poker-incorporated-palo-alto </ClickUrl> − <MapUrl> http://maps.yahoo.com/maps_result?q1=525+Lincoln+Ave+Palo+Alto+CA&gid1=21401964 </MapUrl> − <Categories> <Category id="96926908">Internet Access Providers</Category> <Category id="96932773">Computer Business Solutions</Category> </Categories> </Result> − <Result id="21574436"> <Title>Blinky's Can't Say Lounge</Title> <Address>1031 Monroe St</Address> <City>Santa Clara</City> <State>CA</State> <Phone>(408) 985-7201</Phone> <Latitude>37.348893</Latitude> <Longitude>-121.94816</Longitude> − <Rating> <AverageRating>5</AverageRating> <TotalRatings>3</TotalRatings> <TotalReviews>3</TotalReviews> <LastReviewDate>1228667811</LastReviewDate> − <LastReviewIntro> Good drinks good prices good people. Who could ask for more..... </LastReviewIntro> </Rating> <Distance>6.39</Distance> − <Url> http://local.yahoo.com/info-21574436-blinky-s-can-t-say-lounge-santa-clara </Url> − <ClickUrl> http://local.yahoo.com/info-21574436-blinky-s-can-t-say-lounge-santa-clara </ClickUrl> − <MapUrl> http://maps.yahoo.com/maps_result?q1=1031+Monroe+St+Santa+Clara+CA&gid1=21574436 </MapUrl> − <Categories> <Category id="96926057">All Bars, Pubs, & Clubs</Category> <Category id="96926063">Bars & Pubs</Category> </Categories> </Result> − <Result id="21619987"> <Title>Barbara of Pauline's Cake Decorating Supplies</Title> <Address>1093 Malone Rd</Address> <City>San Jose</City> <State>CA</State> <Phone>(408) 978-9740</Phone> <Latitude>37.293702</Latitude> <Longitude>-121.889876</Longitude> − <Rating> <AverageRating>4.5</AverageRating> <TotalRatings>8</TotalRatings> <TotalReviews>8</TotalReviews> <LastReviewDate>1268173462</LastReviewDate> − <LastReviewIntro> I love this store. No matter what it is i am looking for weather it is some thing i remember from my child hood or some thing i saw in a magazine and i need it i know i can find it there. Yes they are a little rough around the edges but that is only because they are trying to get it across to you what will work and what will not. This is an old school store with people who know their stuff and are only trying to help you get the best end result possible. I am 46 years old and i took my class from Barbara when i first came out of high school and believe me she will not try to up sale you or tell you some thing is going to work if it will not. Go in expecting to be overwhelmed by stock and know you are going to get the best prices in town. Take the time to get to know the employees and the store and you will always go back to Paulines. I travel all the way from Livermore to get stuff i know i can only find there. Thanks for all your many years of being in business </LastReviewIntro> </Rating> <Distance>9.52</Distance> − <Url> http://local.yahoo.com/info-21619987-barbara-of-pauline-s-cake-decorating-supplies-san-jose </Url> − <ClickUrl> http://local.yahoo.com/info-21619987-barbara-of-pauline-s-cake-decorating-supplies-san-jose </ClickUrl> − <MapUrl> http://maps.yahoo.com/maps_result?q1=1093+Malone+Rd+San+Jose+CA&gid1=21619987 </MapUrl> − <Categories> <Category id="96928859">Wedding Supplies & Services</Category> </Categories> </Result> − <Result id="21602089"> <Title>Carey David Incorporated</Title> <Address>1624 Remuda Ln</Address> <City>San Jose</City> <State>CA</State> <Phone>(408) 453-7843</Phone> <Latitude>37.372385</Latitude> <Longitude>-121.908305</Longitude> − <Rating> <AverageRating>NaN</AverageRating> <TotalRatings>0</TotalRatings> <TotalReviews>0</TotalReviews> <LastReviewDate/> <LastReviewIntro/> </Rating> <Distance>4.13</Distance> − <Url> http://local.yahoo.com/info-21602089-carey-david-incorporated-san-jose </Url> − <ClickUrl> http://local.yahoo.com/info-21602089-carey-david-incorporated-san-jose </ClickUrl> − <MapUrl> http://maps.yahoo.com/maps_result?q1=1624+Remuda+Ln+San+Jose+CA&gid1=21602089 </MapUrl> <BusinessUrl>http://dc-enterprises.com/</BusinessUrl> <BusinessClickUrl>http://dc-enterprises.com/</BusinessClickUrl> − <Categories> <Category id="96928508">Clothing Wholesalers</Category> <Category id="96928509">Clothing Manufacturers</Category> <Category id="96931030">Apparel Manufacturing</Category> </Categories> </Result> − <Result id="30246475"> <Title>Royal Casino Parties</Title> <Address>943 Berryessa Rd, #6</Address> <City>San Jose</City> <State>CA</State> <Phone>(408) 213-0904</Phone> <Latitude>37.363563</Latitude> <Longitude>-121.886341</Longitude> − <Rating> <AverageRating>NaN</AverageRating> <TotalRatings>0</TotalRatings> <TotalReviews>0</TotalReviews> <LastReviewDate/> <LastReviewIntro/> </Rating> <Distance>4.71</Distance> − <Url> http://local.yahoo.com/info-30246475-royal-casino-parties-san-jose </Url> − <ClickUrl> http://local.yahoo.com/info-30246475-royal-casino-parties-san-jose </ClickUrl> − <MapUrl> http://maps.yahoo.com/maps_result?q1=943+Berryessa+Rd%2C+%236+San+Jose+CA&gid1=30246475 </MapUrl> <BusinessUrl>http://www.royalcasinoparties.com/</BusinessUrl> <BusinessClickUrl>http://www.royalcasinoparties.com/</BusinessClickUrl> − <Categories> <Category id="96925812">Entertainment Production</Category> <Category id="96930362">Gambling</Category> </Categories> </Result> − <Result id="25247620"> <Title>Bay Casino Gaming, Casino Party Rentals</Title> <Address/> <City>San Jose</City> <State>CA</State> <Phone>(408) 747-1977</Phone> <Latitude>37.338475</Latitude> <Longitude>-121.885794</Longitude> − <Rating> <AverageRating>NaN</AverageRating> <TotalRatings>0</TotalRatings> <TotalReviews>0</TotalReviews> <LastReviewDate/> <LastReviewIntro/> </Rating> <Distance>6.44</Distance> − <Url> http://local.yahoo.com/info-25247620-bay-casino-gaming-casino-party-rentals-san-jose </Url> − <ClickUrl> http://local.yahoo.com/info-25247620-bay-casino-gaming-casino-party-rentals-san-jose </ClickUrl> − <MapUrl> http://maps.yahoo.com/maps_result?q1=+San+Jose+CA&gid1=25247620 </MapUrl> <BusinessUrl>http://www.baycasinogaming.com/</BusinessUrl> <BusinessClickUrl>http://www.baycasinogaming.com/</BusinessClickUrl> − <Categories> <Category id="96925812">Entertainment Production</Category> <Category id="96925814">Party Rentals</Category> </Categories> </Result> </ResultSet> Hello all, I'm looking for some assistance with some code. I'm trying to put this to bed as it's driving me nuts. The Psuedo code for this would be to 1) Download the rates from the Yahoo API and declare my base rate to my foreign exchange. 2) Store an array of currencies to choose from to compare against the base currency. 3) I then GET the chosen currency and register it in a SESSION to be used on other pages. (I'm unsure if this is correct?) 4) I then calculate the Price of my product which is in GBP to the selected foreign currency. 5) Output the converted price anywhere on the page. My script takes GET values from the URL like so.. .com?c=EUR My code is like so.. 1) First I get the rates from the Yahoo API Code: [Select] session_start(); $from = 'GBP'; $to = '$c'; $url = 'http://finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s='. $from . $to .'=X'; $handle = @fopen($url, 'r'); if ($handle) { $result = fgets($handle, 4096); fclose($handle); } $allData = explode(',',$result); /* Get all the contents to an array */ $PoundValue = $allData[1]; 2) Then I store an array of the currencies. Code: [Select] $currency_array = array ('USD','EUR','RMB','JPY','AUD','CHF') 3) Then I get the chosen currency. Code: [Select] if(isset($_GET['c'])) { $c = $_GET['c']; if(array($currency_array)) { $_SESSION['currency_array'] = $c; } } 4) I then calculate the product price. Code: [Select] $Total = $Price * $currency_array; $outprice = number_format($Total, 2, '.', ','); 5) Then I output on the page Code: [Select] <?php echo .$outprice; ?> So is all my coding logically in the right order? Any help would be greatly appreciated. Thank you. Hello ive Googled around for ages for a PHP script that Shows the yahoo user statuts .. but the only thing i ve found is this link from yahoo thats saying the Online/Offline statuts http://opi.yahoo.com/online?u= ive heared that theres some way of sending a bot to the id and see if its on invisible .. dos anyone know a way to do it ? Guys Im having a strange issue with my code I have a form to request a password to be sent to email incase forgotten The script seems to run as it should as in taking the info then redirecting to the messages page for confirmation no problem but its not sending the email Ive checked and double checked, and even re written the code from scratch and nothing seems to be playing ball in sending the email Can someone shed some none sleep deprived eyes over it and point out what will no doubt be an obvious error I just cant seem to see The Form: Code: [Select] <form name="sendpw" method="post" action="sendpw.php"> <br> <table width="100%" border="0" class="tbl"> <tr> <td width="198"><div align="right">Username:</div></td> <td width="418"><input name="name" type="text" class="input" size="30"></td> </tr> <tr> <td><div align="right">Email: </div> </td> <td><input name="mail" type="text" class="input" size="30"></td> </tr> <tr> <td colspan="2"> <div align="center"> <input name="Submit" type="submit"> </div></td> </tr> </table> </form> The Script: Code: [Select] <? include ('config.php'); $name=$_POST['name']; $em=$_POST['mail']; $query="SELECT pw FROM user WHERE uname='$name' AND email='$em'" or die (mysql_error()); $result= mysql_query($query); $row = mysql_fetch_assoc($result); $pass=$row['pw']; $to="$em"; $from="From: passwords@MBD.net"; $msg="Username: $name\r\n"; $msg .="Password: $pass\r\n"; $msg .="Please keep this password safe"; $subject="Your Login Password\r\n"; mail($to,$subject,$msg,$from); header( "Location:messages.php?msg=2" ); exit(); ?> config.php is just my database connection info, which is working fine as it runs all all my pages that access the database. Thanks Tom Hello, I have a php script that I'm trying to have run from a different server via cron Code: [Select] 1 9 * * * /usr/bin/wget wget -o http://www.site1.com/update.php -o /dev/null The log in /var/log/cron is showing this as having been run: Code: [Select] Dec 26 09:01:01 host crond[10392]: (root) CMD (/usr/bin/wget wget -o http://www.site1.com/update.php -o /dev/null) Dec 27 09:01:01 host crond[17001]: (root) CMD (/usr/bin/wget wget -o http://www.site1.com/update.php -o /dev/null) Dec 28 09:01:01 host crond[2331]: (root) CMD (/usr/bin/wget wget -o http://www.site1.com/update.php -o /dev/null) however it does not appear to run successful (or at least nothing gets updated) Here is the update.php <?php require_once('functions.php'); mysql_connect("localhost","username","password"); mysql_select_db("database"); $result = mysql_query("SELECT * FROM ServerList"); while($row = mysql_fetch_array($result)){ $server = new Whm; $server->init($row['HostName'],$row['UserName'],$row['PassHash']); $NewUsedSlots = count($server->listaccts()); mysql_query("UPDATE ServerList SET UsedSlots='$NewUsedSlots' WHERE HostName='{$row['HostName']}'"); } $CurrentTime = date("Y-m-d G:i"); mysql_query("UPDATE UpdateTime SET TimeUpdated='$CurrentTime'"); ?> update.php does in fact work correctly when I run it from my own personal browser.. what is going wrong? thanks! I'm using XAMPP and im a major noob. Last nite I was following this tutor and the connection script that was on it didnt work for me. So today I tried a connection script from another tutor on another site that worked just fine. here is the script that worked I saved it as test.php and went to localhost/test/php and it loaded a page connected to mysql <?php mysql_connect("localhost", "shadowing", "eguitars8") or die(mysql_error()); echo "Connected to MySQL<br />"; ?> The script that didnt work i saved it as connect.php and went to localhost/connect/php and it gave me a page saying "Object not found error "the request url was not found on this server." I understand this script doesnt have a echo on it but shouldnt it still take me to a blank white page instead of a error page. Or is there something wrong with it. Really appreciate any help with this. the script that didnt work is below <?php $mysql_server = "localhost"; // localhost is common on most hosts. $mysql_user = "shadowing"; // this is the name of your username of the server. $mysql_password = "eguitars8"; // the password connected to the username. MAKE IT COMPLEX. $mysql_database = "spacewars"; // the database name of where to connect to and where the information will be help. $connection = mysq1_connect("$mysql_server","$mysql_user","$mysql_password") or die ("Unable to establish a DB connection"); $db = mysql_database("$mysql_database") or die ("Unable to establish a DB connection"); ?> Hello, PHP Freaks, So I have my website built with RapidWeaver, and built a PHP form page, and it works fine with a test host. However, I uploaded to Yahoo Small Business and the submissions aren't getting through. I heard that Yahoo is quite problematic when it comes to PHP...I called their help line and they told me that I needed to include the following in my form: <form name="Form0" method="POST" action="http://us.xx.px.webhosting.yahoo.com/forms?login=YahooID&to=mail@domianname.com&confirm=index.html&error=" onSubmit="return checkForm0()"> However, I have 2 php files, application.php and mailer.php. application.php: Quote <?php // Start session. session_start(); // Set a key, checked in mailer, prevents against spammers trying to hijack the mailer. $security_token = $_SESSION['security_token'] = uniqid(rand()); if ( ! isset($_SESSION['formMessage'])) { $_SESSION['formMessage'] = 'Fill in the form below to submit an application.'; } if ( ! isset($_SESSION['formFooter'])) { $_SESSION['formFooter'] = 'A scholarship is also available, please contact us for more details.'; } if ( ! isset($_SESSION['form'])) { $_SESSION['form'] = array(); } function check($field, $type = '', $value = '') { $string = ""; if (isset($_SESSION['form'][$field])) { switch($type) { case 'checkbox': $string = 'checked="checked"'; break; case 'radio': if($_SESSION['form'][$field] === $value) { $string = 'checked="checked"'; } break; case 'select': if($_SESSION['form'][$field] === $value) { $string = 'selected="selected"'; } break; default: $string = $_SESSION['form'][$field]; } } return $string; } ?><!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> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="robots" content="all" /> <meta name="generator" content="RapidWeaver" /> <title>North Shore Culinary School | Application</title> <link rel="stylesheet" type="text/css" media="screen" href="../rw_common/themes/culinaryschool/styles.css" /> <!--[if IE 6]><link rel="stylesheet" type="text/css" media="screen" href="../rw_common/themes/culinaryschool/ie6.css" /><![endif]--> <!--[if IE 7]><link rel="stylesheet" type="text/css" media="screen" href="../rw_common/themes/culinaryschool/ie7.css" /><![endif]--> <link rel="stylesheet" type="text/css" media="screen" href="../rw_common/themes/culinaryschool/colourtag-page4.css" /> <link rel="stylesheet" type="text/css" media="print" href="../rw_common/themes/culinaryschool/print.css" /> <link rel="stylesheet" type="text/css" media="handheld" href="../rw_common/themes/culinaryschool/handheld.css" /> <link rel="stylesheet" type="text/css" media="screen" href="../rw_common/themes/culinaryschool/css/width/900.css" /> <link rel="stylesheet" type="text/css" media="screen" href="../rw_common/themes/culinaryschool/css/header/sunflower.css" /> <link rel="stylesheet" type="text/css" media="screen" href="../rw_common/themes/culinaryschool/css/icons/blue.css" /> <link rel="stylesheet" type="text/css" media="screen" href="../rw_common/themes/culinaryschool/css/sidebar/sidebar_right.css" /> <script type="text/javascript" src="../rw_common/themes/culinaryschool/javascript.js"></script> <!--[if IE 6]><script type="text/javascript" charset="utf-8"> var blankSrc = "../rw_common/themes/culinaryschool/png/blank.gif"; </script> <style type="text/css"> img { behavior: url("../rw_common/themes/culinaryschool/png/pngbehavior.htc"); } </style><![endif]--> </head> <body> <div id="top_bar"> <img src="../rw_common/themes/culinaryschool/images/body_top_bar.png" alt="" width="3000" height="8" /> </div> <div id="container"><!-- Start container --> <div id="top_swirl"> <img src="../rw_common/themes/culinaryschool/images/top_swirl.png" alt="" width="222" height="140" /> </div> <div id="pageHeader"><!-- Start page header --> <div id="logo_overlay"><img src="../rw_common/themes/culinaryschool/images/logo_grad_overlay.png" alt="" width="3000" height="175" /></div> <div id="logo"></div> <h1>North Shore Culinary School</h1> <h2>This is a complete program designed to train today's food service professionals for entry level jobs which may ladder to further opportunities.</h2> </div><!-- End page header --> <div id="contentContainer"><!-- Start main content wrapper --> <div id="navcontainer"><!-- Start Navigation --> <ul><li><a href="../index.html" rel="self">Home</a></li><li><a href="../about.html" rel="self">About</a></li><li><a href="../requirements.html" rel="self" class="currentAncestor">Curriculum</a><ul><li><a href="../curriculum/details.html" rel="self">Details</a></li><li><a href="../curriculum/calendar.html" rel="self">Calendar</a></li><li><a href="application.php" rel="self" id="current">Application</a></li></ul></li><li><a href="../contact.html" rel="self">Contact</a></li></ul> </div><!-- End navigation --> <div id="sidebarContainer"><!-- Start Sidebar wrapper --> <div id="sidebar"><!-- Start sidebar content --> <h1 class="sideHeader"></h1><!-- Sidebar header --> <!-- sidebar content you enter in the page inspector --> <!-- sidebar content such as the blog archive links --> </div><!-- End sidebar content --> </div><!-- End sidebar wrapper --> <div id="content"><!-- Start content --> <div class="message-text"><?php echo $_SESSION['formMessage']; unset($_SESSION['formMessage']); ?></div><br /> <form action="./application_files/mailer.php" method="post" enctype="multipart/form-data"> <div> <label>First Name:</label> *<br /> <input class="form-input-field" type="text" value="<?php echo check('element0'); ?>" name="form[element0]" size="40"/><br /><br /> <label>Last Name:</label> *<br /> <input class="form-input-field" type="text" value="<?php echo check('element1'); ?>" name="form[element1]" size="40"/><br /><br /> <label>Sex:</label> *<br /> <select name="form[element2]"> <option <?php echo check('element2', 'select','Male'); ?> value="Male">Male</option> <option <?php echo check('element2', 'select','Female'); ?> value="Female">Female</option> </select><br /><br /> <label>Birthdate (DD/MM/YYYY):</label> *<br /> <input class="form-input-field" type="text" value="<?php echo check('element3'); ?>" name="form[element3]" size="40"/><br /><br /> <label>Date of Application (DD/MM/YYYY):</label> *<br /> <input class="form-input-field" type="text" value="<?php echo check('element4'); ?>" name="form[element4]" size="40"/><br /><br /> <label>Address:</label> *<br /> <input class="form-input-field" type="text" value="<?php echo check('element5'); ?>" name="form[element5]" size="40"/><br /><br /> <label>Apartment Number:</label> <br /> <input class="form-input-field" type="text" value="<?php echo check('element6'); ?>" name="form[element6]" size="40"/><br /><br /> <label>Postal Code:</label> *<br /> <input class="form-input-field" type="text" value="<?php echo check('element7'); ?>" name="form[element7]" size="40"/><br /><br /> <label>Home Phone Number:</label> *<br /> <input class="form-input-field" type="text" value="<?php echo check('element8'); ?>" name="form[element8]" size="40"/><br /><br /> <label>Cell Phone Number:</label> <br /> <input class="form-input-field" type="text" value="<?php echo check('element9'); ?>" name="form[element9]" size="40"/><br /><br /> <label>Fax:</label> <br /> <input class="form-input-field" type="text" value="<?php echo check('element10'); ?>" name="form[element10]" size="40"/><br /><br /> <label>E-mail:</label> *<br /> <input class="form-input-field" type="text" value="<?php echo check('element11'); ?>" name="form[element11]" size="40"/><br /><br /> <label>Alternate e-mail:</label> *<br /> <input class="form-input-field" type="text" value="<?php echo check('element12'); ?>" name="form[element12]" size="40"/><br /><br /> <label>BCID #:</label> <br /> <input class="form-input-field" type="text" value="<?php echo check('element13'); ?>" name="form[element13]" size="40"/><br /><br /> <label>BC Driver's License #:</label> <br /> <input class="form-input-field" type="text" value="<?php echo check('element14'); ?>" name="form[element14]" size="40"/><br /><br /> <label>Are you of First Nation or Inuit descent?</label> *<br /> <select name="form[element15]"> <option <?php echo check('element15', 'select','Yes'); ?> value="Yes">Yes</option> <option <?php echo check('element15', 'select','No'); ?> value="No">No</option> </select><br /><br /> <label>Were you born in Canada?</label> *<br /> <select name="form[element16]"> <option <?php echo check('element16', 'select','Yes'); ?> value="Yes">Yes</option> <option <?php echo check('element16', 'select','No'); ?> value="No">No</option> </select><br /><br /> <label>If not, what is your country of birth?</label> <br /> <input class="form-input-field" type="text" value="<?php echo check('element17'); ?>" name="form[element17]" size="40"/><br /><br /> <label>When did you arrive in Canada? (DD/MM/YYYY)</label> <br /> <input class="form-input-field" type="text" value="<?php echo check('element18'); ?>" name="form[element18]" size="40"/><br /><br /> <label>Elementary School Attended:</label> *<br /> <input class="form-input-field" type="text" value="<?php echo check('element19'); ?>" name="form[element19]" size="40"/><br /><br /> <label>High School Attended:</label> *<br /> <input class="form-input-field" type="text" value="<?php echo check('element20'); ?>" name="form[element20]" size="40"/><br /><br /> <label>DId you receive any extra learning support in school? (e.g. ESL)</label> *<br /> <select name="form[element21]"> <option <?php echo check('element21', 'select','Yes'); ?> value="Yes">Yes</option> <option <?php echo check('element21', 'select','No'); ?> value="No">No</option> </select><br /><br /> <label>If yes, please specify...</label> <br /> <input class="form-input-field" type="text" value="<?php echo check('element22'); ?>" name="form[element22]" size="40"/><br /><br /> <label>Do you have a computer workstation at home?</label> *<br /> <select name="form[element23]"> <option <?php echo check('element23', 'select','Yes'); ?> value="Yes">Yes</option> <option <?php echo check('element23', 'select','No'); ?> value="No">No</option> </select><br /><br /> <label>How will you be travelling to and from school?</label> *<br /> <select name="form[element24]"> <option <?php echo check('element24', 'select','Car'); ?> value="Car">Car</option> <option <?php echo check('element24', 'select','Bus'); ?> value="Bus">Bus</option> <option <?php echo check('element24', 'select','Bike'); ?> value="Bike">Bike</option> <option <?php echo check('element24', 'select','Walking'); ?> value="Walking">Walking</option> <option <?php echo check('element24', 'select','Other'); ?> value="Other">Other</option> </select><br /><br /> <label>Are you receiving any financial assistance? Please specify...</label> *<br /> <input class="form-input-field" type="text" value="<?php echo check('element25'); ?>" name="form[element25]" size="40"/><br /><br /> <label>Have you received a blood test?</label> *<br /> <select name="form[element26]"> <option <?php echo check('element26', 'select','Yes'); ?> value="Yes">Yes</option> <option <?php echo check('element26', 'select','No'); ?> value="No">No</option> </select><br /><br /> <label>Have you received a TB test?</label> *<br /> <select name="form[element27]"> <option <?php echo check('element27', 'select','Yes'); ?> value="Yes">Yes</option> <option <?php echo check('element27', 'select','No'); ?> value="No">No</option> </select><br /><br /> <label>Do you have any disabilities? Please specify...</label> *<br /> <input class="form-input-field" type="text" value="<?php echo check('element28'); ?>" name="form[element28]" size="40"/><br /><br /> <label>What is your cultural background?</label> *<br /> <input class="form-input-field" type="text" value="<?php echo check('element29'); ?>" name="form[element29]" size="40"/><br /><br /> <div style="display: none;"> <label>Spam Protection: Please don't fill this in:</label> <textarea name="comment" rows="1" cols="1"></textarea> </div> <input type="hidden" name="form_token" value="<?php echo $security_token; ?>" /> <input class="form-input-button" type="reset" name="resetButton" value="Reset" /> <input class="form-input-button" type="submit" name="submitButton" value="Submit" /> </div> </form> <br /> <div class="form-footer"><?php echo $_SESSION['formFooter']; unset($_SESSION['formFooter']); ?></div><br /> <?php unset($_SESSION['form']); ?> <div class="clearer"></div> </div><!-- End content --> </div><!-- End main content wrapper --> </div><!-- End container --> <div id="footer"><!-- Start Footer --> <div id="footer_swirl"> <img src="../rw_common/themes/culinaryschool/images/footer_swirl.png" alt="" width="502" height="69" /> </div> <p>© 2010 Don Guthro</p> <div id="breadcrumbcontainer"><!-- Start the breadcrumb wrapper --> </div><!-- End breadcrumb --> </div><!-- End Footer --> </body> </html> mailer.php: Quote <?php //start the session session_start(); ////////////////////////////////////////////////////// // Begin variables to be written out by RapidWeaver // ////////////////////////////////////////////////////// //set the return URL $return_url = "../application.php"; //set the users email address $email = "nachapol.d@gmail.com"; //array of fields in form. (In the format "field_name" => "field_label") $form_fields = array( "element0" => 'First Name:', "element1" => 'Last Name:', "element2" => 'Sex:', "element3" => 'Birthdate (DD/MM/YYYY):', "element4" => 'Date of Application (DD/MM/YYYY):', "element5" => 'Address:', "element6" => 'Apartment Number:', "element7" => 'Postal Code:', "element8" => 'Home Phone Number:', "element9" => 'Cell Phone Number:', "element10" => 'Fax:', "element11" => 'E-mail:', "element12" => 'Alternate e-mail:', "element13" => 'BCID #:', "element14" => 'BC Driver\'s License #:', "element15" => 'Are you of First Nation or Inuit descent?', "element16" => 'Were you born in Canada?', "element17" => 'If not, what is your country of birth?', "element18" => 'When did you arrive in Canada? (DD/MM/YYYY)', "element19" => 'Elementary School Attended:', "element20" => 'High School Attended:', "element21" => 'DId you receive any extra learning support in school? (e.g. ESL)', "element22" => 'If yes, please specify...', "element23" => 'Do you have a computer workstation at home?', "element24" => 'How will you be travelling to and from school?', "element25" => 'Are you receiving any financial assistance? Please specify...', "element26" => 'Have you received a blood test?', "element27" => 'Have you received a TB test?', "element28" => 'Do you have any disabilities? Please specify...', "element29" => 'What is your cultural background?' ); $required_fields = array("element0", "element1", "element2", "element3", "element4", "element5", "element7", "element8", "element11", "element12", "element15", "element16", "element19", "element20", "element21", "element23", "element24", "element25", "element26", "element27", "element28", "element29"); $mail_from_name = "element0"; $mail_from_email = "element11"; $mail_subject = "element4"; //uses the email address defined above as the from email. $send_from_users_email = false; //sets the PHP setting 'sendmail_from' for use on a windows server. $windows_server = true; // Set up the error and success messages. $message_success = 'Thank you, your application has been sent.'; $message_unset_fields = "Fields marked with * are required."; //////////////////////////////////////////////////// // End variables to be written out by RapidWeaver // //////////////////////////////////////////////////// // Check key variable from form against session key. if ( ! isset($_POST['form_token']) || $_POST['form_token'] !== $_SESSION['security_token']) { // Set a fixed error message if the keys don't match. redirect($return_url, 'We cannot verify that you are trying to send an email from this form. Please try again.'); } // SPAM checking. If the "comment" form field has been filled out, // send back to form asking to remove content and exit the script. if ($_POST['comment']) { redirect($return_url, 'Please remove content from the last textarea before submitting the form again. This is to protect against SPAM abuse.'); } ///////////////////////// // PROCESS FORM FIELDS // ///////////////////////// $magic_quotes = (bool) get_magic_quotes_gpc(); foreach ($_POST['form'] as $key => $value) { if ($magic_quotes) { $value = stripslashes($value); } $_SESSION['form'][$key] = $value; } /////////////////////////// // CHECK REQUIRED FIELDS // /////////////////////////// //if any of the required fields are empty if (check_required_fields($required_fields) === false) { //return to form with error message. redirect($return_url, $message_unset_fields); } else { /////////////////////////////////// // ALL IS OK, SETUP GLOBAL VAR'S // /////////////////////////////////// //check email address if ( ! check_email($email)) unset($email); //set mime boundry. Needed to send the email. Mixed seperates text from attachments. $mixed_mime_boundary = 'rms-mix-x'.md5(mt_rand()).'x'; //alt seperates html from plain text. $alt_mime_boundary = 'rms-alt-x'.md5(mt_rand()).'x'; //set the from address if user supplied email is invalid use form owners. $submitted_email = ''; if (isset($_SESSION['form'][$mail_from_email])) { $submitted_email = $_SESSION['form'][$mail_from_email]; } if (check_email($submitted_email) && $send_from_users_email === false) { $from = $reply_to = $_SESSION['form'][$mail_from_name].'<'.$submitted_email.'>'; } else { $from = '<'.$email.'>'; $reply_to = check_email($submitted_email) ? '<'.$submitted_email.'>' : $from; } //set the email subject $subject = ''; if (isset($_SESSION['form'][$mail_subject])) { $subject = $_SESSION['form'][$mail_subject]; } //email headers $headers = "From: $from\r\n" . "Reply-to: $reply_to\r\n" . "MIME-Version: 1.0\r\nContent-Type: multipart/mixed; " . "boundary=$mixed_mime_boundary"; //////////////////////////// // CONSTRUCT HTML CONTENT // //////////////////////////// //Construct HTML email content, looping through each form element //Note: When you get to a file attachment you need to use $_FILES['form_element']['name'] //This will just output the name of the file. The files will actually be attached at the end of the message. //Set a variable for the message content $html_content = "<html>\r\n<head>\r\n<title>" . safe_escape_string($subject) . "</title>\r\n</head>\r\n<body>\r\n<p>\r\n"; //////////////////////////// // CONSTRUCT TEXT CONTENT // //////////////////////////// //construct a plain text version of the email. $text_content = ''; //build a message from the reply for both HTML and text in one loop. foreach ($form_fields as $field => $label) { $html_content .= '<b>' . safe_escape_string($label) . '</b> '; $text_content .= "$label "; if (isset($_FILES[$field])) { $string = (isset($_FILES[$field]['name'])) ? $_FILES[$field]['name'] : ''; } else { $string = (isset($_SESSION['form'][$field])) ? $_SESSION['form'][$field] : ''; } $html_content .= nl2br(safe_escape_string($string)) . "<br /><br />\r\n"; $text_content .= "$string\r\n\r\n"; } //close the HTML content. $html_content .= "</p>\r\n</body>\r\n</html>"; ///////////////////////////// // CONSTRUCT EMAIL MESSAGE // ///////////////////////////// //Now we combine both HTML and plain text version of the email into one. //Creating the message body which contains a Plain text version and an HTML version, //users email client will decide which version to display $message = "\r\n--$mixed_mime_boundary\r\n" . "Content-Type: multipart/alternative; boundary=$alt_mime_boundary\r\n\r\n" . "--$alt_mime_boundary\r\n" . "Content-Type: text/plain; charset=UTF-8; format=flowed\r\n" . "Content-Transfer-Encoding: Quoted-printable\r\n\r\n" . "$text_content\r\n\r\n" . "--$alt_mime_boundary\r\n" . "Content-Type: text/html; charset=UTF-8\r\n" . "Content-Transfer-Encoding: Quoted-printable\r\n\r\n" . "$html_content\r\n\r\n" . "--$alt_mime_boundary--\r\n\r\n" . "\r\n\r\n--$mixed_mime_boundary"; ////////////////////// // FILE ATTACHMENTS // ////////////////////// //loop through the $_FILES global array and add each attachment to the form. if (isset($_FILES)) { foreach ($_FILES as $attachment) { $filename = $attachment['name']; //if the file has been uploaded if ($attachment['error'] === UPLOAD_ERR_OK && is_uploaded_file($attachment['tmp_name'])) { $file = fopen($attachment['tmp_name'],'rb'); $data = fread($file,filesize($attachment['tmp_name'])); fclose($file); $data = chunk_split(base64_encode($data)); $message .= "\r\nContent-Type: application/octet-stream; name=\"$filename\"" . "\r\nContent-Disposition: attachment; filename=\"$filename\"" . "\r\nContent-Transfer-Encoding: base64\r\n\r\n$data\r\n\r\n--$mixed_mime_boundary"; } else if ($attachment['error'] !== UPLOAD_ERR_NO_FILE) { //try to provide a useful error message determined from the error code. switch ($attachment['error']) { case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: $error = "File $filename exceeds the " . ini_get('upload_max_filesize') . 'B limit for the server.'; break; case UPLOAD_ERR_PARTIAL: $error = "Only part of the file $filename could be uploaded, please try again."; break; default: $error = "There has been an error attaching the file $filename, please try again."; } redirect($return_url, $error); } } } //finish off message $message .= '--'; //for windows users. if ($windows_server === true) { ini_set('sendmail_from', $email); } //if the mail sending works if (@mail($email, $subject, $message, $headers)) { //set the success message $notice = $message_success; unset($_SESSION['form']); } else { $notice = "I'm sorry, there seems to have been an error trying to send your email. Please try again."; } //redirect to the form redirect($return_url, $notice); } ////////////////////// // GLOBAL FUNCTIONS // ////////////////////// // Redirects back to the form, an optional session message can be defined. function redirect($url, $message = NULL) { if ($message) { $_SESSION['formMessage'] = $message; } header('Location: ' . $url); exit; } // Function to escape data inputted from users. This is to protect against embedding // of malicious code being inserted into the HTML email. // Sample code: safe_escape_string($_POST['form_field']) function safe_escape_string($string) { return htmlspecialchars($string, ENT_QUOTES); } // Function to check the validity of email address. function check_email($email) { return (bool) preg_match('/^([a-z0-9_]|\-|\.)+@(([a-z0-9_]|\-)+\.)+[a-z]{2,4}$/i', $email); } // Function to check the required fields are filled in. function check_required_fields($required_fields) { foreach ($required_fields as $field) { if (( ! isset($_SESSION['form'][$field]) || empty($_SESSION['form'][$field])) && ( ! isset($_FILES[$field]) || empty($_FILES[$field]['name']))) { return false; } } return true; } Now I'm a little bombarded with this code, since I am an amateur web-builder and I don't have much experience modifying PHP. I was just wondering how I can integrate the code given to me into my existing PHP files. The website is www.northshoreculinaryschool.com and my form is under Curriculum > Application. I can provide the files if anyone wishes. Any help is greatly appreciated! If you can help me through this, you're a lifesaver! With this link http://search.yahooapis.com/WebSearchService/V1/relatedSuggestion?appid=YahooDemo&query=Madonna&results=2 , one can see suggested keywords for a query. The result is like "madonna 4 minutes madonna 4 minutes lyrics". How to put the resulting keywords in a $array, as can be used for further php coding. i am new to curl .and i m trying to create create a script to log into yahoo and click the confermation link in emails. but i am stuck witht he login process only i made the code below . but still i cant make it work. the problem is yahoo is implementing a captcha challange for this kind of automated headers. do you have any idea ho to make it work again without alerting the captcha challange ? the header i caught through the livehttp header is as follows: Content-Length: 347 .tries=1&.src=ym&.md5=&.hash=&.js=&.last=&promo=&.intl=in&.bypass=&.partner=&.u=4ls6cr96lbs8e&.v=0&.challenge=W9w31pCrbdazCcY4mH41fVsyxwd8&.yplus=&.emailCode=&pkg=&stepid=&.ev=&hasMsgr=0&.chkP=Y&.done=http%3A%2F%2Fmail.yahoo.com&.pd=ym_ver%3D0%26c%3D%26ivt%3D%26sg%3D&pad=1&aad=1&login=myyahooid&passwd=mypassword&.persistent=y&.save=&passwd_raw= <?php $authUrl = "https: //login. yahoo . com/config/login?"; $userAgent = "Mozilla/5.0 (Windows NT 5.1; rv:2.0b11) Gecko/20100101 Firefox/4.0b11"; $referer = "http : // my . yahoo . com"; $login = "userid"; $password = "password"; $numPostData = 22; $cookieFileJar = "ycookie.txt"; $cookie = 0; $postData = ".tries=1&.src=ym&.md5=&.hash=&.js=&.last=&promo=&.intl=in&.bypass=&.partner=&.u=4ls6cr96lbs8e&.v=0&.challenge=W9w31pCrbdazCcY4mH41fVsyxwd8&.yplus=&.emailCode=&pkg=&stepid=&.ev=&hasMsgr=0&.chkP=Y&.done=http%3A%2F%2Fmail.yahoo.com&.pd=ym_ver%3D0%26c%3D%26ivt%3D%26sg%3D&pad=1&aad=1&login=$login&passwd=$password&.persistent=y&.save=&passwd_raw=" ; $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); // Set the referrer curl_setopt($ch, CURLOPT_REFERER, $referer); // Set the authentication url curl_setopt($ch, CURLOPT_URL, $authUrl); // Set number of post fields curl_setopt($ch, CURLOPT_POST, $numPostData); //Set post data in key=value pair such as login=yourusername curl_setopt($ch, CURLOPT_POSTFIELDS, $numPostData); //Set filename for storing cookie information curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFileJar); //Set ffilename for checking the stored cookie information curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFileJar); //Set option for cookie curl_setopt($ch, CURLOPT_COOKIE, $cookie); //set this to output the result as string and not output directly ot browser curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); //set this value to 1 if you want to redirect to the url you provided as service url curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); //Set this option if you do not want to verify ssl curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); //set this option if you do not want to verify peer's certificate curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); //now execute the curl $res = curl_exec($ch); echo $res; //check if the username and password is valid if ((preg_match("/invalid/i", $res)) || (preg_match("/not yet taken/i", $res))) { echo "Invalid Login"; } else { //if CURLOPT_FOLLOWLOCATION is set to 1 then after logging in successfully user is directed to url that is specified as service url echo "Logged In"; } ?> then i have to work for clicking confermation links in mails. please suggest me some ways.i would be very grateful to you Hello, I am writing a data retrieval script, in order to print data stored in a DB. For some reason the script does not work.. More details below.. Code: [Select] the form that calls the initiator script.. <form method='get' action="init.Get.php"> <div><input type="submit" name="get" value="See Data"></div> </form> Code: [Select] the initiator script <?php include 'dataGet.class.php'; $data= new getData(); $data= getData($name, $email, $text); ?> Code: [Select] my class.. <?php class getData { private $name; private $email; private $text; function __construct(){ $this->host = 'localhost'; $this->uname = 'root'; $this->pword = '1111'; $this->dbname = 'teststorage'; $this->dbtable = 'userData'; } function getData($name, $email, $text){ $this->dbconnect = mysql_connect($this->host, $this->uname, $this->pword); if (!$this->dbconnect) die("Connection Unable " . mysql_error()); mysql_select_db($this->dbname); $sql_query = "SELECT * FROM $this->dbtable "; $result = mysql_query($sql_query); if ($result){ echo $result; } else{ echo "Retrieval Unsuccesful"; } mysql_close($sql_query); } } ?> Can someone please tell me what am I doing wrong? Thank you in advance. Hi all, Sorry to be a pain, but I've been out of the php game for quite a few years and have just come back to it briefly to help someone out. I've been using an old admin auth script that I used to use a long time ago but it's not working, and I can't for the life of me work it out :/ I apologise for the noobishness of the code, but as I said, it's been a long time. Any and all help would be very greatly appreciated. Here is the code: <? require("config.php"); mysql_connect($server,$login,$password) or die('Error connecting to server'); mysql_select_db($base) or die('Error connecting to database'); $req = mysql_query("SELECT username,mempass,level FROM members WHERE username='$admin_login'"); $data = @mysql_fetch_array($req); $member_name = $data["username"]; $member_pass = $data["mempass"]; $member_userlevel = $data["level"]; if($member_pass == $admin_pass) { SetCookie("mgdwebby","$member_name:$member_pass:$member_userlevel"); } include("header.php"); ?> <? if($action=="login") { if($admin_login==""){ echo"Wrong info. "; } elseif($admin_pass==""){ echo"Wrong info. "; } else{ require("config.php"); mysql_connect($server,$login,$password) or die('Error connecting to server'); mysql_select_db($base) or die('Error connecting to database'); $req = mysql_query("SELECT username,mempass,level FROM members WHERE username='$admin_login'"); $data = @mysql_fetch_array($req); $member_name = $data["username"]; $member_pass = $data["mempass"]; if($member_pass == $admin_pass) { echo"<head><meta http-equiv=\"refresh\" content=\"2;URL=admin.php\"></head><br><center>Please Wait.</center><br>"; $auth = explode(":",$HTTP_COOKIE_VARS["mgdwebby"]); if(empty($auth[0]) || empty($auth[1])) { } else { echo"Welcome<br>"; include("admin_left.php"); } } else { echo"Wrong info. "; } } } else { echo"<form method='post' action='?action=login'> <table width='307' align='center' cellspacing='0' cellpading='0' border='0'> <tr> <td width='200'> Login : </td> <td> <input type='text' name='admin_login'></td> </tr> <tr> <td width='200'> Password : </td> <td> <input type='password' name='admin_pass'></td> </tr> <tr> <td colspan='2' align='center'><center><input type='submit' value='Login'></center></td> </table> "; } ?> <? include("footer.php"); ?> a douche hard coded my shopping carts VAT to 17.5% i wanted to just adjust the VAT in the shopping cart, but he has removed the feature.. so what i was thinking to counter it, was to make a php script that could EDIT all the prices in the database +2.5% can anybody help me with this please? Hi I have a simply working SMTP form, however I need this to send to a yahoo.com email address, what can I add to achieve this? SmtpConfig.php ============== <?php //Server Address $SmtpServer="91.186.30.25"; $SmtpPort="25"; //default $SmtpUser="things@wilsoncarandvanrental.co.uk"; $SmtpPass="things123"; ?> SmtpClass.php ============= <?php class SMTPClient { // A function for Setting up SMTP function SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $subject, $body) { $this->SmtpServer = $SmtpServer; $this->SmtpUser = base64_encode ($SmtpUser); $this->SmtpPass = base64_encode ($SmtpPass); $this->from = $from; $this->to = $to; $this->subject = $subject; $this->body = $body; //Setting Default port Value if ($SmtpPort == "") { $this->PortSMTP = 25; } else { $this->PortSMTP = $SmtpPort; } } //Sending the Mail function SendMail () { if ($SMTPIN = fsockopen ($this->SmtpServer, $this->PortSMTP)) { fputs ($SMTPIN, "EHLO ".$HTTP_HOST."\r\n"); $talk["hello"] = fgets ( $SMTPIN, 1024 ); fputs($SMTPIN, "auth login\r\n"); $talk["res"]=fgets($SMTPIN,1024); fputs($SMTPIN, $this->SmtpUser."\r\n"); $talk["user"]=fgets($SMTPIN,1024); fputs($SMTPIN, $this->SmtpPass."\r\n"); $talk["pass"]=fgets($SMTPIN,256); fputs ($SMTPIN, "MAIL FROM: <".$this->from.">\r\n"); $talk["From"] = fgets ( $SMTPIN, 1024 ); fputs ($SMTPIN, "RCPT TO: <".$this->to.">\r\n"); $talk["To"] = fgets ($SMTPIN, 1024); fputs($SMTPIN, "DATA\r\n"); $talk["data"]=fgets( $SMTPIN,1024 ); fputs($SMTPIN, "To: <".$this->to.">\r\nFrom: <".$this->from.">\r\nSubject:".$this->subject."\r\n\r\n\r\n".$this->body."\r\n.\r\n"); $talk["send"]=fgets($SMTPIN,256); //CLOSE CONNECTION AND EXIT ... fputs ($SMTPIN, "QUIT\r\n"); fclose($SMTPIN); // } return $talk; } } ?> mail.php ======== <?php //Include Class And Config include('SmtpConfig.php'); include('SmtpClass.php'); //Check the Request Method if($_SERVER["REQUEST_METHOD"] == "POST") { $to = $_POST['to']; $from = $_POST['from']; $subject = $_POST['sub']; $body = $_POST['message']; // Send the mail Using the class $SMTPMail = new SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $subject, $body); $SMTPChat = $SMTPMail->SendMail(); } // After Exit, show the form ?> <form method="post" action=""> To:<input type="text" name="to" /> From :<input type='text' name="from" /> Subject :<input type='text' name="sub" /> Message :<textarea name="message"></textarea> <input type="submit" value=" Send " /> </form> Probably quite straight form, but of course I don#t know how :0) Much appreciated. |