PHP - Checking For Valid Data Question
Hi there,
I was thinking of using this following check system to see if a user has entered a good valid value for a categories selection, but it is just is_numeric, here's my line of single code for this: Code: [Select] if(!array_key_exists('category', $_GET) || trim(is_numeric($_GET['category'])) == '') Is there anything better that I can be using than is_numeric()? I mean this would allow 2.22 which for the categories selection, would not be valid, I will only be allowing integer values, I mean it would potentially come up with no category selected but that wouldn't be very good would it? It could be applied to a blog I am doing aswell, any guidance on such an improvement on this function would very much be appreciated, Jeremy. Similar TutorialsHello all, I'm currently doing this Facebook connect module for my website. With the FBconnect, it creates a user profile on my mysql, which stores only the Facebook userid, the full name, and the thumbnail url of this user. Currently the code works well except for this 'image url checking'. this is my fb profile image url: http://profile.ak.fbcdn.net/hprofile-ak-snc4/hs349.snc4/41540_772137439_5612219_q.jpg when I've added a 'XXX' at the back ( http://profile.ak.fbcdn.net/hprofile-ak-snc4/hs349.snc4/41540_772137439_5612219_qXXX.jpg ). It returns a blank instead. On Facebook, some accounts are not genuine and they might the deleted sooner or later. So I'm trying to figure out a php script or functions which detect if the image is not the 'XXX' version. I've tried using getimagesize() or file_get_contents() but still won't work. any ideas? I'm terrible at getting my question clear, but this is my last try. I got this which gets sent when clicking the button; echo"Auto/Prijs<br><br><select name='autos'>"; echo"<br><br>"; $sql = "SELECT `garage`.`id`, `car_id`, `schade`, `naam`, `prijs` FROM `garage` LEFT JOIN `cars` ON (`garage`.`car_id` = `cars`.`id`) WHERE `user_id`=".ID." ORDER BY `id` ASC LIMIT ".($page * 10).", 10"; $sql = mysql_query($sql) or die(mysql_error()); $i = 1; while($res = mysql_fetch_assoc($sql)){ echo" <option value='".$res['car_id']."'>".$res['naam']."</option><br> ";This is a dropdown, showing carnames instead of car_id's. Now, the car_id is not unique, but refers to a car. The 'id' in the 'garage' table IS unique. Am I able to like call the 'id' too, and on sending check if that ID is actually the sent 'car_id'? Because, you can tamper the sent car_id and simply change it. This happens on sending: if(isset($_POST['start'])){ $prijs = $_POST['prijs']; $carr = $_POST['autos']; $sql = mysql_query("SELECT `id` FROM `automarkt` WHERE `seller_id`=".ID." LIMIT 1") or die(mysql_error()); mysql_query("INSERT INTO `automarkt`(`seller_id`, `prijs`, `car_id`) VALUES (".ID.", ".$prijs.", ".$carr.")") or die(mysql_error());I'm out of idea's, and can't get clear enough on what I need to do. I need to check if the sent car_id is actually in the 'user''s garage. (Trying to do it by checking the unique entry 'id' in the 'garage' table. Hi, Im trying to generate a random 4- digit code, and then check if it is allready in the database. My current code is below, but im not sure how to make it loop again, if the code exists. Also, im not sure if this is the best way of doing this, maybe someone could suggest something better... This is basicly what im trying to do: 1. hash the code 2. check if it exits in the DB 3. if it does, re-generate, and repeat 2., if not, return it function getUniqueHash() { global $mysql_server, $mysql_user, $mysql_password; $code = substr(md5(uniqid(rand(), true)), 0, 4); mysql_connect($mysql_server, $mysql_user, $mysql_password); // connect // $sql = "SELECT * FROM `$mysql_db`.`short` WHERE `short` = '$code'"; $result = mysql_query($sql); $results = mysql_numrows($result); if($results > 0) { //GO BACK AND RE-GENERATE CODE AND REPEAT CHECK } else { return $code; } mysql_close(); } PasteBin: Quote http://paste.tgxn.net/?s=9 Hi, I'm making a website that uses data stored in SQL. One of my pages allows the user to enter a new product into a product table. I was wondering if somebody could help me with some validation or Query that will not allow the user to enter a product name that already exists in the table? Code: [Select] $nameNew = $_POST['new]; $nameID = $_POST['newID]; $namePrice = $_POST['newPrice]; INSERT INTO products VALUES ($nameNew, $newID, $newPrice) $describeQuery = "SELECT ID, Name, Price FROM Products"; $results = sqlsrv_query($conn, $describeQuery); echo '<table border="1" BORDERCOLOR=Black>'; echo '<tr><th bgcolor = "LightBlue">Name</th><th bgcolor = "LightBlue" >ID</th> <th bgcolor = "LightBlue" >Price</th></tr>'; while($row = sqlsrv_fetch_array($results, SQLSRV_FETCH_ASSOC)) { echo '<tr>'; echo '<td >' .$row['Name'].'</td>'; echo '<td>' .$row['ID'].'</td>'; echo '<td>' .$row['Price'].'</td>'; echo '</tr>'; } echo '</table>'; sqlsrv_close($conn); Thanks Friends, I want to check a site if there is any data avaliable for a given Domain Name.... For example Quote http://www.keywordspy.com/research/search.aspx?tab=domain-organic&market=uk&q=abc.co.uk In this URl the Domain is the "&q=" POST Parameter which is: abc.co.uk In the Output, Observe the Columns Keyword, Position, Volume etc.... So for any Domain we want to check if there is one or more keyword returned. Here is the Example of a Domain for which there is no Data: Quote http://www.keywordspy.com/research/search.aspx?tab=domain-organic&market=uk&q=notfoundforme.co.uk As you Observe there is no data in Keyword, Position or Volume Columns for this Domain (i.e. notfoundforme.co.uk) All i want is to Echo All the Keywords, their Position and Volumes for any domain for which data is avaliable. Code: Here is the Code i have which scrapes the Whole data with Curl, but i am not able to make getkwspydata function work to get the Keyword, Position or Volume data for the domain, i know some regex and preg_match needs to be done but its too technical for me, may someone help me with this? <?php function getkwspydata($host) { $request = "http://www.google.com/search?q=" . urlencode("site:" . $host) . "&hl=en"; $request = "http://www.keywordspy.com/research/search.aspx?tab=domain-organic&market=uk&q=". urldecode($host); $data = getPageData($request); // preg_match('/<div id=resultStats>(About )?([\d,]+) result/si', $data, $p); // $value = ($p[2]) ? $p[2] : "n/a"; // $string = "<a href=\"" . $request . "\">" . $value . "</a>"; //return $string; print_r($data); } function getDomainName($host) { $hostparts = explode('.', $host); // split host name to parts $num = count($hostparts); // get parts number if(preg_match('/^(ac|arpa|biz|co|com|edu|gov|info|int|me|mil|mobi|museum|name|net|org|pp|tv)$/i', $hostparts[$num-2])) { // for ccTLDs like .co.uk etc. $domain = $hostparts[$num-3] . '.' . $hostparts[$num-2] . '.' . $hostparts[$num-1]; } else { $domain = $hostparts[$num-2] . '.' . $hostparts[$num-1]; } return $domain; } function getPageData($url) { if(function_exists('curl_init')) { $ch = curl_init($url); // initialize curl with given url curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // add useragent curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // write the response to a variable if((ini_get('open_basedir') == '') && (ini_get('safe_mode') == 'Off')) { curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // follow redirects if any } curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); // max. seconds to execute curl_setopt($ch, CURLOPT_FAILONERROR, 1); // stop when it encounters an error return @curl_exec($ch); } else { return @file_get_contents($url); } } $sitehost = ($_POST['sitehost']) ? $_POST['sitehost'] : $_SERVER['HTTP_HOST']; $sitedomain = getDomainName($sitehost); ?> <html> <head> <title>SEO Report for <?=$sitedomain;?></title> </head> <body> <form method="post" action="<?$_SERVER['PHP_SELF'];?>"> <p><b>Domain/Host Name:</b> <input type="text" name="sitehost" size='30' maxlength='50' value="<?=$sitehost;?>"> <input type="submit" value="Grab Details"></p> </form> <ul> <li>Google indexed pages: <?=getkwspydata($sitehost);?></li> </ul> </body> </html> Cheers Natasha T. currently I am using this: if ($display == "schedule") { $schedule = $ffn->getSchedule(); echo '<h4>Season Schedule</h4>'; echo '<p>Season: ', $schedule->Season, '</p>'; foreach($schedule->Games AS $game) { echo '<p>'; echo 'Week: ', $game->Week, ' ', $game->AwayTeam, ' at ', $game->HomeTeam, ' on ', date("M j, Y", strtotime($game->GameDate)), ' at ', $game->GameTime, ' ', $schedule->Timezone; echo '</p>'; } } It's working great... the only problem I want to be able for users to pick a week then have it display that weeks matchups... Any help would be greatly appreciated!! I wrote this code many moons ago... Code: [Select] if (preg_match('#^[A-Z \'.-]{2,20}$#i', $trimmed['firstName'])){ Can someone please help me remember... What do the two # signs do? Thanks, Debbie Hello all, I have a problem I'm not sure how to tackle. I have data in a database that looks looks like this: Field1 | Field2 AA | AA Row 1 Data AA | AA Row 2 Data AA | AA Row 3 Data AB | AB Row 4 Data AB | AB Row 5 Data AB | AB Row 6 Data AC | AB Row 7 Data AC | AB Row 8 Data AC | AB Row 9 Data AC | AB Row 10 Data I would like to grab and output JUST the first AA, AB, AC and the the row data in field two? So the loop would catch the first AA then when field1 data has changed it will output the first AB and so on... So the output would look like: Row1: AA : AA Row 1 Data Row2: AB : AA Row 4 Data Row3: AC : AA Row 7 Data Is there a way to accomplish this? Any help would be great! Thanks! Hello everyone.
I have some code that I need some assistance with. By the way I am using CentOS 6.5 on my Linux server.
Here is my current code:
<html> <head></head> <body> <?php if (!isset($_POST['q'])) { ?> <img src="/wvb-logo-slogen.png" border="0" /> //code for logo <h2>Search</h2> <form method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>"> <input type="text" name="q" size="30" /> </form> <?php } else { ?> <img src="/wvb-logo-slogen.png" border="0" /> //code for logo <h2>Search Results</h2> <?php try { // create object // $swish = new Swish('/usr/local/apache/htdocs/swish/index.swish-e'); $swish = new Swish('/var/www/html/pdf2/index.swish-e'); // get and run query from command-line $queryStr = htmlentities($_POST['q']); $result = $swish->query($queryStr); ?> Found <?php echo $result->hits; ?> match(es) for '<?php echo $queryStr; ?>'. <?php // iterate over result set // print details for each match while($r = $result->nextResult()) { ?> <p> <?php echo $r->swishreccount; ?> <strong> <a href="<?php echo '/pdf2', ltrim($r->swishdocpath, '.') ; ?>"> <?php echo $r->swishdocpath; ?> </a> </strong> (sco <?php echo $r->swishrank; ?>) <br/> <?php echo $r->swishdocpath; ?><br /> <?php $file = '/var/www/html/active_colist.csv'; $fh = fopen($file, 'r'); $companies = array(); $row = fgetcsv($fh, 1024); // ignore header while ($row = fgetcsv($fh, 1024)) { $companies[$row[0]] = array('company' => $row[1], 'country' => $row[3]); //changed line } fclose($fh); //Split a filename by . $filenames = explode(".", $r->swishdocpath); //get 3 chars from $filenames to $country $wvb_number = substr($filenames[1],1,12); $country = substr($filenames[1],1,3); echo 'Country: '.$companies[$wvb_number]['country']."<br />"; //echo 'Country Name: '.$country."<br />"; //$filenames[2] = explode(".", $r->swishdocpath); $year = substr($filenames[2],0,4); echo 'Year: '.$year."<br />"; //$filenames = explode(".", $r->swishdocpath); //$wvb_number = substr($filenames[1],1,12); echo 'WVB Number: '.$wvb_number."<br />"; echo 'Company Name: '.$companies[$wvb_number]['company']; ?> </p> //Suggested Pagination code. <?php ///////////////FILLING ARRAY WITH DUMMY DATA//////////////////// $key = array(); for($i=0; $i<200; $i++) { //fill array data $key[] = "num = ".$i; } //////////////////////////////////////////////////////////////// /////////////////////START OF ARRAY PAGINATION CODE///////////////////// $ptemp="http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; $pt=explode('&',$ptemp); if (strpos($ptemp,'pageno')) array_pop($pt); $pt=implode('&',$pt); $ptemp=$pt; $array=$key; // REPLACE $KEY WITH YOUR ARRAY VARIABLE $page = $_REQUEST['pageno']; $currentpage = isset($page) ? (integer)$page : 1; $numperpage = 10; //NUMBER OF RECORDS TO BE DISPLAYED PER PAGE $total = count($array); $numofpages = ceil($total / $numperpage); //TOTAL NUMBER OF PAGES if(isset($array)) { if (($currentpage > 0) && ($currentpages <= $numofpages)) { //STARTING LOOP FOR ARRAY DATA $start = ($currentpage-1) * $numperpage; for($i=$start;$i<=($numperpage+$start-1);$i++) { ///////////PLACE YOUR CODE HERE////////////////////////// echo $array[$i] .' '; //////////////////////////////////////////////////////// } } } if ($currentpage != 1) { //GOING BACK FROM PAGE 1 SHOULD NOT BET ALLOWED $previous_page = $currentpage - 1; $previous = '<a href="'.$ptemp.'?pageno='.$previous_page.'"> <</a> '; } $pages = ''; for ($a=1; $a<=$numofpages; $a++) { if ($a == $currentpage) $pages .= $a .'</u> '; else $pages .= '<a href="'.$ptemp.'?pageno='.$a.'" >'. $a .'</a> '; } $pages = substr($pages,0,-1); //REMOVING THE LAST COMMA (,) if ($currentpage != $numofpages) { //GOING AHEAD OF LAST PAGE SHOULD NOT BE ALLOWED $next_page = $currentpage + 1; $next = ' <a href="'.$ptemp.'?pageno='.$next_page.'"> ></a>'; } echo ' '. $previous . $pages . $next; //PAGINATION LINKS /////////////////////END OF ARRAY PAGINATION CODE///////////////////// ?> <?php } } catch (Exception $e) { die('ERROR: ' . $e->getMessage()); } } ?> </body> </html>As you can see from the code above when I implemented that code into my script I was able to get it to display but only after the </p> marker. When I did that I got the following results. Results: Found 736 match(es) for 'test'. 1 ./ITA000030192.2013.A.00.L.12.31.PDF (sco 1000) ./ITA000030192.2013.A.00.L.12.31.PDF Country: Italian Republic (Italy) Year: 2013 WVB Number: ITA000030192 Company Name: BEGHELLI num = 0 num = 1 num = 2 num = 3 num = 4 num = 5 num = 6 num = 7 num = 8 num = 9 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 > 2 ./ITA000030164.2013.A.00.L.12.31.PDF (sco 976) ./ITA000030164.2013.A.00.L.12.31.PDF Country: Italian Republic (Italy) Year: 2013 WVB Number: ITA000030164 Company Name: CREDITO EMILIANO num = 0 num = 1 num = 2 num = 3 num = 4 num = 5 num = 6 num = 7 num = 8 num = 9 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 > 127 ./IND000102048.2012.A.00.E.03.31.PDF (sco 457) ./IND000102048.2012.A.00.E.03.31.PDF Country: Year: 2012 WVB Number: IND000102048 Company Name: num = 0 num = 1 num = 2 num = 3 num = 4 num = 5 num = 6 num = 7 num = 8 num = 9 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 > 128 ./NLD000030064.2013.A.00.E.12.28.PDF (sco 457) ./NLD000030064.2013.A.00.E.12.28.PDFThe results page shows that there are 736 matches. There are currently 5000 PDF files in the /var/www/html/pdf2 directory. What I am trying to accomplish in terms of pagination is twofold. First get the above page links to display on the top and bottom of the page and only display 10 results at a time on each page. Second have the links working correctly so that they can go to the correct results. Can this be accomplished with the above pagination code where it states //Suggested pagination code? Do I need to change my layout? Furthermore I was also told that I should focus on the following lines of code: <?php ///////////////FILLING ARRAY WITH DUMMY DATA//////////////////// $key = array(); for($i=0; $i<200; $i++) { //fill array data $key[] = "num = ".$i; }as well as the result variable $queryStr = htmlentities($_POST['q']); $result = $swish->query($queryStr);What would I need to change in these two areas in order to get what it is that I am trying to accomplish. Sorry for the large post. Any assistance would be greatly appreciated. Hey guys.. I'm new to the forum and have a quick question about some coding i've been doing for my website. A couple index errors are coming up when I run my code, but I believe it all should be working fine. I am going to paste the code, but also upload the files so that you can understand the problem better. ANY help is greatly appreciated. I am currently making a contact form with validation. I know that using ifempty() is probably the best way, but I am unclear as to how to use it. I have two files, an html containing my form, and a php file containing the following code: //Define Variables $FirstName = $_GET['FirstNameTextBox']; $LastName = $_GET['LastNameTextBox']; $PhoneNumber = $_GET['PhoneNumberTextBox']; $EmailAddress = $_GET['EmailAddressTextBox']; $Address = $_GET['AddressTextBox']; $City = $_GET['CityTextBox']; $State = $_GET['StateDropDownBox']; $Zip = $_GET['ZipTextBox']; $error1='*Please enter a First Name<br>'; $error2='*Please enter a Last Name<br>'; $error3='*Please enter a Phone Number<br>'; $error4='*Please choose a state<br>'; $error5='*Please enter a valid email address<br>'; $day2 = mktime(0,0,0,date("m"),date("d")+2,date("Y")); $day3 = mktime(0,0,0,date("m"),date("d")+3,date("Y")); $day7 = mktime(0,0,0,date("m"),date("d")+7,date("Y")); if($FirstName=="") {echo $error1; exit;} if($LastName=="") {echo $error2; exit;} if($PhoneNumber=="") {echo $error3; exit;} if($State=="") {echo $error4; exit;} if($EmailAddress=="") {echo $error5; exit;} if($State == "NY") { echo "$FirstName $LastName - we will get back to you within 2 days, ie before " .date("d M Y", $day2); exit; } if($State == "NJ") { echo "$FirstName $LastName - we will get back to you within 3 days, ie before " .date("d M Y", $day3); exit; } if($State == "Other") { echo "$FirstName $LastName - we will get back to you within 1 week, ie before " .date("d M Y", $day7); exit; } The following errors come up: Notice: Undefined index: FirstNameTextBox in C:\Users\Jonny P\Documents\My Web Sites\JMPMySite\AddContact.php on line 14 Notice: Undefined index: LastNameTextBox in C:\Users\Jonny P\Documents\My Web Sites\JMPMySite\AddContact.php on line 15 Notice: Undefined index: PhoneNumberTextBox in C:\Users\Jonny P\Documents\My Web Sites\JMPMySite\AddContact.php on line 16 Notice: Undefined index: EmailAddressTextBox in C:\Users\Jonny P\Documents\My Web Sites\JMPMySite\AddContact.php on line 17 Notice: Undefined index: AddressTextBox in C:\Users\Jonny P\Documents\My Web Sites\JMPMySite\AddContact.php on line 18 Notice: Undefined index: CityTextBox in C:\Users\Jonny P\Documents\My Web Sites\JMPMySite\AddContact.php on line 19 Notice: Undefined index: StateDropDownBox in C:\Users\Jonny P\Documents\My Web Sites\JMPMySite\AddContact.php on line 20 Notice: Undefined index: ZipTextBox in C:\Users\Jonny P\Documents\My Web Sites\JMPMySite\AddContact.php on line 21 *Please enter a First Name Again, ANY help is greatly appreciated.. it is for a class, but I have honestly exhasted all my sources to figure out what is wrong. Are my codes correct and all there? Thanks for the help! -WPN I have code for displaying result from database:
foreach ($_SESSION["products"] as $cart_itm) { $product_code = $cart_itm["code"]; $results = $mysqli->query("SELECT * FROM products WHERE product_code='$product_code' LIMIT 1"); $obj = $results->fetch_object();Now, I display data with: $obj->product_name When I get the list, how to put inline numbers (1 2 3 4 ...)? 1 products1 2 products1 3 products1 4 products1.. I currently am working on a fantasy golf site. I have a table where I store each users picks by tournament. I want to be able to write a small snippet of code that can compare the current date and time to the Start Time in the database and display that weeks picks. I can do this the long way by extracting the date in each row and comparing it. Is there a way that I can do it without having to write out the code for each row in the database? this is the current code I have to do it the long way: Code: [Select] <?php $result2 = mysql_query("SELECT * FROM `2010_Picks` WHERE Id = 2"); echo "<table border='1'> <tr> <th>Tournament</th> <th>Player</th> <th>Golfer</th> </tr>"; while($row2 = mysql_fetch_array($result2)) { $result = mysql_query("SELECT * FROM `2012_tournaments` WHERE id = 2"); while($row = mysql_fetch_array($result)) { $time1 = strtotime($row['start_date_time']); if ($time2 < $time1) { echo "<tr>"; echo "<td>" . $row2['tournament'] . "</td>"; echo "<td>" . $row2['player'] . "</td>"; echo "<td>" . $row2['golfer'] . "</td>"; echo "</tr>"; } else echo "This did not work"; }}echo "</table>"; ?> So here is a small sample of the data I have stored in my database: Date Start Time Tournament Jan. 2-9 2012-01-06 16:10:00 Hyundai Tournament of Champions(Monday finish) Jan. 9-15 2012-01-12 16:00:00 Sony Open in Hawaii Jan. 16-22 2012-01-19 10:00:00 Humana Challenge in partnership with the Clinton Foundation Jan. 23-29 2012-01-26 10:00:00 Farmers Insurance Open Jan. 30-Feb. 5 2012-02-02 09:00:00 Waste Management Phoenix Open Feb. 6-12 2012-02-09 10:00:00 AT&T Pebble Beach National Pro-Am Feb. 13-19 2012-02-16 11:00:00 Northern Trust Open Feb. 20-26 2012-02-23 09:25:00 World Golf Championships-Accenture Match Play Championship Feb. 27-March 4 2012-03-01 07:00:00 The Honda Classic March 5-11 2012-03-08 07:00:00 World Golf Championships-Cadillac Championship March 12-18 2012-03-15 07:00:00 Transitions Championship March 19-25 2012-03-22 07:00:00 Arnold Palmer Invitational presented by MasterCard March 26-April 1 2012-03-29 08:00:00 Shell Houston Open April 2-8 2012-04-05 07:00:00 Masters Tournament # April 9-15 2012-04-12 07:00:00 RBC Heritage April 16-22 2012-04-19 09:00:00 Valero Texas Open April 23-29 2012-04-26 07:00:00 Zurich Classic of New Orleans April 30-May 6 2012-05-03 07:00:00 Wells Fargo Championship May 7-13 2012-05-10 07:00:00 THE PLAYERS Championship May 14-20 2012-05-17 09:00:00 HP Byron Nelson Championship May 21-27 2012-05-24 09:00:00 Crowne Plaza Invitational at Colonial May 28-June 3 2012-05-31 07:00:00 the Memorial Tournament presented by Nationwide Insurance June 4-10 2012-06-07 08:00:00 FedEx St. Jude Classic June 11-17 2012-06-14 11:00:00 U.S. Open # June 18-24 2012-06-21 07:00:00 Travelers Championship June 25-July 1 2012-06-28 07:00:00 AT&T National July 2-8 2012-07-05 07:00:00 THe Greenbrier Classic July 9-15 2012-07-12 08:00:00 John Deere Classic July 16-22 2012-07-19 01:00:00 The Open Championship # July 23-29 2012-07-26 07:00:00 RBC Canadian Open July 30-Aug. 5 2012-08-02 07:00:00 World Golf Championships-Bridgestone Invitational Aug. 6-12 2012-08-09 07:00:00 PGA Championship # Aug. 13-19 0000-00-00 00:00:00 Off week Aug. 20-26 2012-08-23 07:00:00 The Barclays Aug. 27-Sept. 3 2012-08-30 07:00:00 Deutsche Bank Championship (Monday Finish) Sept. 3-9 2012-09-06 07:00:00 BMW Championship Sept. 10-16 0000-00-00 00:00:00 Off week Sept. 17-23 2012-09-20 10:00:00 TOUR Championship by Coca-Cola Hello dear friends, hello community, i want to parse a site http://www.aktive-buergerschaft.de/buergerstiftungsfinder Well therefore i have a true beginner-question regarding Array in order to work with the data: beginner question The results should be stored in a MySQL-Database: well you see. i have a Curl-Approach: and i want to work with the parsed data: and in this case i want to give over the data into an array (if viewing the output in web browser, do view-source to see structured array). Here the musings that led to the code: Depending on num dimensions, we could do, foreach($result as $k => $v) {echo $k." ".$v} to view and work with data (adding sub foreach loops accordingly; i.e. if $v is itself an array) see the results: What do you think: Code: [Select] $ch = curl_init("http://www.aktive-buergerschaft.de/buergerstiftungsfinder"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $buffer = curl_exec($ch); curl_close($ch); $result = explode(",", $buffer); foreach($result as $k => $v) {echo $k." ".$v} if $v is itself an array) // print_r($result); look forward to hear from you!! db1 I have been trying to insert data into my database thru php script with no luck. I think its has to do with not being able access my database. My question is when I use MySQL command client and enter the password and get mysql> does that mean I can use that password to access my databases as long as I point to the correct database with the mysqli_connect function. I dont think I fully understand how this works. I have everything stored on my local computer and I use "localhost" in mysqli_connect function. $ARR[$i] == $NEEDLE ? $Count++ : $Count I am using it in: private function _countIf($ARR, $NEEDLE){ $Count = 0; for($i = 0; $i < count($ARR); i++){ $ARR[$i] == $NEEDLE ? $Count++ : $Count } return $Count; }Edited March 25, 2019 by Karaethon Hello! First... I'm sorry about my english skills.. Seems that with my own language I don't get a correct or good answer So.. I have a site where visitors can put there favorite links to other sites and show them to others. My problem is multiple urls to same locations in sites-table. example: http://google.com http://google.com/ http://www.google.com http://www.google.com/ http://www.google.com/index.php (?) they all lead to same... is there any light and powerfull way to check these? I'm trying to use query with "like" but it only works if there is exactly same url. I use fopen to check that url really exicst.. table: Sites (basic information for link) -id -url -title +some meta tags if found -timestamp I'm not asking to do me this code. But if someone can tell me just what functions and others I'm looking for and what I need for this... My coal is to keep sites-table as clean as it can be. If visitor adds a url that is already in sites-table only thing that happens is updating timestamp. Thank you all for helping me! -Roosterr With the following code i can create an xml file. Code: [Select] <?php $myXML = new SimpleXMLElement("<myroot></myroot>"); $title= $myXML->addChild('title'); $title->addAttribute('number','12'); $titleName= $title->addChild('titleName', 'title1'); $titleLink= $title->addChild('titleLink', 'link1'); Header('Content-type: text/xml'); echo $myXML->asXML(); ?> But when i check the validity of xml file http://www.validome.org/xml/validate/ This error occurs: Can not find declaration of element 'myroot'. I suppose that the problem is missing of !DOCTYPE and !ELEMENT lines. How can i create valid XML documents with PHP automatically?? Is it possible to make it without writing doctype and element types for the whole element types of xml by hand $title, $titleName and $titleLink Thank you I'm trying to list all the tables in my database. I got this code pretty much "word" for word from the example at php.net, but I get: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in E:\wamp\www\test\test-in.php on line 67 <?php $db= $_POST['db']; $sql= "SHOW TABLES FROM $db"; $result=mysql_query($sql); while ($tblarray = mysql_fetch_row($result)){ ?><a href="?tablename=<?php echo $tblarray[0];?>"><?php echo $tblarray[0];?></a><?php } ?> What is wrong? Warning: mysql_select_db(): supplied resource is not a valid MySQL-Link resource in /home/rweekly/public_html/2012/view_arguments.php on line 41 Warning: mysql_query(): supplied resource is not a valid MySQL-Link resource in /home/rweekly/public_html/2012/view_arguments.php on line 43 Code: [Select] mysql_select_db($database_news, $news); $query_news = "SELECT * FROM news WHERE id = '$id'"; $news = mysql_query($query_news, $news) or die(mysql_error()); $row_news = mysql_fetch_assoc($news); $totalRows_news = mysql_num_rows($news); mysql_select_db($database_news, $news); $query_arguments = "SELECT * FROM argue WHERE pid = '$id'"; $arguments = mysql_query($query_arguments, $news) or die(mysql_error()); $row_arguments = mysql_fetch_assoc($arguments); $totalRows_arguments = mysql_num_rows($arguments); Hi, I am trying to create a mobile version of my already uploaded file using below code but getting this error imagecreatefrompng(): is not a valid PNG file Here is the code: if (move_uploaded_file($_FILES['photo']['tmp_name'], $uploadedFile)) { $resource = imagecreatefrompng($uploadedFile); $small_file = imagescale($resource , 500, 400); $small_file = imagepng($small_file); $newSmallFile = "mobile-" . $gallery_uuid . '.png'; $uploadedSmallFile = $uploaddir . $newSmallFile; echo $uploadedSmallFile; if (move_uploaded_file($small_file, $uploadedSmallFile)) { } else { echo json_encode("error"); } } else { echo json_encode("error"); }
Kindly help..
Thanks, Jassim Edited July 29 by requinix removing link |