PHP - Why Is Nothing Displaying
I'm trying to grab something on a different page with the layout:
Code: [Select] 0 day, 10 hours, 35 min, 59 sec My code to display this information on another page is: <?php $page_contents = file_get_contents("http://www.mysite.com"); $matches = array(); preg_match('/([0-9,]+) day, ([0-9,]+) hours, ([0-9,]+) min, ([0-9,]+) sec /', $page_contents, $matches); echo $matches[0]; ?> Why is it displaying nothing? Similar TutorialsOkay, so I am trying to display players usernames and kills and deaths from my highscores page and I have different div classes set for each block This is my code:
<div id="table"> <div class="tr ttl"> <div class="col st1">Rank</div> <div class="col st2">Username</div> <div class="col st3">Rating</div> <div class="col st4">Deaths</div> <div class="col st5">Kills</div> </div> <?php if($_GET['skill'] == 0) { $skill = $_GET['skill']; $page = ($_GET['page']-1); $limit = RESULTS_PER_PAGE*$page.', '.RESULTS_PER_PAGE; $limitt = RESULTS_PER_PAGE*$page; $query = "SELECT * FROM hs ORDER BY `elo` DESC LIMIT ".$limit.""; $result = mysql_query($query); $counter = 1; while ($fetch = mysql_fetch_assoc($result)) { echo '<div class="tr normal ftr rd1"> <div class="col st1">'.($counter+$limitt).'</div> <div class="col st2"><a href="?user='.$fetch['username'].'">'.$fetch['username'].'</a></div> <div class="col st3">'.number_format($fetch['kills']).'</div> <div class="col st4">'.number_format($fetch['deaths']).'</div> <div class="col st5">'.$fetch['elo'].'</div> </div> '; $counter++; } } ?>See where it says echo '<div class="tr normal ftr rd1"> I'd want it to print out like this: (tr normal ftr rd1) for the first one, (tr normal ftr rd2) for second one and (tr normal ftr rd3) for the 3rd one. Then (tr normal) and (tr odd normal) for the rest Can anyone help me out here? Quick background... I bought an auction program with plenty of bugs. Todays bug that I can't figure out is that it is displaying a - (dash) when I would prefer it to display 0 (zero) in instances of "total fees due" or in the "fee chart" if it's a flat fee of 0. 0% works fine. The code related to it is spread out on a handful of files but I think it's mostly related to the following. if (is_array($setup_fee)) { foreach ($setup_fee as $key => $value) { if ($value['amount']) { if ($value['calc_type'] == 'flat') { $output['amount'] += $value['amount']; $fee_display = $this->display_amount($value['amount'], $this->setts['currency']); } else if ($value['calc_type'] == 'percent') { $output['amount'] += $this->round_number($item_details['start_price'] * $value['amount'] / 100); $fee_display = $value['amount'] . '%'; } if ($item_relist) { $output['amount'] = $this->round_number($output['amount'] - $output['amount'] * $this->fee['relist_fee_reduction'] / 100); } $output['display'] .= '<tr class="c1"> '. ' <td width="150" align="right"><b>' . GMSG_SETUP_FEE . ':</b></td> '. ' <td align="left" nowrap colspan="2"><b>' . $fee_display . $value['display'] . '</b></td> '. '</tr> '; ## now add the row on the invoices table if ($user_payment_mode == 2 && $add_invoices) { $account_balance += $output['amount']; $tax_settings = $this->tax_amount($output['amount'], $this->setts['currency'], $user_details['user_id'], $this->setts['enable_tax']); $sql_insert_invoice = $this->query("INSERT INTO " . DB_PREFIX . "invoices (user_id, item_id, name, amount, invoice_date, current_balance, can_rollback, tax_amount, tax_rate, tax_calculated, reverse_id) VALUES ('" . $user_details['user_id'] . "', '" . $item_details['auction_id'] . "', '" . GMSG_SETUP_FEE . "', '" . $output['amount'] . "', '" . CURRENT_TIME . "', '" . $account_balance . "', " . $can_rollback . ", '" . $tax_settings['amount'] . "', '" . $tax_settings['tax_rate'] . "', '1', '" . $item_details['reverse_id'] . "')"); $sql_update_user_balance = $this->query("UPDATE " . DB_PREFIX . "users SET balance='" . $account_balance . "' WHERE user_id='" . $user_details['user_id'] . "'"); } } } } foreach ($fees_no_tier as $key => $value) { if ($value[1]) { $fee_details = $this->display_fee($key, $user_details, $item_details['category_id'], $item_details['list_in'], $voucher_details, $apply_tax); if ($item_relist) { $fee_details['amount'] = $this->round_number($fee_details['amount'] - $fee_details['amount'] * $this->fee['relist_fee_reduction'] / 100); } $output['amount'] += $fee_details['amount']; if ($fee_details['amount']) ## only do this if there is a fee { $output['display'] .= '<tr class="c1"> '. ' <td width="150" align="right"><b>' . $value[0] . ':</b></td> '. ' <td nowrap colspan="2"><b>' . $fee_details['display'] . '</b></td> '. '</tr> '; ## now add the row on the invoices table if ($user_payment_mode == 2 && $add_invoices) { $account_balance += $fee_details['amount']; $tax_settings = $this->tax_amount($fee_details['amount'], $this->setts['currency'], $user_details['user_id'], $this->setts['enable_tax']); $sql_insert_invoice = $this->query("INSERT INTO " . DB_PREFIX . "invoices (user_id, item_id, name, amount, invoice_date, current_balance, can_rollback, tax_amount, tax_rate, tax_calculated, reverse_id) VALUES ('" . $user_details['user_id'] . "', '" . $item_details['auction_id'] . "', '" . $value[0] . "', '" . $fee_details['amount'] . "', '" . CURRENT_TIME . "', '" . $account_balance . "', " . $can_rollback . ", '" . $tax_settings['amount'] . "', '" . $tax_settings['tax_rate'] . "', '1', '" . $item_details['reverse_id'] . "')"); $sql_update_user_balance = $this->query("UPDATE " . DB_PREFIX . "users SET balance='" . $account_balance . "' WHERE user_id='" . $user_details['user_id'] . "'"); } } } } $output['display'] .= '<tr class="c5"><td colspan="3"></td></tr><tr class="c2"> '. ' <td width="150" align="right"><b>' . GMSG_TOTAL . ':</b></td> '. ' <td nowrap colspan="2"><b>' . $this->display_amount($output['amount'], $this->setts['currency']) . '</b></td> '. '</tr> '. '<tr class="c5"> '. ' <td><img src="themes/' . $this->setts['default_theme'] . '/img/pixel.gif" width="150" height="1"></td> '. ' <td colspan="2"><img src="themes/' . $this->setts['default_theme'] . '/img/pixel.gif" width="1" height="1"></td> '. '</tr> '; return $output; } I'll really really appreciate the help. Hello all! Very frustrated PHP newbie here. I am trying to simply get my code to display errors. I have gone into the php.ini file, changed error_reporting to E_ALL, changed display_errors to On, changed display_startup_errors to On, and even added the line ini_set('display_errors', 'on'); to my code. I restarted the server after every change, and still I see no errors. My boss wants me to reach out to the community for answers rather than handing them to me himself. So here I am. Please advise! Thank you very much in advance. can someone please help me understand why the form isn't displaying on this page? http://auntievics.com/checkOut.php Code: [Select] <?php session_start(); if (isset($_SESSION['cart'])){ foreach ($_SESSION['cart'] as $key => $value){ //echo "Product Number $key Quantity $value<br />"; } } require_once("functions.php"); DatabaseConnection(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>ordering doggy treats</title> <link href="doggyTreats.css" rel="stylesheet" type="text/css" /> <style type="text/css"> #order { margin-right: auto; margin-left: auto; } .orderRow{ padding-bottom: 50px; } h2 { text-align: center; } </style> </head> <body> <?php $errors=array(); if(isset($_POST['submit'])){ validate_input(); if(count($errors) !=0) { display_form(); } else { display_form(); } function validate_input() { global $errors; if($_POST["fname"] == " ") { $errors['fname']="<span style=\"color:red;\"> Please enter your first name </span>"; } } logo(); navBar(); display_form(); extract($_POST); if(!isset($submit)) { echo "<table id=\"order\">"; function display_form() { global $errors; ?> <form action="" method="post" name="checkOut">' <caption><h2>Customer Information </h2> </caption> <tr class = "orderRow"> <td> First Name:<br /> <input name="fname" type="text" size="10" maxlength="20" value="<?php echo $_POST[fname] ?>"> <br /> <br /> <!--<?php echo $errors['fname']; ?> --> </td> <td> Last Name: <br /> <input name="lname" type="text" size="10" maxlength="20" /> </td> <td> Address: <br /> <input name="address " type="text" size="25" /> </td> </tr> <tr class = "orderRow"> <td> City: <br /> <input name="city " type="text" size="15" maxlength="20" /> </td> <td> State: <br /> <select name = "state"> <option selected value ="Please choose a state"/> Please choose a state</option> <option value = "AL" />AL</option> <option value = "AK" />AK</option> <option value = "AR" />AR</option> <option value = "AZ" />AZ <option value = "CA" />CA <option value = "CO" />CO <option value = "CT" />CT <option value = "DE" />DE <option value = "DC" />DC <option value = "FL" />FL <option value = "GA" />GA <option value = "HI" />HI <option value = "IA" />IA <option value = "ID" />ID <option value = "IL" />IL <option value = "IN" />IN <option value = "KS" />KS <option value = "KY" />KY <option value = "LA" />LA <option value = "MA" />MA <option value = "ME" />ME <option value = "MD" />MD <option value = "MI" />MI <option value = "MN" />MN <option value = "MO" />MO <option value = "MS" />MS <option value = "MT" />MT <option value = "NC" />NC <option value = "ND" />ND <option value = "NE" />NE <option value = "NH" />NH <option value = "NJ" />NJ <option value = "NM" />NM <option value = "OH" />OH <option value = "OK" />OK <option value = "OR" />OR <option value = "PA" />PA <option value = "RI" />RI <option value = "SC" />SC <option value = "SD" />SD <option value = "TN" />TN <option value = "TX" />TX <option value = "UT" />UT <option value = "VA" />VA <option value = "VT" />VT <option value = "WA" />WA <option value = "WI" />WI <option value = "WV" />WV <option value = "WY" />WY </select> </td> <td> Zip Code:<br /> <input name="zipcode" type="text" size="5" maxlength="5" /> </td> </tr> <tr class = "orderRow"> <td> Phone <br /> Please include area code <br /> <input name="phone" type="text" size="13" maxlength="13" /> </td> <td> Fax:<br /> <input name="" type="text" size="13" maxlength="13" /> </td> <td> Email: <br /> <input name="email " type="text" size="15" maxlength="30" /> </td> </tr> <tr class = "orderRow"> <td> Please choose method of payment: <br /> Check <input name="check " type="radio" value="Check " /> Money Order <input name="money " type="radio" value="Money order " /><br />PayPal<input name="paypal" type="radio" value="Paypal" /> </td> </tr> <tr> <td colspan = "6"> <h2> Pet Information </h2></td> </tr> <tr> <td> Name: <br /> <input name="petName" type="text" size="10" maxlength="20" /> </td> <td> Age: <br /> <select name="age"> HEREDOC; for ($age =1; $age <=20; $age ++) { print "<option value=\"age\"> $age</option>"; } echo <<<HEREDOC </select> </td> <td> Breed:<br /> <select name = "breed"> <option selected value ="Please choose a breed"/> Please choose a breed <option value = "I don't know" />I don't know <option value = "Affernpincher" />Affernpincher <option value = "Afghan Hound" />Afghan Hound <option value = "Airedale Terrier" /> Airedale Terrior <option value = "Akita" /> Akita <option value = "Alaskan Malamute" /> Alaskan Malamute <option value = "Standard American Eskimo Dog"/> Standard American Eskimo Dog <option value = "Miniature American Eskimo Dog"/>Miniature American Eskimo Dog <option value = "Toy American Eskimo Dog"/> Toy American Eskimo Dog <option value = "American Foxhound" /> American Foxhound <option value = "American Staffordshire Terrier" /> American Staffordshhire Terrier <option value = "American Water Spaniel" /> American Water Spaniel <option value = "Australian Shepherd Dog"/> Anatolian Shepherd Dog <option value = "Australian Cattle Dog"/> Australian Cattle Dog <option value = "Australian Shepherd"/> Australian Shepherd <option value = "Australian Terrier" /> Australia Terrier <option value = "Basenji" /> Basenji <option value = "Basset Hound" /> Basset Hound <option value = "Beagle" /> Beagle <option value = "Bearded Collie" /> Bearded Collie <option value = "Beauceron" /> Beauceron <option value = "Bedington Terrier"/> Bedington Terrier <option value = "Belgin Malinois"/> Belgin Malinois <option value = "Belgian Sheepdog"/> Belgian Sheepdog <option value = "Belgian Tervuren"/> Belgian Tervuren <option value = "Bernese Mountain Dog"/> Bernese Mountain Dog <option value = "Bichon Frise"/> Bichon Frise <option value = "Black and Tan Greyhound" /> Black and Tan Greyhound <option value = "Black Russian Terrier" /> Black Russian Terrier <option value = "Bloodhoung" /> Bloodhound <option value = "Border Collie" /> Border Collie <option value = "Border Terrier"/> Border Terrier <option value = "Borzoi"/> Borzoi <option value = "Boston Terrier"/> Boston Terrier <option value = "Bouvier des Flandres"/> Bouvier des Flandres <option value = "Boxer"/> Boxer <option value = "Briard"/> Briard <option value = "Brittany" /> Brittany <option value = "Brussels Griffon" /> Brussels Griffon <option value = "Bulldog" /> Bulldog <option value = "Bullmastiff" /> Bullmasttiff <option value = "Bull Terrier" /> Bull Terrier <option value = "Cairn Terrier" /> Cairn Terrier <option value = "Canaan Dog" /> Canaan Dog <option value = "Cardigan Welsh Corgi" /> Cardigan Welsh Corgi <option value = "Cavalier King Charles Spaniel" />Cavalier King Charles Spaniel <option value = "Chesepeake Bay Retriever" />Chesapeake Bay Retriever <option value = "Chilauhua" /> Chilauhua <option value = "Chinese Created" /> Chinese Crested <option value = "Chinese Shar-Pei" /> Chinese Shar-Pei <option value = "Chow Chow" /> Chow Chow <option value = "Clumber Spaniel" /> Clumber Spaniel <option value = "Cocker Spaniel" /> Cocker Spaniel <option value = "Collie" /> Collie <option value = "Curly-Coated Retrieve" /> Curly-Coated Retriever <option value = "Dachshound" /> Dachshund <option value = "Dalmation" /> Dalmation <option value = "Dandle Dimonnt" /> Dandie Dinmont Terrier <option value = "Doberman Pincher" /> Doberman Pincher <option value = "Dogue de Bordeaux" /> Dogue de Bordeaux <option value = "English Cocker Spaniel" /> English Cocker Spaniel <option value = "English Foxhound" /> English Foxhound <option value = "English Setter" /> English Setter <option value = "English Springer" /> English Springer <option value = "English Toy Spaniel" /> English Toy Spaniel <option value = "Field Spaniel" /> Field Spaniel <option value = "Finnish Spitz" /> Finnish Spitz <option value = "Flat-Coated Retriever" /> Flat-Coated Retriever <option value = "French Bulldog" /> French Bulldog <option value = "German Shepherd Dog" /> German Shepherd Dog <option value = "German Shorthaired Pointer"/>German Shorthaired Pointer <option value = "German Wirehaired Pointer" /> German Wirehaired Pointer <option value = "Giant Schnauzer" /> Giant Schnauzer <option value = "Glen of Imaal Terrier" /> Glen of Imaal Terrier <option value = "Golden Retriever" /> Golden Retriever <option value = "Gorden Setter" /> Gorden Setter <option value = "Great Dane" /> Great Dane <option value = "Greater Swiss Mountain Dog" /> Greater Swiss Mountain Dog <option value = "Great Pyrenees" /> Great Pyrenees <option value = "Greyhound" /> Greyhound <option value = "Harrier" /> Harrier <option value = "Havanese" /> Havanese <option value = "Ibizen Hound" /> Ibizen Hound <option value = "Irish Setter" /> Irish Setter <option value = "Irish Terrier" /> Irish Terrier <option value = "Irish Water Spaniel" /> Irish Water Spaniel <option value = "Irish Wolfhound" /> Irish Wolfhound <option value = "Italian Greyhound" /> Italian Greyhound <option value = "Jack Russell Terrier" /> Jack Russell Terrier <option value = "Japanese Chin" /> Japanese Chin <option value = "Keeshound" /> Keeshound <option value = "Kerry Blue TErrier" /> Kerry Blue Terrier <option value = "Komondor" /> Komondor <option value = "Kuvasz" /> Kuvasz <option value = "Labradar Retriever" /> Labrador Retriever <option value = "Lakeland Terrier" /> Lakeland Terrier <option value = "Lhasa Apso" /> Lhasa Apso <option value = "Lowchen" /> Lowchen <option value = "Maltese" /> Maltese <option value = "Standard Manchester Terrier" /> Standard Manchester Terrier <option value = "Mastiff" /> Mastiff <option value = "Miniature Bull Terrier" /> Miniature Bull Terrier <option value = "Miniature Pinche" /> Miniature Pinscher <option value = "Miniature Poodle" /> Miniature Poodle <option value = "Miniature Schnauzer" />Miniature Schnauzer <option value = "Mutt" />Mutt <option value = "Neopolitan Mastiff" />Neopolitan Mastiff <option value = "Newfoundland " /> Newfoundland <option value = "Newfolk Terrier" />Norfolk Terrier <option value = "Norwegian Elkhound" /> Norwegian Elkhound <option value = "Norwich Terrier" /> Norwich Terrier <option value = "Nova Scotia Duck Tolling Retriever" /> Nova Scotia Duck Tolling Retriever <option value = "Old English Sheepdog" />Old English Sheepdog <option value = "Otterhound" /> Otterhound <option value = "Papillon" />Papillon <option value = "Parson Russell Terrier" /> Parson Russell Terrier <option value = "Pekingese" />Pekingese <option value = "Pembroke Welsh Corgi" />Pembroke Welsh Corgi <option value = "Petit Basset Griffon Vendeen" />Petit Basset Griffon Vendeen <option value = "Pharch Hound" />Pharoh Hound <option value = "Plott" /> Plott <option value = "Pointer" /> Pointer <option value = "Polish Lowland Sheepdog" />Polish Lowland sheepdog <option value = "Pomeranian" /> Pomeranian <option value = "Portuguese Water Dog" />Portuguese Water Dog <option value = "Pug" />Pug <option value = "Pull" />Puli <option value = "Rhodesian Ridgeback" />Rhodesian Ridgeback <option value = "Rottweiler" />Rottweiler <option value = "ASaint Bernard" /> Saint Bernard <option value = "Saluki" /> Saluki <option value = "Samoyed" />Samoyed <option value = "Schipperke" />Schipperke <option value = "Scottish Doverhound" />Scottish Deerhound <option value = "Scottish Terrier" />Scottish Terrier <option value = "Sealyham Terrier" />Sealyham Terrier <option value = "Shetland Sheepdog" />Shetland Sheepdog <option value = "Shiba Inu" />Shiba Inu <option value = "Shih Tzu" />Shih Tzu <option value = "Siberian Husky" />Siberian Husky <option value = "Silky Terrier" />Silky Terrier <option value = "Skye Terrier" />Skye Terrier <option value = "Smooth Fox Terrier" />Smooth Fox Terrier <option value = "Soft Coated Wheaten Terrier" />Soft Coated wheaten Terrier <option value = "Spinone Italiano" />Spinone Italiano <option value = "Staffordshire Bull Terrier" />Staffordshire Bull Terrier <option value = "Standard Poodle" />Standard Poodle <option value = "Standard Schnauer" /> Standard Schnauzer <option value = "Suseex Spaniel" />Sussex Spaniel <option value = "Swedish Vallhound" />Swedish Vallhund <option value = "Tibertan Mastiff" />Tibetan Mastiff <option value = "Tibertan Spaniel" />Tibetan Spaniel <option value = "Tibetan Terrier" />Tibetan Terrier <option value = "Toy Fox Terrier" />Toy Fox Terrier <option value = "Toy Manchester Terrier" />Toy Manchester Terrier <option value = "Toy Poodle" />Toy Poodle <option value = "Vizela" />Vizela <option value = "Weimaraner" />Weimaraner <option value = "Welsh Springer Spaniel" />Welsh Springer Spaniel <option value = "Welsh Terrier" />Welsh Terrier <option value = "West Highland White Terrier" />West Highland White Terrier <option value = "Whippet" />Whippet <option value = "Wire Fox Terrier" />Wire Fox Terrier <option value = "Wirehaired Pointing Griffon" />Wirehaired Pointing Griffon <option value = "Yorkshire Terrier" />Yorkshire Terrier </td> </select> </tr> <tr> <td>Nutritional Needs:</td> <td><textarea name="nutritionalNeeds" cols="17" rows="5"></textarea> </td> </tr> <tr> <td>Special Instructions</td> <td><textarea name="specialInstructions" cols="17" rows="5"></textarea> </tr> <tr> <td colspan = "6"><h2>Order Information</h2></td> </tr> <tr> HEREDOC; <?php /*foreach($key as $value){ echo $value; }*/ ?> echo <<<HEREDOC </tr> <tr> <td> <input name="Submit" type="submit" value="Order Treats!" /></td><td><input name="reset" type="submit" value="Cancel Order" /> </td> </tr> </table> </form> HEREDOC; <?php } } } footer(); ?> </body> </html> I've got this code that worked on a blank php page but then I copied it to my page and when I preview it nothing is displayed on the page! Can anyone help... Thanks in advance. Code: [Select] <div id="main_content_one"> <?php include 'config.php'; include 'opendb.php'; $var = 'Text'; $query = "SELECT * FROM table WHERE row LIKE \"%$var%\""; $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) { echo "{$row['name']} <br>"; ?> <a href="javascript:;" onclick="document.getElementById('<?php echo $row['id']; ?>').style.display='block'; window.open('http://<?php echo $row['link']; ?>');"><img src="../../graphics/Click here.png" border="0" /></a><br \> <div id="<?php echo $row['id']; ?>" style="display:none;"> <?php echo $row['surname']; ?> </div> <?php echo "{$row['date']} <br>"; } include 'closedb.php'; ?> </div> I put the javascript code of ad into a file named ad.html, then call it in php by $ad = file_get_contents("http://mysite.com/ad.html"); echo $ad; But this does not work for file_get_contents("/ad.html") Is there a way to avoid writing the domain name, and just getting the ad from the file in the root folder? I have conducted a query which should work but its not. Is there any error with this query. Code: [Select] if ( isset( $_GET[ 'rrpmin' ] ) && isset( $_GET[ 'rrpmax' ] ) ) { foreach( $_GET as $k => $v ) { switch( strtolower( $k ) ) { case "ethernet": case "usb": case "parallel": if ( $v == "1" ) $qryParams .= "not isnull(`printers`.`{$k}`) AND length(`printers`.`{$k}`) > 0 AND `printers`.`{$k}` NOT LIKE 'no' AND "; break; case "duplex": if ( $v == "1" ) $qryParams .= "not isnull(`printers`.`duplex`) AND length(`printers`.`duplex`) > 0 AND `printers`.`duplex` NOT LIKE 'no' AND `printers`.`duplex` NOT LIKE '%manual%' AND "; break; case "A3": case "A4": if ( $v == "1" ) $qryParams .= "format LIKE '%{$k}%' AND "; break; case "windows": case "mac": if ( $v == "1" ) $qryParams .= "platform LIKE '%{$k}%' AND "; break; case "format": case "category": $qryParams .= "{$k}='{$v}' AND "; break; case "wireless": if ( $v == "1" ) $qryParams .= "name like '%w' AND "; break; } } The whole thing worked until I added Code: [Select] case "A3": case "A4": if ( $v == "1" ) $qryParams .= "format LIKE '%{$k}%' AND "; break; This case is not working and I was wondering why? Hi, can someone help me understand why it 's only printing the first record in the database ? Code: [Select] <?php require_once("functions.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php DatabaseConnection(); mysql_select_db("auntievics"); $query= "SELECT product_id FROM treats"; $result_set= mysql_query($query); if ($result_set){ $products= mysql_fetch_row($result_set); foreach ($products as $value){ print $value; } print "<br />"; } //print_r(mysql_fetch_row($result_set)); ?> </body> </html> Hello I am using this script right here http://www.nearby.org.uk/sphinx/search-example5-withcomments.phps and am trying to show images from my db but I can only get it to show the first image. Does anyone know how to make it show all images if images even exist for that particular search result? I changed the query to $CONF['mysql_query'] = ' SELECT l.link_id AS id, l.title AS title, l.fulltxt AS body, l.url AS url, m.media_id AS im_id, m.title AS im_title, m.thumb_link AS im_t_link FROM search1_links AS l LEFT JOIN search1_media AS m ON (m.link_id = l.link_id) WHERE l.link_id IN ($ids) '; and added if ($row['im_id']) { echo '<img src="'.($row['im_t_link']).'" height="100px" width="100px"> '; } right here //Actully display the Results print "<ol class=\"results\" start=\"".($currentOffset+1)."\">"; foreach ($ids as $c => $id) { $row = $rows[$id]; $link = htmlentities(str_replace('$id',$row['id'],$CONF['link_format'])); print "<li><a href=\"$link\">".htmlentities($row['title'])."</a><br/>"; if ($CONF['body'] == 'excerpt' && !empty($reply[$c])) print ($reply[$c])."</li>"; else if ($row['im_id']) { echo '<img src="'.($row['im_t_link']).'" height="100px" width="100px"> '; } print htmlentities($row['body'])."</li>"; } print "</ol>"; if ($numberOfPages > 1) { print "<p class='pages'>Page $currentPage of $numberOfPages. "; printf("Result %d..%d of %d. ",($currentOffset)+1,min(($currentOffset)+$CONF['page_size'],$resultCount),$resultCount); print pagesString($currentPage,$numberOfPages)."</p>"; } Can anyone help me to be able to display all images if they exist? Thanks. $_GET["find"] displays all users including the current user. The current user should not be displayed. I would like to display members that are NOT friends with the current user. Do I need to join the tables to make this work? $_GET["add"] inserts "screen_name" into "member and friendwith" Code: [Select] <?php if(isset($_GET["find"])) { $username = $_POST["screen_name"]; $query = "SELECT * FROM users WHERE screen_name LIKE '%$username%'"; $result = mysql_query($query); $exist = mysql_num_rows($result); if($exist=='0') { echo "No match found"; } else { echo "Matches for search: $username<br>"; while($currow = mysql_fetch_array($result)) { ?> <a href="users/member?addfriend=<?php echo $currow['screen_name']; ?>"><img src="avatars/<?php echo $currow["image"]; ?>" ></a> <?php } } } if(isset($_GET["add"])) { $username = $_SESSION["screen_name"]; $friend = $_GET["add"]; $query = "SELECT * FROM friends WHERE member='$username' AND friendwith='$friend'"; $result = mysql_query($query); $exist = mysql_num_rows($result); if($exist=='0') { $query = "INSERT INTO friends(member,friendwith) VALUES('$username','$friend')"; mysql_query($query); echo "$friend is now your friend!"; } else { echo "$friend is already your friend!"; } } ?> i been working on my view Members page for a while now i can't seem to get it to work right this is how i shows up for me and i want it to show up like this i think it has something to do with the loop, but have no idea how to fix this :S <?php require_once('settings.php'); checkLogin('1 2'); $Members = mysql_query("SELECT * FROM users") or die(mysql_error()); $numRowsMembers = mysql_num_rows($Members); ?> <?php for($count = 1; $count <= $numRowsMembers; $count++) { $name = mysql_fetch_array($Members); ?> <table border=2> <tr><td><img src="<? echo $name['main_P']?>" width="50" height="50"/> <a href="view_profile.php?username=<? echo $name['Username']?>"><? echo $name['Username']?></a> <? $onlinestatus = $name['ON_OFF']; if ( $onlinestatus == OFFLINE ) { echo ""; } else { echo "<font color=green>Online Now!</font>"; } ?> </td></tr></table> <? } ?> Hi, I'm very new to php. just wrote my first insert script which works great. Now when my script has run it sends you to the thank you page. It also sends username through a post. Now I'm trying to display Dear <? username ?> But i cant get it working. can anyone help? Here is the code for the join page <?php include('database name'); session_start(); $validation_id = strval(time()); if(isset($_POST['submit'])) { $first_name = mysql_real_escape_string($_POST['first_name']); $last_name = mysql_real_escape_string($_POST['last_name']); $DOB = mysql_real_escape_string($_POST['DOB']); $sex = mysql_real_escape_string($_POST['sex']); $email = mysql_real_escape_string($_POST['email']); $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); $agree = mysql_real_escape_string($_POST['agreed']); $creation_date = mysql_real_escape_string($_POST['creation_date']); $user_type = mysql_real_escape_string($_POST['member_type']); $access_level = mysql_real_escape_string($_POST['access_level']); $validation = mysql_real_escape_string($_POST['validation_id']); $club_user = mysql_real_escape_string($_POST['user_type']); $insert_member= "INSERT INTO Members (`first_name`,`last_name`,`DOB`,`sex`,`email`,`username`,`password`,`agree`,`creation_date`,`usertype`,`access_level`,`validationID`) VALUES ('".$first_name."','".$last_name."','".$DOB."','".$sex."','".$email."','".$username."','".$password."','".$agree."','".$creation_date."','".$user_type."','".$access_level."', '".$validation."')"; $insert_member_now= mysql_query($insert_member) or die(mysql_error()); $url = "thankyou.php?name=".$_POST[$username]; header('Location: '.$url); } Also the form looks like this <form method="POST" name="member_accounts" id="member_accounts"> <input name="username" type="text" class="form_fields" value="<?php echo $_POST['username'];?>" size="20" /> <input name="password" type="password" class="form_fields" value="<?php echo $_POST['password'];?>" size="21" /> now here is the code on the thank you next page. <? include('database name'); session_start(); $_POST['username']= $username; ?> <body> <div id="wrapper"> <h3 class="para_space">Dear <?php echo $_REQUEST[$username]; ?></h3> This is a multiplication test for students to take and when they finish they click the score button. after they click the score button it tells them what their score is, with the opportunity to take it again. What I am trying to do is make this able to keep the recent score and just post the next score. Right now my app just gives the first score and then when I take the test again it just refreshes and gives the new score. I want it to play the new score under the old score. I can't seem to figure out how to do this. If someone could help point me in the right direction. Would appreciate the help. Here is my code for my app.... Code: [Select] <?php require_once('database.php'); define ('ROWS', 3); define ('COLS', 3); define ('MAX_NUMBER', 12); date_default_timezone_set('America/New_York'); if (isset($_POST['btn_score'])) { $result_name= $_POST['result_name']; $correct = 0; //print_r ($_POST); $time1 = $_POST['ts']; $time1_object = new DateTime($time1); $now = new DateTime(); $time_span = $now->diff($time1_object); $minutes = $time_span->format('%i'); $seconds = $time_span->format('%s'); $seconds+= $minutes * 60; echo "It took $seconds seconds to complete the test<hr />"; foreach ($_POST as $problem => $answer) { if ($problem <> "btn_score" && $problem <> "ts" && $problem <> "result_name") { //echo "$problem -- $answer <br />"; $problem = explode('_', $problem); $num1 = $problem[2]; $num2 = $problem[3]; $right = $num1 * $num2; if ($answer != $right) { echo "$num1 * $num2 = $answer , The right answer is $right<br />"; }else { $correct = $correct + 1; } } } $result_score= 0; $result_score= ($correct / 9) * 100; echo "your score is <br/>$result_score<br/>"; } $sql = "INSERT INTO results (result_name, result_score, result_date_time) VALUES ('$result_name','$result_score', NOW());"; ?> <h1>Multiplication Test</h1> <form name="lab5" method="post" action="lab5b.php"> <?php $now = new DateTime(); //echo $now->format('Y-m-d H:i:s'); echo "<input type='hidden' name='ts' value='" . $now->format('Y-m-d H:i:s') . "'>"; ?> <table border="1" cellspacing="5" cellpadding="5"> <?php $no_of_problems = 0; for ($row=0; $row<ROWS; $row++) { echo "<tr>"; for ($col=0; $col<COLS; $col++) { $num1 = mt_rand(1,MAX_NUMBER); $num2 = mt_rand(1,MAX_NUMBER); echo "<td>$num1 * $num2 </td>"; echo "<td><input type='text' size='2' name=${no_of_problems}_mult_${num1}_${num2}></td>"; $no_of_problems++; } echo "</tr>"; } $colspan = 2 * COLS; echo "<tr><td colspan=$colspan align='right'><input type='submit' value='Score' name='btn_score'></td></tr>"; ?> Is it possible to do either one of the following: - Display all current sessions that are set or even request a session from one client and display it to another client. - Or else to detect when someone closes their browser. Thanks in advanced! - GreenFanta I have a textarea displaying data from a mysql table. However, a user discovered today that if they use a carriage return in the textarea, the data comes out with "rn" at the location in the text where the carriage return goes. I have been searching the forums for a while this afternoon and have found quite a few references to this, but have been unable to fix my problem. I am using mysql_real_escape_string before inserting into database (I am not using anything else at insertion time). Is there something else that I should be using at either the insertion into the database or when I display the data? I have tried various combinations of htmlspecialchars() and htmlentities() and nl2br() with no luck. Here is a sample of the output in my textarea: Quote copy diagonal lines and a square with no more than 1/4" overlap or gap at point of closure(modified).rn2.Patient will draw a person ........ Should look like: Quote copy diagonal lines and a square with no more than 1/4" overlap or gap at point of closure(modified). 2.Patient will draw a person ........ Thanks for the help. Matt Could someone please tell me why this displays 3 columns correct and then all moves over. Here is the page you can see what I am talking about http://www.woodrun.org/includes/news.php I have looked the code over and over and can't see it. Thanks in advance. Code: [Select] <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $maxRows_Recordset1 = 1000000; $pageNum_Recordset1 = 0; if (isset($_GET['pageNum_Recordset1'])) { $pageNum_Recordset1 = $_GET['pageNum_Recordset1']; } $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1; mysql_select_db($database_woodrun, $woodrun); $query_Recordset1 = "SELECT * FROM news ORDER BY id DESC" ; $query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1); $Recordset1 = mysql_query($query_limit_Recordset1, $woodrun) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); if (isset($_GET['totalRows_Recordset1'])) { $totalRows_Recordset1 = $_GET['totalRows_Recordset1']; } else { $all_Recordset1 = mysql_query($query_Recordset1); $totalRows_Recordset1 = mysql_num_rows($all_Recordset1); } $totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1; ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_fwragain, $fwragain); $query_Recordset1 = "SELECT * FROM news ORDER BY id DESC"; $Recordset1 = mysql_query($query_Recordset1, $woodrun) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?> <table width="100%" border="0" align="center" cellpadding="5" cellspacing="5"> <?php do { ?> <tr> <td colspan="4" align="left" valign="top"><?php echo "<img src=http://woodrun.org/images/".$row_Recordset1['photo'] ."> "; ?></td> <td width="550" align="left" valign="top"><?php echo $row_Recordset1['title']; ?> <hr /> <?php echo $row_Recordset1['article']; ?><br /></td> </tr> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?> </table> <?php mysql_free_result($Recordset1); ?> i have it set up so the user picks the year and session and then the database shows all the games in that specific year and session and then displays them with a link to their photo galleria and also shows the record(wins - losses - ties) but the way i have it know its not displaying the first result here is the code Code: [Select] <?php //declares $y as year played and $s as session $y = ' '; $s = ' '; //handles submition of form for picking year and session if (isset($_POST['submit'])) { $data = mysql_real_escape_string($_POST['session']); $exploeded = explode(",", $data); $y = $exploeded[0]; $s = $exploeded[1]; } //Query for the selection menu $squery = "SELECT DISTINCT(Year_Played), Sessions FROM pinkpanther_games"; $sresults = mysql_query($squery) or die("squery failed ($squery) - " . mysql_error()); //checks $y and $s to see if their is a vaule if ($y == ' '){$y = '20112012';} if ($s == ' '){$s = '2';} //Query for getting record and for getting all the appropriate info for displaying the games $query = " SELECT (SELECT COUNT(id) FROM pinkpanther_games WHERE Year_Played = $y AND Sessions = $s AND Win_Loss = 'Tie' ) AS 'Tie', (SELECT COUNT(id) FROM pinkpanther_games WHERE Year_Played = $y AND Sessions = $s AND Win_Loss = 'Win') AS 'Win', (SELECT COUNT(id) FROM pinkpanther_games WHERE Year_Played = $y AND Sessions = $s AND Win_Loss = 'Loss') AS 'Lose', Opponent AS Opponent, Score AS Score, Gallery_no AS Gal, Win_Loss AS Record FROM pinkpanther_games WHERE Year_Played = $y AND Sessions = $s"; $results = mysql_query($query) or die("Query failed ($query) - " . mysql_error()); $row_a = mysql_fetch_assoc($results); //Set record variables $wins = $row_a['Win']; $loss = $row_a['Lose']; $tie = $row_a['Tie']; //creates from and selection menu for year and session echo "<tr><td colspan='2'><form method='post' action=''><select name='session' class='txtbox2'>"; while ($srow = mysql_fetch_assoc($sresults)){ echo "<option value='" . $srow['Year_Played'] . "," . $srow['Sessions'] . "'>" . $srow['Year_Played'] . " Session " . $srow['Sessions'] . "</option>"; } echo "</select><input type='submit' name='submit' value='Go' class='txtbox2' /></form></td></tr>"; //displays record echo "<tr><td colspan='2'>" .$wins . " - " . $loss . " - " . $tie . "</td></tr>"; echo "<tr></tr>"; //displays games and scores in appropriate year and session while ($row = mysql_fetch_assoc($results)){ $opp = $row['Opponent']; $score = $row['Score']; $gal = $row['Gal']; $wlt = $row['Record']; //styles games acording to if win lose or tie if ($wlt == 'Win'){ echo "<tr><td class='win'>"; echo "<a href='galleries.php?g=$gal'" . $gal . " >" . $opp . "</a>"; echo "</td><td class='win'>"; echo $score . ""; echo "</td></tr>"; } if ($wlt == 'Loss'){ echo "<tr><td class='loss'>"; echo "<a href='galleries.php?g=$gal'" . $gal . " >" . $opp . "</a>"; echo "</td><td class='loss'>"; echo $score . ""; echo "</td></tr>"; } if ($wlt == 'Tie'){ echo "<tr><td class='tie'>"; echo "<a href='galleries.php?g=$gal'" . $gal . " >" . $opp . "</a>"; echo "</td><td class='tie'>"; echo $score . ""; echo "</td></tr>"; } } ?> <?php include'db.php'; $session= $_SESSION['username']; $query="SELECT * FROM login_ip WHERE login='$session'"; $result= mysql_query($query); $count= mysql_num_rows($result); //$close = die($query); $min= $count - 1; $find= mysql_query("SELECT * FROM login_ip WHERE login= '$session' & times='$min'")or die(mysql_error()); while($row = mysql_fetch_assoc($find)) { $lip=$row['ipaddress']; echo" <br>$min<br>$count"; } ?> i worte the code above to pull the last ip address that a user has login form it is finding the ip adress but it is displaying like this Code: [Select] 72.145.25.457 72.145.25.457 72.145.25.457 72.145.25.457 72.145.25.457 so i remove the $lip form the echo and place $min and $count in there and i am getting Code: [Select] 1 2 1 2 1 2 1 2 Can some one please enplane why i am getting this problem thank you i have a db which store jpg image thru the upload prg code in php.But the image is not displayed properly in the <img> and also when i echo the blob data. how to correct this code.i am pasting the code below $result = mysql_query("select cover from Movies where movie_id=4"); $row = mysql_fetch_row($result); $data = base64_decode($row[0]); $im = imagecreatefromstring($row[0]); imagejpeg($im); header('Content-type: ' . $mime); // 'image/jpeg' for JPEG images echo $data; <img src=<?php echo $data;?>> Hey Guys. I am using php to output to frames. When I add an "\n" tag of even a PHP_EOL the second frame shows blank. The weird thing is when I view the page source I can clearly see the HTML of both frames... Can anyone help me resolve this issue? Thanks!
$iframe = "<iframe src='menu_new.php' width='65%' name='menu' id='menu' title='Menu Frame' ></iframe>\n"; //iframe not working when adding the /n on this line $iframe .= "<iframe src='menu-items.php' width='35%' name='menu-items' id='menu-items' scrolling='yes' noresize='noresize' title='Menu Items Frame'></iframe>\n"; echo $iframe; |