PHP - Php Pdo Execute() .... Somewhat Confused ?
Hi,
Below i have some sample code and am confused over execute(), i have the code below in a try and catch block, in the catch block i call a function i created to log any error that is caught in catch block to a .txt file. I then looked online and it seems that i should do an if statement check on execute to ensure it executed the query, the part that confuses me if the execute failed i thought it would be caught in the catch block but it seems that is not the case. To explain better i have commented the code in depth on the area that i am confused about. Any help in making me understand would be great. I have not included all code above try and catch to keep things simple Code: [Select] <?php try { // connect to database $dbh = sql_con(); // checke if username exists on users table or users banlist table $stmt = $dbh->prepare(" SELECT users.user_login FROM users WHERE users.user_login = ? UNION ALL SELECT users_banlist.user_banlist FROM users_banlist WHERE users_banlist.user_banlist = ?"); // this is the part i am confused with, why is it i would use an if statement on execute() ? // i thought using a try and catch block any errors would be caught in the catch block. // using an if statement to check if execute() worked, i thought if execute failed it would // be handled by the catch block, i mean in my exmaple code here, what could cause the execute to fail ? // and why if execute failed it would not be caught by catch block ? // i am looing at exmaple online and i am reading different things and its all confusing me // execute query if(!$stmt->execute(array($username, $username))){ echo 'something went wrong .. '; } else { // execute worked } } // if any errors found log them in my ExceptionErrorHandler() function and display friendly message catch (PDOException $e) { // this function catches an error and logs them to file ExceptionErrorHandler($e); require_once($footer_inc); exit; } } ?> Thanks or any help! Similar TutorialsHi, i'm about to start making my admin page for my site and i'm confused on if i wanted to select a user to change the password or ban them e.t.c how would i select the user?
so like if i had a list of all the users on my web page i.e
John
Paul
Lisa
how would i select one of them so i could make changes?
Hi all im trying to create a simple user registration page using php and mysql i created the database and tables locally and tested it and it works great so I did the same for on my sever and in the my mysqli connection script I changed the database name/passwords etc to match the hosting. when i tested the script I get: Notice: Constant DB_USER already defined in /home/lkennet1/public_html/xxx.co.uk/mysqli_connect.php on line 3 Notice: Constant DB_PASSWORD already defined in /home/lkennet1/public_html/xxx.co.uk/mysqli_connect.php on line 5 Notice: Constant DB_HOST already defined in /home/lkennet1/public_html/xxx.co.uk/mysqli_connect.php on line 7 Notice: Constant DB_NAME already defined in /home/lkennet1/public_html/xxx.co.uk/mysqli_connect.php on line 9 Easy to fix right. dont definine it twice. but im not defining it anywhere but my registration page and the only call i make to it is whne i use Code: [Select] require_once("mysqli_connect.php"); next mind boggling error is this: Table 'example_wrdp2.users' doesn't exist ok so to fix this I create the database right. well I have and it still dont work and I dont know why its choosing example_wrdp2 on my server i have 5 databases: example_wrdp1 example_wrdp2 example_wrdp3 example_wrdp4 example_myNewDatabase I don't understand why its not using example_myNewDatabase which i am specifying in my db connect script. Im totally lost and stuck with this. So just seen this http://www.ultramegatech.com/2009/07/using-mysql-prepared-statements-in-php/ from another topic, and am a bit confused now, I started coding a little while back, but did not get introduced to mysqli until very recently, should I change all my normal mysql queries to the mysqli prepared statements like in the website/tutorial stated? does this mean I won't have to use mysql_real_escape_string and it is more secure in general? Would really like some input, much appreciated. Hi I'm trying to do a php website using notepad++ but when I save it and I test it out on a web browser it gives me my coding instead of a form. How do I fix this. Thank you I have a MYSQL Query and when I see the code, I think it would do what I want it to do, also so do my other friends, but it doesn't. What I'm trying to do is basically make a top 10 poster, and select and order the list by the person with the most posts in the table. The table has a field named user, which represents the username. So basically I'm trying to order it by the `user` with the most posts. The problem is that it only displays the first row in the table, which is id:1. Code: [Select] SELECT * FROM `mrsw_adventurer_log` ORDER BY COUNT(`user`) I can't seem to figure it out. I want the following script to run attack_code.php when all the statements come back as being ok.. only issue is on the last line i do }else{ include("attack_code.php"); yet it runs the attack_code anyway, its rather odd as if i leave attack_code.php at the top of the page it shows the error messages of the statements below any clues? Code: [Select] <?php if($playerID == $defender) { echo "<div>You can't attack yourself.</div>"; include("exit.php"); exit; } /// below shows the noto forumla $cashnoto = round($steal_amount / 100); $drugnoto = round($steal_amount * 15); ?><br /> <?php $sql = "SELECT * FROM messages WHERE to_username = '$defender_info[username]' AND from_username = '$playerdata[username]' AND type = 'Combat' ORDER BY id DESC LIMIT 1"; $que = mysql_query($sql) or die(mysql_error()); $res = mysql_fetch_array($que); $now = time(); $lastattack = strtotime($res['timestamp']); $timesince = $now - $lastattack; $nextatk = round((10800 - $timesince) / 60); if($timesince < 10800){ echo "You can only attack the same player once every 3 hours.<br><br> You can attack this player again in $nextatk minutes."; include("exit.php"); exit; }else{ $sql = "SELECT hits FROM users WHERE id = $playerID"; $que = mysql_query($sql) or die(mysql_error()); $res = mysql_fetch_array($que); $hits = $res['hits']; if($hits < 1){ echo "You have no available hits. New hit allowances are granted every ten minutes on the :05's"; include("exit.php"); exit; }else{ ?> I am getting this error Quote Parse error: syntax error, unexpected '}', expecting ',' or ';' in /home/a6658518/public_html/view/register.php on line 83 Code: [Select] <html> <body> <pre> <?php $Fname = $_POST["Fname"]; $Lname = $_POST["Lname"]; $mail = $_POST["mail"]; if (!isset($_POST['submit'])) { ?> <form method="post" action="<?php echo $PHP_SELF;?>"> First Name:<input type="text" size="12" maxlength="12" name="Fname"><br /> Last Name:<input type="text" size="12" maxlength="36" name="Lname"><br /> Email:<input type="text" size="12" maxlength="36" name="mail"><br /> This must be a valid email! <input type="submit" value="submit" name="submit"> </form> <? } else { if (isset($_COOKIE["dsc"])) { echo "Whoops! You already got a serial number!" } else { $myFile = $Fname; $myFile .= ".vl"; $myFile = $loca .= myFile$; if (file_exists($myFile)) { echo "We seem to have another serial key with that name already made! Please email emery.cairns@gmail.com if you think this is an error"; } else { $fh = fopen($myFile, 'w') or die("Whoops! I had an error, please contact my owner at emery.cairns@gmail.com, code: file unwriteable"); $stringData = getSerial(); fwrite($fh, $stringData); fclose($fh); echo "Hello, ".$Fname." ".$Lname.".<br />"; echo "Thanks for registering with us, the email with your serial key and name will show up in your inbox shortly!.<br />"; echo "Please make sure it does not end up in your junk mail!"; $expire=time()+60*60*24*60; setcookie("dsc", "Serial given within 60 days", $expire); $to = $mail; $serial = getSerial(); $subject = "Dhpos Self Checkout"; $message = "Hello!, your serial number for D.S.C is {$serial} and your name is {$Fname} Thanks for downloading DSC, we hope you enjoy the program. You recived this message because you requested a serial number from http://dhposselfcheckout.tk, if you did not, please disregard this message."; $from = "emery.cairns@gmail.com"; $headers = "From:" . $from; if ( $to == "emery.cairns@gmail.com" ) { echo "mail stop"; } else { mail($to,$subject,$message,$headers); } } } } ?> <br /> </pre> </body> </html> Code: [Select] //mod_KaLiTe_Subforums BEGIN $forum_data['subforums'] .= "<a href=?z={$data[id]}>"; $forum_data['subforums'] .= $data['name']; $forum_data['subforums'] .= "</a>"; //mod_KaLiTe_Subforums END This shows all my subforums on my forum, but 1 problem, if I try to seperate them, like let's say with a "comma" by using: Code: [Select] //mod_KaLiTe_Subforums BEGIN $forum_data['subforums'] .= "<a href=?z={$data[id]}>, "; $forum_data['subforums'] .= $data['name']; $forum_data['subforums'] .= "</a>"; //mod_KaLiTe_Subforums END It will show the , BEFORE the link? so weird, here is the function: Code: [Select] $forum_data['subforums'] = "<br> <span class=desc4>Subforums:</span> "; foreach($this->children[ $forum_data['id'] ] as $idx => $data) { //-------------------------------------- // Check permissions... //-------------------------------------- if ( $std->check_perms($data['read_perms']) != TRUE ) { continue; } // Do the news stuff first if (isset($data['last_title']) and $data['last_id'] != "") { if ( ( $ibforums->vars['index_news_link'] == 1 ) and (! empty($ibforums->vars['news_forum_id']) ) and ($ibforums->vars['news_forum_id'] == $data['id']) ) { $this->news_topic_id = $data['last_id']; $this->news_forum_id = $data['id']; $this->news_title = $data['last_title']; } } if ($data['last_post'] > $newest['last_post']) { //Subforum last_title? $newest['last_post'] = $data['last_post']; $newest['fid'] = $data['id']; //$newest['id'] = $data['id']; $newest['last_id'] = $data['last_id']; $newest['last_title'] = $data['last_title']; $newest['password'] = $data['password']; $newest['last_poster_id'] = $data['last_poster_id']; $newest['last_poster_name'] = $data['last_poster_name']; $newest['status'] = $data['status']; $newest['star'] = $data['star']; } $newest['posts'] += $data['posts']; $newest['topics'] += $data['topics']; $printed_children++; //mod_KaLiTe_Subforums BEGIN $forum_data['subforums'] .= "<a href=?z={$data[id]}>, "; $forum_data['subforums'] .= $data['name']; $forum_data['subforums'] .= "</a>"; //mod_KaLiTe_Subforums END } How can I make it so it doesn't show the , before the FIRST link on that subforums variable, but only after every link and beyond? Okay I got it working by moving it ontop Code: [Select] $forum_data['subforums'] .= "<a href=?z={$data[id]}>{$data['name']}</a>, "; //mod_KaLiTe_Subforums END $printed_children++; but now it shows the , after the last link, how do I make it so it doesn't show the comma for the last child? everytime i run my code i get ( ! ) Warning: mysqli_query() expects parameter 2 to be string, object given in C:\wamp\www\Tutorial\test.php on line 5. i just cant seem to find the error
my code looks like this
why does this code display this webpage? brandysstudioofdance.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(); extract($_POST); if(!isset($submit)) { echo "<table id=\"order\">"; function display_form() { global $errors; ?> <form action="php_self" 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> Hi there, I have been following this tutorial: http://www.freewebmasterhelp.com/tutorials/phpmysql/6 I have everything working, but I am a little confused when it comes to the "Links for Single Records" part. The following code snippet is what I am using to display the data that is in the database on the page after it is inserted, inside of a table. It is working fine, but the "edit" link just brings up a blank page, that has my edit code on it. Code: [Select] <table border="1" bordercolor="#000000" cellspacing="2" cellpadding="10"> <tr> <th bgcolor="#01337f"><font face="Arial, Helvetica, sans-serif" size="2">Name</font></th> <th bgcolor="#01337f"><font face="Arial, Helvetica, sans-serif" size="2">E-Mail</font></th> <th bgcolor="#01337f"><font face="Arial, Helvetica, sans-serif" size="2">Age</font></th> <th bgcolor="#01337f"><font face="Arial, Helvetica, sans-serif" size="2">Gender</font></th> <th bgcolor="#01337f"><font face="Arial, Helvetica, sans-serif" size="2">Location</font></th> <th bgcolor="#01337f"><font face="Arial, Helvetica, sans-serif" size="2">Home Phone</font></th> <th bgcolor="#01337f"><font face="Arial, Helvetica, sans-serif" size="2">Other Phone</font></th> <th bgcolor="#01337f"><font face="Arial, Helvetica, sans-serif" size="2">Best Time to Reach</font></th> <th bgcolor="#01337f"><font face="Arial, Helvetica, sans-serif" size="2">Referrer</font></th> <th bgcolor="#01337f"><font face="Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">Options</font></th> </tr> <? $i=0; while ($i < $num) { $name=mysql_result($result,$i,"name"); $email=mysql_result($result,$i,"email"); $age=mysql_result($result,$i,"age"); $gender=mysql_result($result,$i,"gender"); $location=mysql_result($result,$i,"location"); $homephone=mysql_result($result,$i,"homephone"); $otherphone=mysql_result($result,$i,"otherphone"); $besttime=mysql_result($result,$i,"besttime"); $referrer=mysql_result($result,$i,"referrer"); ?> <tr> <td><font class="lead_txt"><? echo $name; ?></font></td> <td><font face="Arial, Helvetica, sans-serif" size="2" class="lead_txt"><? echo $email; ?></font></td> <td align="center"><font face="Arial, Helvetica, sans-serif" size="2" class="lead_txt"><? echo $age; ?></font></td> <td align="center"><font face="Arial, Helvetica, sans-serif" size="2" class="lead_txt"><? echo $gender; ?></font></td> <td align="center"><font face="Arial, Helvetica, sans-serif" size="2" class="lead_txt"><? echo $location; ?></font></td> <td align="center"><font face="Arial, Helvetica, sans-serif" size="2" class="lead_txt"><? echo $homephone; ?></font></td> <td align="center"><font face="Arial, Helvetica, sans-serif" size="2" class="lead_txt"><? echo $otherphone; ?></font></td> <td align="center"><font face="Arial, Helvetica, sans-serif" size="2" class="lead_txt"><? echo $besttime; ?></font></td> <td align="center"><font face="Arial, Helvetica, sans-serif" size="2" class="lead_txt"><? echo $referrer; ?></font></td> <td bgcolor="#01337f""><a href="db_edit.php?id=$id"><img src="edit.png" width="25" height="25" alt="Edit"></a> <a href=""><img src="delete.png" width="25" height="25" alt="Delete"></a> <a href=""><img src="email.png" width="25" height="25" alt="E-Mail"></a></td> </tr> Any ideas? Thanks in advance!! How can I get this form to execute? Do I need to use a hidden input or something? Code: [Select] <form action="partnerRequest.php" method="post"> <a href="" title="Become Associates" id="becomeassoc" class="mll"> <span class="f_right">Become Associates</span><img src="../assets/img/becomeassoc.jpg" class="mrs vmiddle" alt="Become Associates" /> </a> </form> Hi Guys, I have the following script which works fine for GoogleMaps Code: [Select] <?php require'EasyGoogleMap.class.php'; $gm = & new EasyGoogleMap("rYvyXhRFPYW5tkV_IE5hWxecUidHAYjJhBSp59xzQuNZcoxNYCiaum4_Xb66Fw"); $gm->SetMarkerIconStyle('STAR'); $gm->SetMapZoom(10); $gm->SetAddress("10 market st, san francisco"); $gm->SetInfoWindowText("This is the address # 1."); $gm->SetAddress("Manila, Philippines"); $gm->SetInfoWindowText("This is Philippine Country."); $gm->SetSideClick('Philippines'); ?> <html> <head> <title>EasyGoogleMap</title> <?php echo $gm->GmapsKey(); ?> </head> <body> <?php echo $gm->MapHolder(); ?> <?php echo $gm->InitJs(); ?> <?php echo $gm->GetSideClick(); ?> <?php echo $gm->UnloadMap(); ?> </body> </html> I've now coded that static page to take the following, and within the GoogleMaps database field entered in exactly the following $gm->SetAddress("10 market st, san francisco"); $gm->SetInfoWindowText("This is the address # 1."); $gm->SetAddress("Manila, Philippines"); $gm->SetInfoWindowText("This is Philippine Country."); $gm->SetSideClick('Philippines'); Code: [Select] <?php $maps_find = $OO_Open->newFindCommand('Maps'); $maps_find->AddFindCriterion('AccountName','xx'); $maps_result = $maps_find->execute(); $maps_row = current($maps_result->getRecords()); $Gdata = $maps_row->getField('GoogleMaps'); //echo $Gdata; //exit; ?> <?php require'EasyGoogleMap.class.php'; $gm = & new EasyGoogleMap("my key"); $gm->SetMarkerIconStyle('GT_FLAT'); $gm->SetMapZoom(10); $gm->SetMapWidth(1080); # default = 300 $gm->SetMapHeight(550); # default = 300 echo $maps_row->getField('GoogleMaps'); //eval("\$Gdata = \"$Gdata\";"); ?> <html> <head> <title>EasyGoogleMap</title> <?php echo $gm->GmapsKey(); ?> </head> <body> <?php echo $gm->MapHolder(); ?> <?php echo $gm->InitJs(); ?> <?php echo $gm->GetSideClick(); ?> <?php echo $gm->UnloadMap(); ?> </body> </html> Is there way of getting the $maps_row->getField('GoogleMaps'); command to behave as if it was php (when I echo it, it does display the code as text). I'm not using the FileMaker db to store the code, I thought eval function was the answer but not had much luck. Many Thanks for the advice Jalz I need to execute a program in the command prompt in windows using php, which php functions would be best to do this? and would i need to set any type of permissions to be able to use them? I have written a Validation class that checks to see if a file being uploaded to the server meets certain conditions. That works a treat. The next step is to actually upload it to the server and I have an Upload class that can do that. Again, that works perfectly fine. Once the file uploads, I am passing the $location of that of that file to my DB class. The DB class is full of methods that prepare and then execute strings that are SQL queries that are required in other areas of my application. Nothing I have at the moment is suitable for just running an SQL file so I don't know what to do now.. My procedural code, that works, looks like this; $dbh2 = new PDO("mysql:host=localhost;dbname=DB360transfer", $login_user, $login_password); $sql = file_get_contents($path.$new_file_name); $qr = $dbh2->exec($sql);I'm not sure how to replicate this up in a PDO/OOP application. My DB Class script is attached. The run_from_file code starts on line 98. I've left in the other stuff as I suspect the answer has something to do with using the $this or the self:: - but really I have no idea. So my question is, what is the correct syntax for executing a file in OOP? Attached Files DB.php 2.92KB 6 downloads Hi,
I have a cron job that executes this script every 2 minutes:
<?php // LOAD WP-LOAD.PHP require('/opt/bitnami/apps/wordpress/htdocs/wp-load.php'); // INCLUDE AND EXECUTE SCHEDULER.PHP include('/opt/bitnami/apps/wordpress/htdocs/wp-content/themes/yeelloe/scheduler.php'); ?>When I try to include; /opt/bitnami/apps/wordpress/htdocs/wp-content/themes/yeelloe/scheduler.php: <?php // EXPLODE AND PARSE WP-CONTENT; FUNCTIONS.PHP $parse_uri = explode( '/opt/bitnami/apps/wordpress/htdocs/wp-content', $_SERVER['SCRIPT_FILENAME'] ); // LOAD WP-LOAD.PHP require_once( $parse_uri[0] . '/opt/bitnami/apps/wordpress/htdocs/wp-load.php' ); // LOAD TEMPLATE FUNCTION CheckFunction(); ?> Hi, I am trying to create a PHP script ("repair-correct.php") in order to run some CLI commands without using PuTTy - The CLI commands are needed to repair/correct the execution of a web application named Mautic. Shared web host account with PHP 7.0 URL: https://www.myserver.com Mautic directory: https://www.myserver.com/mautic
What I want to do is:
Step1: Change ownership of files and folders To find out which user Apache is running as, I want to execute the following command and take note of the first entry in the line which is returned: ps aux | grep apache2 I want to use this information to find the groups with the following command groups apache_user (where apache_user is the user I identified from the first step above) To reset the ownership of files and folders, I want to use the following command (ensuring that I replace apache_user and apache_group with the values identified in the steps above): sudo chown -R apache_user:apache_group With this command I want to change ownership, using the -R flag which means recursively - including all files/folders within that location.
Step 2: Reset the file and folder permissions
find . -type f -not -perm 644 -exec chmod 644 {} +
Thanks so much for your help in solving this problem!
Best, Tony
Not sure if this is possible I am trying to do a multi delete: Code: [Select] <form name="form1" method="post" action=""> <table> while($rows=mysql_fetch_array($result)){ ?> <tr> <td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"></td> <td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['name']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['lastname']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['email']; ?></td> </tr> <?php } ?> // Check if delete button active, start this if($delete){ for($i=0;$i<$count;$i++){ $del_id = $checkbox[$i]; $sql = "DELETE FROM $tbl_name WHERE id='$del_id'"; $result = mysql_query($sql); } <tr><td> <select name="dropdown"> <option value="option1">Choose an action...</option> <option value="edit">Edit</option> <option value="delete">Delete</option> </select> <a class="button" href="#">Apply to selected</a> if($result){ echo "<meta http-equiv=\"refresh\" content=\"0;URL=nameslist.php\">"; } } mysql_close(); hi, I am having problems setting a session from a SQL query, please help... here is my code: Code: [Select] $query1 = "SELECT * FROM members_copy WHERE rsUser = '$username' AND rsPass = '$password'"; $result1 = mysql_query($query1); echo "<br>".$result1['USERID']; $_SESSION['s_logged_n'] = 'true'; $_SESSION['s_username'] = $username; $_SESSION['USERID']=$result1['USERID']; $_SESSION['RSTOWN']=$result1['RSTOWN']; $_SESSION['RSEMAIL']=$result1['RSEMAIL']; $_SESSION['RSUSER']=$result1['RSUSER']; no sessions are currently being set?! Hello, I've been assigned the task of creating an internal site for our office that has links to all the websites we use as well as the applications we use. I'm very comfortable using php with mysql for handling forms and displaying database information but I'm not sure how to go about this. So my question is, is there anyway I can use php to open an exe file? |