Jump to content

hansman

Members
  • Posts

    100
  • Joined

  • Last visited

    Never

Everything posted by hansman

  1. Hey guys, I'm working with a JSON that Twitter gave me... http://api.twitter.com/1/statuses/show/76626185060225024.json I would like to extract the Titter username ('name') and the tweet ('text'). For some reason I can't seem to get any of the objects to echo. Here is what I have.. $tweetid = '76626185060225024'; $jsonurl = "http://api.twitter.com/1/statuses/show/".$tweetid.".json"; $json = file_get_contents($jsonurl); $data = json_decode($json); // echo $jsonurl; //echo $data; // echo $json; //echo $data['0']['text']; // print_r($data); echo $data['0']->name; //$tweet = $data[0]->text; //$tweet = html_entity_decode($tweet); echo $twitterName; You can tell by the commenting that I have tried a lot of things. Thanks for the help in advance.
  2. So I am trying to extract a title out of an external webpage. There code on the external page is this.. <td valign="top" align="left"><font class="resultCourse"><u>Introduction to Java</u></font></td> </tr> <tr> <td colspan="2"><img src="/images/spacer.gif" height="3" width="1" alt="spacer"></td> </tr> <tr> <td colspan="2" align="center"> </td> </tr> </table> </td> </tr> </table> </td> </tr> <tr bgcolor="#FFFFFF"> <td align="left" valign="top"><font class="resultDesc"><font class="resultDescTitle"><u>Description</u></font>: <p>Fall, Spring <br> This course provides software developers with the knowledge and skills to use Java to build Internet and Intranet applets and Windows applications. Topics include overview of the Java virtual machine, Java classes and method, instantiating Java objects, access method, creating Java applets, the Java applet life cycle, inheritance and polymorphism, and Java class libraries.</p> </font></td> </tr> I am trying to pull out just "Introduction to Java." However, this must work across many different pages. The page describes a course, it needs to work with all courses. Here is what I wrote in PHP to pull it. ($returned_content is the URL) $courseStart = "Introduction to"; $courseFinish = "</u></font></td>"; $cpos = strpos($returned_content, $courseStart); echo $cpos; $cpos1 = strpos($returned_content, $courseFinish); $ctotal = $cpos1 - $cpos; echo substr($returned_content, $cpos, $ctotal). "<br>"; This will pull out "18095Introduction to Java" My question is, what should i make $courseStart so that no matter what class is listed, it will output it on my side. If I use the HTML code ( <font class="resultCourse"><u> ) It wont work. Thanks in advance for any help
  3. Data passes through as a 1 or 0 from the previous page, 1 is supposed to go to service@domain.com, while 0 goes to sales@domain.com. For some reason, all of the email, no matter what the selection goes to sales@domain.com. Thanks in advance. <? $yes="service@domain.com"; // $yes="service@domain.com"; $no="sales@domain.com"; // $no="Service@gmail.com"; ?> <?php $vname=$_POST["name"]; $vemail=$_POST["email"]; $vphone=$_POST["phone"]; $vsubject=$_POST["subject"]; $vbody=$_POST["body"]; if($_POST['RadioGroup']==1) { $to=$yes; } else { $to=$no; } /* recipients */ //$to="Bussiness@gmail.com"; /* subject */ $subject = $vname; /* message */ $message = " <html> <head> <title>Contact</title> </head> <body> <p>Contact</p> <table border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"10\"> <tr> <td>name:</td><td>".$vname."</td> </tr> <tr> <td>Phone: </td><td>".$vphone."</td> </tr> <tr> <td>Email: </td><td>".$vemail."</td> </tr> <tr> <td>Location: </td><td>".$vsubject."</td> </tr> <tr> <td>Message: </td><td>".$vbody."</td> </tr> </table> </body> </html> "; /* To send HTML mail, you can set the Content-type header. */ $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=utf-8\r\n"; /* additional headers */ $headers .= "To: ".$to."\r\n"; $headers .= "From: ".$vemail."\r\n"; /* and now mail it */ mail($to, $subject, $message, $headers); echo "<h2>Thank you for contacting us! We will have a representative get back to you shortly.</h2>"; ?> Here is what the form look like on the previous page <label for="contact_bs">Are you currently an active program client?</label><br/> <input type="radio" value="1" name="RadioGroup" checked="checked">Yes<input type="radio" value="0" name="RadioGroup">No <br /> </p> <form onsubmit="return validateForm(this);" class="form-validate" id="contact" name="contact" method="post" action="contact_action.php"> <label class="required" for="contact_name">Name</label><br/> <input type="text" class="inputbox" value="" size="30" id="contact_name" name="name"/><br/> <label class="required" for="contact_phone">Phone</label><br/> <input type="text" class="inputbox" value="" size="30" id="contact_phone" name="phone"/><br/> <label class="required" for="contact_email">E-mail address</label><br/> <input type="text" class="inputbox" value="" size="30" id="contact_email" name="email"/><br/> <label class="required" for="contact_location">City / State</label><br/> <input type="text" class="inputbox" value="" size="30" id="contact_subject" name="subject"/><br/> <label class="required" for="contact_text">Enter your Message</label><br/> <textarea class="inputbox" id="contact_text" name="body" rows="10" cols="50"/></textarea><br/> <input type="submit" value="Send" class="contact-button" name="submit"/> <br/> </form>
  4. I am looking to make a zip code search on part of my website that will display what town the zip code the user types in, I see online you can buy these lists. Are there any free ones that have been updated this year? If not.. do all the websites that have zip code searches really buy these lists? Thanks
  5. Hello, currently I have a search field that searches a given database given a zip code, then pulls out the info it finds. The link for the results is www.mysite.com/results.php. Users canngive this link out as it wont show any information. How can i change the script so it would appear something like www.mysite.com/results.php"?ZIPCODE" currently the php of results.php looks something like this <title><?php echo $_POST['zipcode']; ?></title> <? include_once("header.php"); ?> <div class="topcontent"></div><div class="morewrap"><div class="content"> <? $zip = $_POST['zipcode']; if (preg_match("/^\w{1,10}$/", $zip, $matches)) { $query = "SELECT * FROM Companies, Zips, Zips_To_Company WHERE Zips_To_Company.company_id = Companies.company_id AND Zips_To_Company.zip_id = Zips.ZipCode AND Zips_To_Company.zip_id = '$zip' ORDER BY Rank ASC "; } else{ // we don't bother querying the database echo "Not A Valid Zip Code"; } $result = mysql_query($query); while ($row = mysql_fetch_array($result)){ echo "<span class=\"profile\"> <h2>".$row['CName']. "</h2><br>Located at: " . $row['Address']; echo ", ".$row['StateAbbr'] . "<br> Phone Number <b>" . $row['Phone']."</b><br>" ."Fax: ". $row['Fax']. "<br><b>Services:</b><br>". $row['Services'] . "<br><a href=http://".$row['Website']."> Visit ". $row['CName'] ."'s Website</a><br><a href= Mailto:".$row['email'].">Email ". $row['CName']."</a></span><br>"; } ?>
  6. Hello all, I am reading up on php and i had a question. I would like to create a company listing. Entering these companies into my database is no problem. How can i make each company have their own "static" page but it is dynamic. EX: www.example.com/companies/[company name] Currently im using a method that is searches by zip code, but my result is www.example.com/zip.php (zip.php takes the entered zip code as a variable, then pulls it from the db with the rest of the information) Is there any topic that i should be looking into to figure out how to do this? Thanks in advance for any help.
  7. ok so ill make them into sub-domains, however i still need to know how to make each company page a .php page. Currently i am using a GET method that blows for SEO.
  8. Hello all, I am developing a webpage that will have company profile pages (www.domain.com/companies/[company name] I have these companies stored in my database. I would like to dynamically create a .php page for each company. What is the best way to go upon this. I only know how to search company using the GET method. Thanks for your help
  9. Hey my site is intelligentpestsolutions.com and i have a zip code search for pest companies, i have a huge text document with every zip code in the country and what city and stae it is. How can i go upon implementing this into my website.
  10. the above one works, but it will only display Artists that have songs!
  11. Here is my code $query2 = "SELECT * From Songs where band_id = '$id'"; $result2 = mysql_query($query2) or die(mysql_error()); while($row2 = mysql_fetch_array($result2)){ $query = "SELECT * FROM Artists"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo $row['bandname']. " - ". $row['yearformed']. " - ". $row['locationformed']. " - ". $row['summary']." ".$row['id']." - ". $row2['name'];; $id = $row['id']; print '<td><a href="'; print ($_SERVER['PHP_SELF']); print '?delete_id='.$id.'">Delete</a></td>'; print '</tr>'."\n"; }} ?> I have a table named "Songs" and "Artists" I have band_id in "Songs" and i would like every song by each band to come out next to it. What am I doing wrong? --I am connecting to the database fine--
  12. This is prolly a very dumb question but I was curious to know the method commonly used to remember data that is stored in mysql fields. For example Facebook status'. I assume they use on mysql field for it, but how do they always remember it. Do they store it in a excel file or something?
  13. haha im stupid forgot to query it, thank you
  14. $_POST['zips'] = 10567,10567...... and the query dosent even work, nothing put into the db
  15. $_POST['zips'] = 10567,10567...... and the query dosent even work, nothing put into the db
  16. code $zips = $_POST['zips']; $zipsextracted = explode(",", $zips); mysql_connect("-----", "--------", "------"); mysql_select_db("--------") or die( "Unable to select database"); foreach($zipsextracted as $zip) { "INSERT INTO `Zips_To_Company` (`id`, `company_id`, `zip_id`) VALUES ('', '1', '$zip')"; } echo $zipsextracted; ------Displays "array" when i turn the query into a variable it only shows the last item in the array.
  17. I have a form that is named "Numbers" I will be putting data that looks like: "1,4433,4567645,33245654,345," there will be hundreds of numbers. i am assuming i need to use explode() and remove then put the numbers in an array to store in different rows. how would i write this code?
  18. BlueSky, That is not returning anything. Barand- How would i go upon using a JOIN, in the SQL statement i have provided. I have a table of companies, with a field full of zipcodes. and i have table of zip codes, each zipcode has a town state etc.. When a user searches there own zip code, compnay info will come up, and information about the zip code will come up.
  19. I get this SQL error MySQL client ran out of memory With this query SELECT * FROM `Companies`, `Zips` WHERE `ZipCodes` LIKE CONVERT(_utf8 '%$zip%' USING latin1) COLLATE latin1_german2_ci ORDER BY Rank ASC Whats going on?
  20. Here is my code SELECT Companies.Name, Companies.Address, Companies.Website, Companies.Email, Companies.Services, Companies.Fax, Companies.Phone, Companies.ZipCodes, Zips.ZipCode, Zips.StateAbbr FROM Companies, Zips WHERE Companies.ZipCodes LIKE \%'$zip'%\ i get the error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\%'10511'%\' at line 1
  21. Hello, If i have a field that has a bunch of city names, how can i start a search to see if the city is in that field or not? The cities are separated by commas
  22. Here is my code ...$zip is from $_POST['zip'] if (preg_match("/^\w{1,10}$/", $zip, $matches)) { echo $zip; $query = "SELECT Companies.Name, Companies.Phone, Companies.ZipCodes, Zips.ZipCode FROM Companies, Zips Where Zips.ZipCode='$zip'"; } else{ // we don't bother querying the database echo "Not A Valid Zip Code"; } while($row = mysql_fetch_array($query)){ echo "Zip Code Phone Numbers: " . $row['Companies.Phone']; }
  23. After 3 hours i finally understood how to do this. All company zip codes are stored in the "Companys" Table I then use the Join Query with w/e zip code the user typed in, and i will get all my company data. Thank you guys very much
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.