PHP - Help To Add Dropdownlist To Weather Script
Similar Tutorialsanyone have experience integrating the WeatherBug API and PHP to pull data? Specifically I want to pull zip code from a MySQL DB and integrate with the API to display the weather for a specific zip code based location. Hi, I'm trying to get weather from google. it is working fine on my local machine. but when i make the page live it starts giving error as follow: Warning: simplexml_load_file(): http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /vhost/vhost10/d/x/b/dxbconnect.com/www/demo/weather.php on line 9 Warning: simplexml_load_file(http://www.google.com/ig/api?weather=dubai): failed to open stream: no suitable wrapper could be found in /vhost/vhost10/d/x/b/dxbconnect.com/www/demo/weather.php on line 9 Warning: simplexml_load_file(): I/O warning : failed to load external entity "http://www.google.com/ig/api?weather=dubai" in /vhost/vhost10/d/x/b/dxbconnect.com/www/demo/weather.php on line 9 Fatal error: Call to a member function xpath() on a non-object in /vhost/vhost10/d/x/b/dxbconnect.com/www/demo/weather.php on line 10 can anyone help please? This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=326509.0 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. Good Day guys
I need some help with something that I am busy with. I have a wallpaper that need to get weather effects on it but it has to be according to the current weather status and time. The wallpaper is in the attached. I have searched the net the whole day now and cant find what I am looking for.
Let me give an example:
If it rains the background wallpaper must have the rainy look and be wet, when its sunny there need to be a sun and the background must be brighter.
Please help me with this.
Attached Files
bg.jpg 127.22KB
0 downloads hi friends! this code Code: [Select] foreach ( $users as $key => $value ) { $user_ids = implode(',', $value); echo "$key - $user_ids<br />"; } sends this output: Code: [Select] user one - 376,373 user charlie - user beta - 372 I need the $user_ids are shown in a DropDownList, of course only if the $user_ids is not empty. How can I do? thanks! how could I get the next days forecasted high and low temp from this feed into php variables? feed://view/1292654647//http://newsrss.bbc.co.uk/weather/forecast/2818/Next3DaysRSS.xml any help appreciated. thanks in advance. Hi. I got this code below, which makes a dropdownlist. the value is passed in a string to a URL. The value EXAMPLE: is 13:30pm, but what reaches the URL is 13 If i add the mysql_real_escape_string, the full value is passed to the URL. BUT so is the "mysql_real_escape_string".. what is wrong with this code? this example does not work period: $query = "SELECT DISTINCT timeslot_start FROM #__profile_rates ORDER BY timeslot_start ASC"; $dropDownList ="<select class=\"inputbox\" name=\"timeslotstart\">"; $timeslotstarts =doSelectSql($query); foreach ($timeslotstarts as $timelotstart) { $timeslot_start=mysql_real_escape_string($timelotstart->timeslot_start); $dropDownList .= "<option value=$timeslot_start>".$timeslot_start."</option>"; } $dropDownList.="</select>"; $output['TIMESLOTSTART']=$dropDownList; but if i change to this it works but gives the "mysql_real_escape_string" in the url foreach ($timeslotstarts as $timelotstart) { $timeslot_start=$timelotstart->timeslot_start; $dropDownList .= "<option value=mysql_real_escape_string($timeslot_start)>".$timeslot_start."</option>"; } //Url looks like www.xxxx.com/xxx/x//xxxx/timeslotstart=mysql_real_escape_string(13%3A30pm), Everything is correct except the mysql_real_escape_string and the "(" and ")" should not be passed. how can i write this? Hi all,
I'm trying to code a dependable dropdownlist with php/mysql/ajax.
Goal is to select one thing in the first dropdown and depending on that option (and without reloading the page) enabling the second and add the options to the second, dependant on the first.
This is the index :
<?php require_once($_SERVER['DOCUMENT_ROOT'].'/dbconnect.php'); ?> <script type="text/javascript" src="http://ajax.googleapis.com/ ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $(".country").change(function() { var id=$(this).val(); var dataString = 'id='+id; $.ajax ({ type: "POST", url: "edit_form.php", data: dataString, cache: false, success: function(html) { $(".city").html(html); } }); }); }); </script> <?php $id_test=$_POST['selector']; $N = count($id_test); for($i=0; $i < $N; $i++) { $result = mysqli_query($conn, "SELECT * FROM cloud where id='$id_test[$i]'"); while($row = mysqli_fetch_array($result)) { $id_bird = $row['id']; ?> <div style="margin:80px"> <label>Country :</label> <select name="country" class="country"> <option selected="selected">--Select Country--</option> <?php $sql=mysqli_query($conn, "SELECT category.id AS cat_id, category.name, category.type, cloud.id FROM cloud,category,link_category_cloud WHERE link_category_cloud.cloud_id = cloud.id AND link_category_cloud.category_id = category.id AND cloud.id='$id_test[$i]'"); while($row=mysqli_fetch_array($sql)) { $id_test=$row['cat_id']; $data=$row['name']; echo '<option value="'.$id_test.'">'.$data.'</option>'; } ?> </select> <br/> <br/> <label>City :</label> <select name="city" class="city"> <option selected="selected">--Select City--</option> </select> </div> <?php } } ?>And this is the edit_form.php part : <?php require_once($_SERVER['DOCUMENT_ROOT'].'/dbconnect.php'); $cat_id = $_GET['cat_id']; $cloud_id = $_GET['id']; if($_POST['id_test']) { $id_test=$_POST['id_test']; $data=$_POST['data']; $sql=mysqli_query($conn, "SELECT * FROM link_category_cloud WHERE category_id={$cat_id}"); $data=$row['cloud_id']; $id_test=$_POST['id_test']; echo '<option value="'.$id_test.'">'.$id_test.' '.$data.'</option>'; //} } ?>Now, it does not work. I'm not only tring to pass through ID to 'edit_form.php', but also $data and $id_test[i]. Any idea how I can do this? Thank you very much, all help is so appreciated!! Hey guys, i'm new to this site and would need some help with coding. So i'm making a car part website which should has brand/model search. It's a dropdown search which will get the brand / model from database and should display all the parts for that exact model, from folder. Database structure which i have is id, master, name. ( Here's some pictures to clear out what i'm doing. http://imgur.com/a/7XwVd ) So the problem is that it does not get the images from folder named ex: *_audi_a3.jpg. And link to codes what have been written already. Parts.php: http://pastebin.com/q6vdypge Update.php: http://pastebin.com/DymhGQ17 Search_images.php: http://pastebin.com/LF5Q0i8f Core.js: http://pastebin.com/bgc0y4TS I don't know what's wrong with it sadly. One thing i noticed when i used firebug it gives error on category when searching error:true. Hope you guys understand what i mean here, and also all help is appreciated. And move this post if it's in wrong place. Thanks! Edited by aeonius, 17 October 2014 - 12:15 PM. Hi, I need to call to this text to add a all with value "blank/empty" or "0" to the dropdownlist code below.. it should be inserted int the first position in the dropdownlist and have a value blank and call to this text from the language files: $searchAll = gettext('_LANGUAGE_SEARCH_ALL',_LANGUAGE_SEARCH_ALL,false,false); example is: ratestitle=>0 gettext('_LANGUAGE_SEARCH_ALL',_LANGUAGE_SEARCH_ALL,false,false); the words it calls is "ALL" when the user selects or leaves the "ALL" in the list the value remains empty this allows the search to search everything.. basically im stuck how to get it in the dropdown list as the first default position: can anyone help? here is my code://this is a search function which calls to the field rate_title the text from the select box is matched to the database table and the search pages shows the search option is the search is successful.. I have 5 of these types of searches but cant give a broader search option to my users as the values must be selected to search--- i need the option "ALL" to have a "EMPTY" value or no value.... if (in_array("ratestitle",$searchOptions)&& $showSearchOptions ) { if (empty($sch->filter['ratestitle']) ) $selectOption=$output['LANGUAGE_SEARCH_RATESTITLE']; else $selectOption=$sch->filter['ratestitle']; $showButton=true; $query = "SELECT DISTINCT rate_title FROM #__rates_table ORDER BY rate_title ASC"; $dropDownList ="<select class=\"inputbox\" name=\"ratestitle\">"; $ratesitles =doSelectSql($query); foreach ($ratesitles as $ratetitle) { $selected=""; $rate_title=$ratetitle->rate_title; if ($ratetitle==".$sch->filter['ratestitle'].") $selected="selected"; $dropDownList .= "<option ".$selected." value=\"".$rate_title."\">".$rate_title."</option>"; } $dropDownList.="</select>"; $output['RATESTITLE']=$dropDownList; } Hi everyone! I've been working on a php script to replace links that contain a query with direct links to the files they would redirect to. Hi i have this upload script which works fine it uploads image to a specified folder and sends the the details to the database. but now i am trying to instead make a modify script which is Update set so i tried to change insert to update but didnt work can someone help me out please this my insert image script which works fine but want to change to modify instead Code: [Select] <?php mysql_connect("localhost", "root", "") or die(mysql_error()) ; mysql_select_db("upload") or die(mysql_error()) ; // my file the name of the input area on the form type is the extension of the file //echo $_FILES["myfile"]["type"]; //myfile is the name of the input area on the form $name = $_FILES["image"] ["name"]; // name of the file $type = $_FILES["image"]["type"]; //type of the file $size = $_FILES["image"]["size"]; //the size of the file $temp = $_FILES["image"]["tmp_name"];//temporary file location when click upload it temporary stores on the computer and gives it a temporary name $error =array(); // this an empty array where you can then call on all of the error messages $allowed_exts = array('jpg', 'jpeg', 'png', 'gif'); // array with the following extension name values $image_type = array('image/jpg', 'image/jpeg', 'image/png', 'image/gif'); // array with the following image type values $location = 'images/'; //location of the file or directory where the file will be stored $appendic_name = "news".$name;//this append the word [news] before the name so the image would be news[nameofimage].gif // substr counts the number of carachters and then you the specify how how many you letters you want to cut off from the beginning of the word example drivers.jpg it would cut off dri, and would display vers.jpg //echo $extension = substr($name, 3); //using both substr and strpos, strpos it will delete anything before the dot in this case it finds the dot on the $name file deletes and + 1 says read after the last letter you delete because you want to display the letters after the dot. if remove the +1 it will display .gif which what we want is just gif $extension = strtolower(substr($name, strpos ($name, '.') +1));//strlower turn the extension non capital in case extension is capital example JPG will strtolower will make jpg // another way of doing is with explode // $image_ext strtolower(end(explode('.',$name))); will explode from where you want in this case from the dot adn end will display from the end after the explode $myfile = $_POST["myfile"]; if (isset($image)) // if you choose a file name do the if bellow { // if extension is not equal to any of the variables in the array $allowed_exts error appears if(in_array($extension, $allowed_exts) === false ) { $error[] = 'Extension not allowed! gif, jpg, jpeg, png only<br />'; // if no errror read next if line } // if file type is not equal to any of the variables in array $image_type error appears if(in_array($type, $image_type) === false) { $error[] = 'Type of file not allowed! only images allowed<br />'; } // if file bigger than the number bellow error message if($size > 2097152) { $error[] = 'File size must be under 2MB!'; } // check if folder exist in the server if(!file_exists ($location)) { $error[] = 'No directory ' . $location. ' on the server Please create a folder ' .$location; } } // if no error found do the move upload function if (empty($error)){ if (move_uploaded_file($temp, $location .$appendic_name)) { // insert data into database first are the field name teh values are the variables you want to insert into those fields appendic is the new name of the image mysql_query("INSERT INTO image (myfile ,image) VALUES ('$myfile', '$appendic_name')") ; exit(); } } else { foreach ($error as $error) { echo $error; } } //echo $type; ?> I'm having trouble echoing $year in my script. Listed below is the script, just below ,$result = mysql_query("SELECT * FROM $dbname WHERE class LIKE '%$search%'") or die(mysql_error());, in the script I try to echo $year. It doesn't show up in the table on the webpage. Everything else works fine. Any help wold be appreciated greatly. Thanks in advance. <?php include 'config2.php'; $search=$_GET["search"]; // Connect to server and select database. mysql_connect($dbhost, $dbuser, $dbpass)or die("cannot connect"); mysql_select_db("vetman")or die("cannot select DB"); $result = mysql_query("SELECT * FROM $dbname WHERE class LIKE '%$search%'") or die(mysql_error()); // store the record of the "" table into $row //$current = ''; echo "<table align=center border=1>"; echo "<br>"; echo "<tr>"; echo "<td align=center>"; ?> <div style="float: center;"><a><h1><?php echo $year; ?></h1></a></div> <?php echo "</td>"; echo "</tr>"; echo "</table>"; // keeps getting the next row until there are no more to get if($result && mysql_num_rows($result) > 0) { $i = 0; $max_columns = 2; echo "<table align=center>"; echo "<br>"; while($row = mysql_fetch_array($result)) { // make the variables easy to deal with extract($row); // open row if counter is zero if($i == 0) echo "<tr>"; echo "<td align=center>"; ?> <div style="float: left;"> <div><img src="<?php echo $image1; ?>"></div> </div> <?php echo "</td>"; // increment counter - if counter = max columns, reset counter and close row if(++$i == $max_columns) { echo "</tr>"; $i=0; } // end if } // end while } // end if results // clean up table - makes your code valid! if($i > 0) { for($j=$i; $j<$max_columns;$j++) echo "<td> </td>"; echo '</tr>'; } mysql_close(); ?> </table> hey guys im really just after a bit of help/information on 2 things (hope its in the right forum).
1. basically I'm wanting to make payments from one account to another online...like paypal does...im wondering what I would need to do to be able to do this if anyone can shine some light please?
2.as seen on google you type in a query in the search bar and it generates sentences/keywords from a database
example:
so if product "chair" was in the database
whilst typing "ch" it would show "chair" for a possible match
I know it would in tale sql & json but im after a good tutorial/script of some sort.
if anyone can help with some information/sites it would be much appreciated.
Thank you
Hello, I stored a fsockopen function in a separate "called.php" file, in order to run it as another thread when it needs. The called script should return results to the "master.php" script. I'm able to run the script to get the socket working, and I'm able to get results from the called script. I tried for hours but I can't do the twice both My master.php script (with socket working): Code: [Select] <?php $command = "(/mnt/opt/www/called.php $_SERVER[REMOTE_ADDR] &) > /dev/null"; $result = exec($command); echo ("result = $result\r\n"); ?> and my called.php script Code: [Select] #!/mnt/opt/usr/bin/php-cli -q <?php $device = $_SERVER['argv'][1]; $port = "8080"; $fp = fsockopen($device, $port, $errno, $errstr, 5); fwrite($fp, "test"); fclose($fp); echo ("normal end of the called.php script"); ?> In the master script, if I use Code: [Select] $command = "(/mnt/opt/www/called.php $_SERVER[REMOTE_ADDR] &) > /dev/null"; the socket works, but I have nothing in $result (note also that I don't anderstand why the ( ... &) are needed!?) and if I use Code: [Select] $command = "/mnt/opt/www/called.php $_SERVER[REMOTE_ADDR]"; I have the correct text "normal end of the called.php script" in $result but the socket connection is not performed (no errors in php logs) Could you help me to find a way to let's work the two features correctly together? Thank you. I'm trying to use this script known as SimpleImage.php that can be found here <a href="http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php">link</a> I'm trying to include what is on the bottom of the page to my existing script can anyone help me I've tried several ways but its not working. Code: [Select] <?php session_start(); error_reporting(E_ALL); ini_set('display_errors','On'); //error_reporting(E_ALL); // image upload folder $image_folder = 'images/classified/'; // fieldnames in form $all_file_fields = array('image1', 'image2' ,'image3', 'image4'); // allowed filetypes $file_types = array('jpg','gif','png'); // max filesize 5mb $max_size = 5000000; //echo'<pre>';print_r($_FILES);exit; $time = time(); $count = 1; foreach($all_file_fields as $fieldname){ if($_FILES[$fieldname]['name'] != ''){ $type = substr($_FILES[$fieldname]['name'], -3, 3); // check filetype if(in_array(strtolower($type), $file_types)){ //check filesize if($_FILES[$fieldname]['size']>$max_size){ $error = "File too big. Max filesize is ".$max_size." MB"; }else{ // new filename $filename = str_replace(' ','',$myusername).'_'.$time.'_'.$count.'.'.$type; // move/upload file $target_path = $image_folder.basename($filename); move_uploaded_file($_FILES[$fieldname]['tmp_name'], $target_path); //save array with filenames $images[$count] = $image_folder.$filename; $count = $count+1; }//end if }else{ $error = "Please use jpg, gif, png files"; }//end if }//end if }//end foreach if($error != ''){ echo $error; }else{ /* -------------------------------------------------------------------------------------------------- SAVE TO DATABASE ------------------------------------------------------------------------------------ -------------------------------------------------------------------------------------------------- */ ?> Well the subject line is pretty explicit. I found this script that uploads a picture onto a folder on the server called images, then inserts the the path of the image on the images folder onto a VACHAR field in a database table. Code: [Select] <?php //This file inserts the main image into the images table. //address error handling ini_set ('display_errors', 1); error_reporting (E_ALL & ~E_NOTICE); //authenticate user //Start session session_start(); //Connect to database require ('config.php'); //Check whether the session variable id is present or not. If not, deny access. if(!isset($_SESSION['id']) || (trim($_SESSION['id']) == '')) { header("location: access_denied.php"); exit(); } else{ // Check to see if the type of file uploaded is a valid image type function is_valid_type($file) { // This is an array that holds all the valid image MIME types $valid_types = array("image/jpg", "image/jpeg", "image/bmp", "image/gif"); if (in_array($file['type'], $valid_types)) return 1; return 0; } // Just a short function that prints out the contents of an array in a manner that's easy to read // I used this function during debugging but it serves no purpose at run time for this example function showContents($array) { echo "<pre>"; print_r($array); echo "</pre>"; } // Set some constants // This variable is the path to the image folder where all the images are going to be stored // Note that there is a trailing forward slash $TARGET_PATH = "images/"; // Get our POSTed variable $image = $_FILES['image']; // Sanitize our input $image['name'] = mysql_real_escape_string($image['name']); // Build our target path full string. This is where the file will be moved to // i.e. images/picture.jpg $TARGET_PATH .= $image['name']; // Make sure all the fields from the form have inputs if ( $image['name'] == "" ) { $_SESSION['error'] = "All fields are required"; header("Location: member.php"); exit; } // Check to make sure that our file is actually an image // You check the file type instead of the extension because the extension can easily be faked if (!is_valid_type($image)) { $_SESSION['error'] = "You must upload a jpeg, gif, or bmp"; header("Location: member.php"); exit; } // Here we check to see if a file with that name already exists // You could get past filename problems by appending a timestamp to the filename and then continuing if (file_exists($TARGET_PATH)) { $_SESSION['error'] = "A file with that name already exists"; header("Location: member.php"); exit; } // Lets attempt to move the file from its temporary directory to its new home if (move_uploaded_file($image['tmp_name'], $TARGET_PATH)) { // NOTE: This is where a lot of people make mistakes. // We are *not* putting the image into the database; we are putting a reference to the file's location on the server $sql = "insert into images (member_id, image_cartegory, image_date, image) values ('{$_SESSION['id']}', 'main', NOW(), '" . $image['name'] . "')"; $result = mysql_query($sql) or die ("Could not insert data into DB: " . mysql_error()); header("Location: images.php"); echo "File uploaded"; exit; } else { // A common cause of file moving failures is because of bad permissions on the directory attempting to be written to // Make sure you chmod the directory to be writeable $_SESSION['error'] = "Could not upload file. Check read/write persmissions on the directory"; header("Location: member.php"); exit; } } //End of if session variable id is not present. ?> The script seems to work fine because I managed to upload a picture which was successfully inserted into my images folder and into the database. Now the problem is, I can't figure out exactly how to write the script that displays the image on an html page. I used the following script which didn't work. Code: [Select] //authenticate user //Start session session_start(); //Connect to database require ('config.php'); $sql = mysql_query("SELECT* FROM images WHERE member_id = '".$_SESSION['id']."' AND image_cartegory = 'main' "); $row = mysql_fetch_assoc($sql); $imagebytes = $row['image']; header("Content-type: image/jpeg"); print $imagebytes; Seems to me like I need to alter some variables to match the variables used in the insert script, just can't figure out which. Can anyone help?? Hi, I am trying to run two scripts on one page. When I use just one script on the page they work however when I place both scripts on the same page one of them disrupts the other script. This script prevents the other following script from working: Code: [Select] ini_set('display_errors', 1); error_reporting(-1); { $query = "SELECT * FROM answers ORDER BY `aid` DESC LIMIT 0, 11"; } $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) { $answer = $row['answer']; $aid = $row['aid']; echo " <div class='questionboxquestion'> <a href= 'http://www.domain.co.uk/test/easy/answer.php?aid=$aid' class='questionlink'>$answer</a> </div> <div class='questionboxnotes'> </br> </div> <div class='questionboxlinks'> <div class='questionboxcategory'> <div class='questionboxcategorytitle'> Category: </div> <a href= 'http://www.domain.co.uk/test/easy/furniture-category.php' class='questionanswerlink'></a> </div> <div class='questionboxanswerlink'> <a href= 'http://www.domain.co.uk/test/oeasy/index.php' class='questionanswerlink'>Answer</a> </div> </div> "; } Code: [Select] <?php if($error) echo "<span style=\"color:#ff0000;\">".$error."</span><br /><br />"; ?> <label for="username">Username: </label> <input type="text" name="username" value="<?php if($_POST['username']) echo $_POST['username']; ?>" /><br /> <label for="password">Password: </label> <input type="password" name="password" value="<?php if($_POST['password']) echo $_POST['password']; ?>" /><br /> <label for="password2">Retype Password: </label> <input type="password" name="password2" value="<?php if($_POST['password2']) echo $_POST['password2']; ?>" /><br /> <label for="email">Email: </label> <input type="text" name="email" value="<?php if($_POST['email']) echo $_POST['email']; ?>" /><br /><br /> <input type="submit" name="submit" value="Register" /> How would I go about making it to where,, I can tell the script to use a certain extension of php in the script like curl.. ? Thanks |