Jump to content

Search the Community

Showing results for tags 'php'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. I am trying to get all the "posts" from a users friends list on their news feed. I'm trying to do so by getting all those posts where the user is the initiator_user_id and get all the posts from the friend_user_id then I want to get all the posts from initiator_user_id where the user's id is the friend_user_id. This is what I have that's messing up: $wallsql= $conn->prepare('SELECT * FROM activity f INNER JOIN wp_bp_friends n1 ON (n1.initiator_user_id=f.user_id) INNER JOIN wp_bp_friends n2 ON (n2.friend_user_id=f.user_id) WHERE (n1.friend_user_id=:userid) OR (n2.initiator_user_id=:userid) ORDER BY datetime DESC LIMIT 8'); $wallsql->bindParam(':userid', $_SESSION['uid']); $wallsql->execute(); Previously this works but it only gets the posts where the user is the initiator_user_id: $wallsql= $conn->prepare('SELECT * FROM activity f INNER JOIN wp_bp_friends n2 ON n2.friend_user_id=f.user_id WHERE n2.initiator_user_id=:userid ORDER BY datetime DESC LIMIT 8'); Any help would be much appreciated!
  2. Hi all, I was trying to update Tapatalk (from 3.9 to 4.2) on my forum (phpBB 3.0.12) and I get this error when I get to the external installer link (if anyone here's familiar with Tapatalk?) Here is some of the code from that file, starting at line 50 going down to 62. break; case "viewonline.php": $param_arr['location'] = 'online'; break; default: $param_arr['location'] = 'index'; break; } $queryString = http_build_query($param_arr); $url = generate_board_url() . '/?' .$queryString; $url = preg_replace('/^(http|https)/isU', 'tapatalk', $url); return $url; } Any ideas?
  3. Hello all! I'm new to this forum so just wanted to introduce myself.. can't put a picture up yet (wouldn't let me...don't know why).. so sorry bout that. Hope to learn, suggest, brainstorm, etc... Cheers! - darkcloudcoder
  4. Hi folks, you could help me with a PHP question. I changed our pagination from .../?page=0%2C0%2C1 to ?page=1. The problem now is that a few custom codes aren't working anymore. There is one code that puts all following pages as nofollow/noindex. The code worked with the long pagination URL but not with the short. Here's the code: <?php $target_page= explode("/",$_SERVER['REQUEST_URI']); $target_page= $target_page[1]; $pages_with_nofollow = array( 'nyc-apartments-by-school', 'park', ); if(in_array($target_page, $pages_with_nofollow) ===true){ $target_page_num = isset($_GET['page']) ? explode(",",$_GET['page']) : 0; $target_page_num = !empty($target_page_num) ? $target_page_num[2] : 0; if($target_page_num > 0){ $variables['head'] .= '<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">'; } } ?> What do I need to change? Thank you!!!
  5. I am trying to validate my form and then send a message back to the submitter and then send an email to me with the information the submitter inputed. <?php include_once("analyticstracking.php") ?> <?php include_once("analyticstracking1.php") ?> <?php include_once('init.php'); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); }; if(isset($_POST['submit'])) { if (!$_POST['fname'] ) { $mes1='Please enter your First Name';} elseif (!$_POST['lname'] ) { $mes2='Please enter your Last Name';} elseif (!$_POST['street_address'] ) { $mes3='Please enter your Street Address';} elseif (!$_POST['city'] ) { $mes4='Please enter your City';} elseif (!$_POST['state'] ) { $mes5='Please enter your State';} elseif (!$_POST['zip_code'] ) { $mes6='Please enter your Zip Code';} elseif (!$_POST['phone'] ) { $mes7='Please enter your Phone Number';} elseif (!$_POST['department'] ) { $mes9='Please enter your Department';} elseif (!$_POST['email'] ) { $mes10='Please enter your Email Address';} elseif (!$_POST['level']) { $mes12='Please select a Level Of Training';} else { echo " Thank you $_POST[fname] !! Your registration has been submitted!!"; && $sendEmail; } } if(isset($_POST['submit'])) { // validate a phone number if(preg_match("/^[0-9]{3}-[0-9]{3}-[0-9]{4}$/", $_POST['phone'])); // $phone is valid else echo $mes8= 'invalid phone number'; if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { // The email address is not valid echo $mes11= 'invalid email entered';}} $sendEmail= $to = ' webmaster@ottawa-glandorfems.org'; $subject= 'Regisration from $fname'; $fname= $_POST['fname']; $lname= $_POST['lname']; $email= $_POST['email']; $street_address= $_POST['$street_address']; $city= $_POST['city']; $state= $_POST['state']; $zip_code= $_POST['zip_code']; $phone= $_POST['phone']; $department= $_POST['department']; $level= $_POST['level']; $message=<<<EMAIL My name is $fname. $lname, my email is $email. My address is $stree_address . $city . , $state . $zip_code. My phone number is $phone. I work for $department and my level of training is $level. EMAIL; $header = '$email'; mail to($to, $subject, $message, $additional_headers); if (isset($_POST['fname'], $_POST['lname'], $_POST['phone'], $_POST['street_address'], $_POST['city'], $_POST['state'], $_POST['zip_code'], $_POST['department'], $_POST['email'], $_POST['level'])) { $fname = mysqli_real_escape_string ($conn, trim($_POST['fname'])); $lname = mysqli_real_escape_string ($conn, trim($_POST['lname'])); $phone = mysqli_real_escape_string ($conn, trim($_POST['phone'])); $street_address = mysqli_real_escape_string ($conn, trim($_POST['street_address'])); $city = mysqli_real_escape_string ($conn, trim($_POST['city'])); $state = mysqli_real_escape_string ($conn, trim($_POST['state'])); $zip_code = mysqli_real_escape_string ($conn, trim($_POST['zip_code'])); $department = mysqli_real_escape_string ($conn, trim($_POST['department'])); $email = mysqli_real_escape_string ($conn, trim($_POST['email'])); $level = mysqli_real_escape_string ($conn, trim($_POST['level'])); $query ="INSERT INTO oktoberfesttest2014 SET First_Name='{$fname}', Last_Name='{$lname}', Phone='{$phone}', Address='{$street_address}', City='{$city}', State='{$state}', Zip_Code='{$zip_code}', Department='{$department}', Email_Address='{$email}', Level_of_Training='{$level}'"; mysqli_query($conn, $query); //if (!mysqli_query($conn, $query)) { //printf("Errormessage: %s\n", mysqli_error($conn)); //}; } ?> <!DOCTYPE html> <html> <head> <title>Registration form for Octoberfest With O-G EMS 2013</title> </head> <body bgcolor="#084B8A"> <br><div align="center"><img id="Oktoberfest Logo" src="/pics/oktoberfestweb.jpg" border="5" height="200" width="250"><br><br><table style="background-color: beige; border: 1px dashed #999"><tr><td> <center><form action="" method="post"> <p><center>REGISTRATION FORM</center></p> First Name:<input type="text" name="fname" placeholder="First name" size="25" > <p> <b><?php echo "$mes1"; ?></b></p> <p>Last Name:<input type="text" name="lname" size="25" placeholder="Last Name" /> </p><p><b><?php echo "$mes2";?></b> </p> <p>Phone Number:<input type="text" name="phone" placeholder="Phone Number (xxx-xxx-xxxx)" size="30" /></p><p><b><?php echo "$mes7";?><?php echo "$mes8";?></b> </p> <p>Address:<input type="text" name="street_address" size="30" placeholder="Street Address (P.O. Box)" /><p><b><?php echo "$mes3";?></b> </p><input type="text" name="city" size="10" placeholder="City" /><p><b><?php echo "$mes4";?><b> </p><input type="text" placeholder="State" name="state" size="5" /><p><b><?php echo "$mes5";?></b> </p><input type="text" name="zip_code" size="10" placeholder="Zip Code" /><p><b><?php echo "$mes6";?></b> </p> <p>Department:<input type="text" name="department"size="25" placeholder="Department/Agency" /></p><p><b><?php echo "$mes9";?></b> </p> <p>Email Address:<input type="text" name="email" size="40" placeholder="Email Address" /></p></center><p><b><?php echo "$mes10"; ?><?php echo "$mes11";?></b> </p> <fieldset><legend><b>LEVEL OF TRAINING</b></legend> <p><b>(PLEASE NOTE IF YOU HAVE MULTIPLE LEVELS...<br>PLEASE CHOOSE THE ONE YOUR WILL BE ATTENDING FOR)</b></br><p><b><?php echo "$mes12";?></b> </p> <input type="radio" name="level" value="EMR">EMR</br> <input type="radio" name="level" value="EMT-B">EMT-B</br> <input type="radio" name="level" value="EMT-I">EMT-I</br> <input type="radio" name="level" value="EMT-P">EMT-P</br> <input type="radio" name="level" value="Nurse">Nurse</br></p></fieldset> <input type="submit" name="submit" value="Register"><td align="left" valign="bottom"></form><table><tr> <fieldset> <legend><b>If you are not a Putnam County Employee please pay HERE!</b></legend> <form action="https://www.paypal.com/cgi-bin/webscr" target ="_blank" method="post"> <input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="hosted_button_id" value="V9XZ2NSAT5BWA"> <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"> </form></tr> </table> </fieldset> </td> </form></td></tr></table> </body> </html> error given is on line 53...I have given my entire html/php for this page. Here is the error I receive.....Parse error: syntax error, unexpected T_BOOLEAN_AND in /home/a9035067/public_html/oktoberfestr12.php on line 53. Thanks for any help.
  6. Hello guys this is string1301 i am new to php and i don't know much about php but just in recent days i have started to learn php as i am new in php but i am good at static web pages design so some time i need to embade a sign up form in my web pages so usually i do it by downloading some online source file of sign up form in php then i just embade it to my web page. But this cause me a lot of trouble as i am not able to modify it freely. This time i thought to do it by my self so i just studied some codes and attached it to my web page but when i run it in my local host i am not able to get the out put just a blank page and the page is showing white not even any error message is showing so i decided to share my problem in this forum Here's My PHP code <?php require_once 'connect.php'; require_once 'functions.php'; require_once 'myfunc.php'; require_once 'cifunc.php'; $name=$address=$landmark=$pincode=$phone_num=$email=$password=$city=$touchpoint=$error=$success=""; if(isset($_POST['yourname'])) $name=correct_input($_POST['yourname']); if(isset($_POST['address'])) $address=correct_input($_POST['address']); if(isset($_POST['landmark'])) $landmark=correct_input($_POST['landmark']); if(isset($_POST['pincode'])) $pincode=correct_input($_POST['pincode']); if(isset($_POST['phone_num'])) $phone_num=correct_input($_POST['phone_num']); if(isset($_POST['email'])) $email=correct_input($_POST['email']); if(isset($_POST['password'])) $password=correct_input($_POST['password']); $city=$_POST['city']; $touchpoint=$_POST['touchpoint']; $fail = validate_name($name); $fail .= validate_landmark($landmark); $fail .= validate_password($password); $fail .= validate_phone($phone_num); $fail .= validate_email($email); $fail .= validate_address($address); if($fail=="") { if(isset($_POST['accept'])) { $name=strtolower($name); $landmark=strtolower($landmark); $address=strtolower($address); $query="INSERT INTO user_info(name,address,landmark,pincode,city,phone_num,hear,email,password) VALUES('$name','$address','$landmark','$pincode','$city','$phone_num','$touchpoint','$email','$password')"; if(queryMysql($query)) { $success="Successfull Sign up. Please Log in."; } else { $error="Sign up not successfull. Please Try Again."; } } else { $error="Please accept terms and conditions."; } } echo<<<_END <html> <head> <title> Sign Upp </title> </head> <body> <form method="post" action="signupp.php"> <p>$error</p> <p>$success</p> <table> <tr> <td>Your name:</td> <td><input type="text" name="yourname" /></td> </tr> <tr> <td>Address:</td> <td><input type="text" name="address" /></td> </tr> <tr> <td>Landmark:</td> <td><input type="text" name="landmark" /></td> </tr> <tr> <td>Pin Code:</td> <td><input type="text" name="pincode" /></td> </tr> <tr> <td>City:</td> <td><select name="city"> <option value="Bangalore">Bangalore</option> </select> </td> </tr> <tr> <td>Your phone number:</td> <td><input type="text" name="phone_num" /></td> </tr> <tr> <td>How did you hear about us?</td> <td><select name="touchpoint"> <option value="">Select</option> <option value="Friends">Friends</option> <option value="Hoarding">Hoarding</option> <option value="Newspaper">Newspaper Insert</option> <option value="Apartment">Apartment Event</option> <option value="Online">Online Search</option> <option value="Flyer">Flyer</option> </select> </td> </tr> <tr> <td>Email:</td> <td><input type="text" name="email" /></td> </tr> <tr> <td>Password:</td> <td><input type="text" name="password" /></td> </tr> <tr> <td><input type="checkbox" name="accept" /> Accept Terms and Conditions</td> </tr> <tr> <td><button>Submit</button></td> </tr> </table> </form> </body> </html> _END; ?> And i need some tutorial or pdf files or any web site where i can learn this php I want some one to guide me so that i can go in a proper path to learn php Thanks
  7. I am doing a search engine for free for a Autism site. I am having a problem with a php query returning an embedded link from a MySql db. The issue is it returns http://mysitename.com and then concatenates the link I had put in which is http://www.ada.com In the db Text field it is : <a href="http://www.ada.com" target="_blank">The Americans with Disabilities Act </a>was enacted in 1990 to establish the prohibition of discrimination.... Results are the link goes to http://www.mysitename.com/"www.ada.com" (Please notice the quotes as well). I don't know why it's putting in mysitename.com or why it's putting quotation marks around the real link or lastly why it's making my link a sub folder of mysitename.com. Pic of the results: Here is the code: <?php // create short variable names $searchtype=$_POST['searchtype']; $searchterm=trim($_POST['searchterm']); if (!$searchtype || !$searchterm) { echo '<p><strong>You have not entered search details. Please go back and try again.</strong></p>'; exit; } if (!get_magic_quotes_gpc()){ $searchtype = addslashes($searchtype); $searchterm = addslashes($searchterm); } @ $db = new mysqli("*","*","*","*"); if (mysqli_connect_errno()) { echo 'Error: Could not connect to database. Please try again later.'; exit; } $query = "select * from acronymns where ".$searchtype." like '%".$searchterm."%' ORDER BY title "; $result = $db->query($query); $num_results = $result->num_rows; echo "<p>Number of records found: ".$num_results."</p>"; for ($i=0; $i <$num_results; $i++) { $row = $result->fetch_assoc(); echo "<p><strong>".($i+1).". "; echo $row['acro']; echo " - "; echo $row['title']; echo "</strong><br />"; echo $row['desc']; echo "</p>"; } // $result->free(); $db->close(); ?> Thank you ahead of time.... this is really driving me nuts!
  8. Hi everyone, Please bear with me as I try my best to explain the following. I'm working on a shopping script, specifically the search page. Now on this page the user will have several options to refine the products by price, merchant, type, colours etc etc So for example a typical search page will look like domain.com/search/ipad and with additional filters I want it to look like domain.com/search/ipad/price/200-500/ I have managed to do it with one feature however the problem is that are bound to be several types of features a user can use so I need to work on a generic code of some sorts to cover everything. A live website which has something like what I want to do is: http://www.sparsam-kaufer.de/shopping/search/q/laptop/ I've no idea how to tackle this issue as I'm a sort of newbie. Thanks for your advice, Jack
  9. Hello! I have a site with premium memberships, but PHP script is not working well.. I the table accounts I have a column called reset_timer(default value is 0). When someone purchase a new premium membership, PHP add with time(); function into the reset_timer. Premium is 1 month yes and is working well, but the "countdown" script is not working, the script take only the first reset_timer value so for example if the user1 purchase premium membership today, after 5 days, he have 25 days left, but if somebody in another account purchase 1 month of premium, he have 25 days left too, because script only taking the first reset_timer value.. This is the code: function time_reset() { $now = time(); DB::select('accounts'); $timer = DB::fetch_row(); $timer = $timer['reset_timer']; $difference = ($now - $timer); return (2629743 - $difference); } This is my table structure: How I can do it for the script look in every account and reset timer for work correctly? Thank you very much!
  10. Hello, I was studying through the CANVAS LMS and looked at a few demonstrations that were at dev cons. The problem is the canvas LMS is built with Ruby I believe so all the demos to connect to the API were using Ruby. Unfortunately the app that I'm working this into is using PHP, so once I develop the module for this part of the app I nned to figure out what the best way to do this is. Will I be able to use Ruby to do in this app as well? It's using something called Kurogo and most of the other modules that call data use PHP. So I'd prefer to use PHP, but I see no good documentation for getting it (CANVAS LMS API) running with PHP. I'm just trying to study up on this for when I'll be building this new part of the app in the summer most likely (or fall) and want to figure out the best course of action or where I can find decent documentation ofr this. Thanks in advance!
  11. I have the following code: <? Header("content-type: application/x-javascript"); $pathstring=pathinfo($_SERVER['PHP_SELF']); $locationstring="http://" . $_SERVER['HTTP_HOST'].$pathstring['dirname'] . "/"; function returnimages($dirname=".") { $pattern="(\.jpg$)|(\.jpeg$)|(\.gif$)"; $files = array(); $mostRecent=0; $curimage=0; if($handle = opendir($dirname)) { while(false !== ($file = readdir($handle))){ if(eregi($pattern, $file)){ echo 'picsarray[' . $mostRecent .']="' . $file . '";'; $mostRecent++; } } closedir($handle); } return($files); } echo 'var locationstring="' . $locationstring . '";'; echo 'var picsarray=new Array();'; returnimages() ?> I want to sort the images by reverse because This code sort pictures like this: picsarray[0]="2013-11-29 11:42:11 pm.jpg";picsarray[1]="2013-11-29 11:58:24 pm.jpg";picsarray[2]="2013-11-30 12:13:36 am.jpg";picsarray[3]="2013-11-30 12:27:46 am.jpg" I want to sort them by reverse. Anyone can help me to fix this problem?
  12. Sir I Have added some advertise in My Website I Want to track The link Where does my visitor go after living
  13. Am Creating a login Script and i do not want users to put in number or alpha numeric characters in the username field and i use the the ctype_alnum function the problem is that the validation is also affecting the password field below is login script. <div id="login"> <?php if(isset($_POST["login"])&&(empty($_POST["username"])||empty($_POST["password"]))) { echo"<p class='style1' style='background:yellow;' > Please You Have to Provide a Valid Username and password</p>"; $staff=false;}?> <form action="<?php $_SERVER["PHP_SELF"] ?>" method="post"> <label style="font-style:bold;color:#FF9900;" ><h2>UserName:</h2> </label> <?php if(isset($_POST["login"])&&(empty($_POST["username"]))) { echo"Your User Name is Required";$staff=false; } elseif(ctype_alnum($_POST["username"])==true) { echo"You are allowed to put in Numbers<br>"; $staff=false; } ?> <input size="40" type="text" name="username" placeholder="UserName"/><br><br> <label style="font-style:bold;color:#FF9900;" ><h2>Password:</h2> </label> <?php if(isset($_POST["login"])&&(empty($_POST["password"]))) { echo"Your Password is Required";$staff=false; } ?> <input style="radius:6;" size="40" type="password" placeholder="Password" name="password"/><br></div> <input type="submit" width="25px" value="Login" name="login"/> </form> so please help check the code for errors and how to limit the ctype_alnum validation to just the username field.
  14. i do not know how to do the forget password, the doForgetPassword php page. which is once i click the submit buttom then will go to the page that shows the message: the password has already send into your email. my code is not show anything inside the page. doForgetPassword.php forgetPassword.php
  15. I'm near completing my second php course . I've added my final just below. I'm sure you all know what the "array_merge" function does. I've added the array_merge to a new echo, so that I can merge two arrays together. I wanted to combine ($company->name, $company->department) together. <html> <head> <title>PHP</title> <link rel="stylesheet" href="assets/css/bootstrap.css" media="screen"> <link rel="stylesheet" href="assets/css/bootstrap-responsive.css" media="screen"> <link rel="stylesheet" href="assets/css/normalize.css" type="text/css" media="screen"> <link rel="stylesheet" href="assets/css/style.css" media="screen"> </head> <body> <div class="navbar"> <div class="navbar-inner"> <a class="brand" href="#">Week 9</a> <ul class="nav"> <li class="active"><a href="clients.php">Clients</a></li> <li><a href="potential clients.php">Potential Clients</a></li> <li><a href="previousclients.php">Pervious Clients</a></li> </ul> </div> </div><!-- END of navbar--> <div align="center"> <h1>CLients</h1> <? date_default_timezone_set("America/Los_Angeles"); # set default timezone $imageDir = ".../assets/images"; class Clients { const IMAGEDIR = "images/"; public $clients = "Clients"; } /** * */ class Nike extends Clients { public $category = "sporting goods"; public $name = "Nike"; public $department = "Multi Media Devision"; public $yearsWorked = 9; public $jobPerYear = 10; public $fullTimeEmployment = false; public $freelance= true; public $annualBudget= 100000; public $founding= "1999-10-27"; public $visitsBeforeHire= 12000; public $visitsAfterHire= 23000; public $expenses= 100 ; public $income= 500 ; public $activelyWorking= true ; # A Constructor is automatically called when PHP is loaded public function __construct() { # set path for imageDir $this->imagePath = parent::IMAGEDIR . "nike.gif"; } } $nike = new Nike(); class CoffeePress extends Clients { public $category = "coffee"; public $name = "Coffee Press"; public $department = "UI/UX Devision"; public $yearsWorked = 5; public $jobPerYear = 10; public $fullTimeEmployment = false; public $freelance= true; public $annualBudget= 50; public $founding= "11992-05-12"; public $visitsBeforeHire= 12000; public $visitsAfterHire= 23000; public $expenses= 1700 ; public $income= 2500 ; public $activelyWorking= true; # A Constructor is automatically called when PHP is loaded public function __construct() { # set path for imageDir $this->imagePath = parent::IMAGEDIR . "coffeepress.jpg"; } } $coffeePress = new CoffeePress(); class BarrettsFruitProduce extends Clients { public $category = "fruit delivery"; public $name = "Barrett's Fruit Produce"; public $department = "Branding / Marketing"; public $yearsWorked = 1; public $jobPerYear = 1; public $fullTimeEmployment = false; public $freelance= true; public $annualBudget= 10000; public $founding= "2011-08-25"; public $visitsBeforeHire= 12000; public $visitsAfterHire= 23000; public $expenses= 400 ; public $income= 600 ; public $activelyWorking= false; # A Constructor is automatically called when PHP is loaded public function __construct() { # set path for imageDir $this->imagePath = parent::IMAGEDIR . "fruit.jpg"; } } $barrettsFruitProduce = new BarrettsFruitProduce(); class LeisureLife extends Clients { public $category = "apparel"; public $name = "Leisure Life"; public $department = "Branding / Marketing"; public $yearsWorked = 3; public $jobPerYear = 1; public $fullTimeEmployment = true; public $freelance= false; public $annualBudget= 10000; public $founding= "1996-06-06"; public $visitsBeforeHire= 12000; public $visitsAfterHire= 23000; public $expenses= 900 ; public $income= 1500 ; public $activelyWorking= false; # A Constructor is automatically called when PHP is loaded public function __construct() { # set path for imageDir $this->imagePath = parent::IMAGEDIR . "leisurehouse.jpg"; } } $leisureLife = new LeisureLife(); class Nintendo extends Clients { public $category = "gaming"; public $name = "Nintendo"; public $department = "character development"; public $yearsWorked = 1; public $jobPerYear = 8; public $fullTimeEmployment = false; public $freelance= true; public $annualBudget= 10000; public $founding= "1985-01-06"; public $visitsBeforeHire= 800; public $visitsAfterHire= 900; public $expenses = 800 ; public $income = 900 ; public $activelyWorking = true ; # A Constructor is automatically called when PHP is loaded public function __construct() { # set path for imageDir $this->imagePath = parent::IMAGEDIR . "imgres.jpg"; } } $nintendo = new Nintendo(); # Create an array containing all the members classes $companiesNameArray = array($nike, $coffeePress, $barrettsFruitProduce, $leisureLife, $nintendo); // str_replace(search, replace, subject) // echo str_replace($companiesNameArray, $activelyWorking, %client%); $income = array( "Nike" => 500, "CoffeePress" => 2500, "BarrettsFruitProduce" => 600, "LeisureLife" => 1500, "Nintendo" => 900, ); arsort($income); foreach ($income as $key => $val) { echo "$key <i>annual income per year is</i> $$val\n <br /> "; } // # Let's introduce all our full time employment // echo "<h2>Cilents</h2>"; // for ($i=0; $i < count($companies); $i++) { // displayProfile($companies[$companiesName[$i]]); // } // #Let's introduce all of our freelance // echo "<h2>Freelance</h2>"; // for ($i=0; $i < count($companies); $i++) { // displayProfile($companies[$companiesName[$i]]); // } # Display our Jump Menu echo "<form name=\"jump\"> <p align=\"center\"> <select name=\"menu\" onchange='window.location.href=this.options[this.selectedIndex].value'> <option selected>All Members</option> <option value=\"?sort=name\">Sort by Name</option> <option value=\"?sort=nameRev\">Sort by Name (descending)</option> <option value=\"?sort=ageLoToHi\">Sort by Age (youngest to oldest)</option> <option value=\"?sort=ageHiToLo\">Sort by Age (oldest to youngest)</option> <option value=\"?sort=paidLoToHi\">Sort by Paid (highiest paid)</option> <option value=\"?sort=paidHiToLo\">Sort by Paid (lowest paid)</option> </select></p> </form>"; $sort = @$_GET['sort']; # Let's introduce all our members echo "<h2>Clients</h2>"; for ($i=0; $i < count($companiesNameArray); $i++) { switch ( $sort ) { # sort=name -- sorts alphabetically by 'name' in the member array case "name" : sort($companiesNameArray); displayProfile($companies[$companiesNameArray[$i]]); break; case "nameRev" : rsort($companiesNameArray); displayProfile($companies[$companiesNameArray[$i]]); break; # sort=ageLoToHi -- sorts alphabetically by 'age' ascending case "ageLoToHi" : displayProfile($companies[$companiesNameArray[$i]]); break; # sort=ageHiToLo -- sorts alphabetically by 'age' descending case "ageHiToLo" : displayProfile($companies[$companiesNameArray[$i]]); break; # default -- spit out all band members according to their order in the array default : displayProfile($companies[$companiesNameArray[$i]]); break; # sort=paidHiToLo -- sorts lowest paid by 'income' descending case "paidLoToHi" : displayProfile($companies[$companiesNameArray[$i]]); break; # sort=paidHiToLo -- sorts highiest paid by 'income' descending case "paidHiToLo" : displayProfile($companies[$companiesNameArray[$i]]); break; # default -- spit out all band members according to their order in the array default : displayProfile($companiesNameArray[$i]); break; } } # FUNCTIONS - Store all functions down here - I could also store them in another file function displayProfile($company) { echo "<div class='characterProfile'><p>"; # spit out the image echo "<img src=\"".$company->imagePath."\" width=200px /><br />"; # spit out our caption echo "<h3>".$company->name."</h3>"; echo "<i>Company type:</i> ".$company->category."<br />"; echo "<i>Contracting Department:</i> ".$company->department."<br />"; THE FOLLOWING IS SPECIFICALLY WHAT I WANT TO MERGE echo "<pre><i>Company Department:</i> ".array_merge($company->name, $company->department)."<br/>";echo"</pre>"; echo "<i>Jobs per year:</i> ".$company->jobPerYear."<br />"; echo "<i>Company founded:</i> ".displayBusinessAge($company->founding)."<br />"; echo "<i>Age of business: </i> ".calculateAge($company->founding).".<br />"; echo "Number of visits before redesign: ".$company->visitsBeforeHire." per month.<br />"; echo "Number of visits after redesign: ".$company->visitsAfterHire." per month.<br />"; echo "<i>Costs for this project:</i> $".$company->expenses."<br />"; setlocale(LC_MONETARY,"en_US"); echo "<pre><i>Income received: </i> ".money_format( "%i", $company->income."<br />");echo"</pre>"; echo "<i> The Cost-to-Income Ratio for this project was:</i> ".calculateCostToIncome($company->expenses, $company->income)."<br />"; $currentEmployment = str_replace("%client%", "$company->name", "Box Car Studio is not currently working for %client%. <br/>"); if ($company->activelyWorking == true){ $currentEmployment = str_replace(" not ", " ", "$currentEmployment"); } echo $currentEmployment; echo "<i>cost-to-income rato:</i> ".calculateCostToIncome($company->expenses, - $company->income)."<br />"; echo "</p></div>"; } function displayBusinessAge($businessFounding) { # January 1, 1984 $openDateFormatted = date('F j, Y', strtotime($businessFounding)); return $openDateFormatted; } function calculateAge($businessFounding) { #$currentTime = time(); # as a Unix timestamp list($year, $month, $day) = explode("-",$businessFounding); $elapsedYears = date('Y') - $year; $age = $elapsedYears; # calculates number of years elapsed # If current date < opendate (i.e. Oct01 < Dec01), then subtract 1 year if ( date('n') < $month || ( date('n') == $month && date('j') < $day ) ) { $age = $age - 1; } return $age; } function calculateCostToIncome($costs, $income) { $costToIncomeRatio = round($costs / $income, 2); return $costToIncomeRatio; } ?> </div> </body> <script> function fasterFasterAudio() { myAudio.playbackRate = (myAudio.playbackRate + 0.2) % 2.0; } </script> <script type="text/javascript" src="js/bootstrap.js"></script> </html>
  16. So this is my 2nd PHP class ever. And this right here is part of my final. I'm sure you all know what the "shuffle" function does. What I thought I could make it do was randomize a bunch of echoes I have. Is that possible? Any help would be greatly appreciated. KCCO! Here's the code I need tweaked: <html> <head> <title>Characters</title> <link rel="stylesheet" href="assets/css/bootstrap.css" media="screen"> <link rel="stylesheet" href="assets/css/bootstrap-responsive.css" media="screen"> <link rel="stylesheet" href="assets/css/normalize.css" type="text/css" media="screen"> <link rel="stylesheet" href="assets/css/style.css" media="screen"> </head> <body> <div class="navbar"> <div class="navbar-inner"> <a class="brand" href="#"></a> <ul class="nav"> <li class="active"><a href="Characters.php">Previous Clients</a></li> <li><a href="workForSupers.php">Work for Supers</a></li> </ul> </div> </div><!-- END of navbar--> <div align="center"> <h1>Supers we've helped locate</h1> <? date_default_timezone_set("America/Los_Angeles"); # set default timezone $imageDir = "images/"; # Comics is a PARENT class - Emily, Jenny, and so forth all are CHILDREN of Comics, meaning: They inherit the properties and methods included inside Comics. # For example: echo $joker->comiccharacters; will print out the $comiccharacters stored in Comics class Comics { const IMAGEDIR = "images/"; public $comiccharacters = "Comics"; } class Spiderman extends Comics { public $name = "Spiderman"; public $location = "New York City"; public $superpower = "his spider-sense, augmented speed and strength and his web shooters."; public $sex = "male"; public $published = "1963-03-01."; public $hero = true; public $asseskicked = 37; public $personscaught = [12,16,19,29,51]; public $powerlevel= '++++++'; public $email = "SpiderMan4Reals@gmail.com"; # A Constructor is automatically called when PHP is loaded public function __construct() { # set path for imageDir $this->imagePath = parent::IMAGEDIR . "spiderman.jpg"; } } $spiderman = new Spiderman(); class Magneto extends Comics { public $name = "Magneto"; public $location = "New York City."; public $superpower = "power of magnetism."; public $sex = "male"; public $published = "1963-10-15."; public $hero = false; public $asseskicked = 52; public $personscaught = [21,11,21,43,31]; public $powerlevel= '+++++++'; public $email = "ElMagneto@yahoo.com"; # A Constructor is automatically called when PHP is loaded public function __construct() { # set path for imageDir $this->imagePath = parent::IMAGEDIR . "magneto.jpg"; } } $magneto = new Magneto(); class Nightwing extends Comics { public $name = "Nightwing"; public $location = "Gotham City"; public $superpower = "is his peak physical conditioning, gadgets, and detective skills."; public $sex = "male"; public $published = "1985-01-06"; public $hero = true; public $asseskicked = 76; public $personscaught = [32,41,53,48,63]; public $powerlevel= '++++++'; public $email = "NightwingIsAwesome@hotmail.com"; # A Constructor is automatically called when PHP is loaded public function __construct() { # set path for imageDir $this->imagePath = parent::IMAGEDIR . "nightwing.jpg"; } } $nightwing = new Nightwing(); class GreenArrow extends Comics { public $name = "Green Arrow"; public $location = "Starling City"; public $superpower = "is his peak physical conditioning and accuracy with his gadgets."; public $sex = "male"; public $published = "1941-11-19"; public $hero = true; public $asseskicked = 62; public $personscaught = [17,17,29,31,49]; public $powerlevel= '++++++'; public $email = "ImTheGreenArrow@gmail.com"; # A Constructor is automatically called when PHP is loaded public function __construct() { # set path for imageDir $this->imagePath = parent::IMAGEDIR . "greenarrow.jpg"; } } $greenArrow = new GreenArrow(); class TheJoker extends Comics { public $name = "The Joker"; public $location = "Gotham City"; public $superpower = "being completely insane and psychotic."; public $sex = "male"; public $published = "1940-04-11"; public $hero = false; public $asseskicked = 112; public $personscaught = [61,79,103,94,52]; public $powerlevel= "++++++++"; public $email = "KillingForAJoke@gmail.com"; # A Constructor is automatically called when PHP is loaded public function __construct() { # set path for imageDir $this->imagePath = parent::IMAGEDIR . "joker.jpg"; } } $thejoker = new TheJoker(); # Create an array containing all the members classes $members = array($spiderman, $magneto, $nightwing, $greenArrow, $thejoker); # Calculate Ages - this cycles through all of the classes, and calculates the age for each band member, and places it in a property named "$age" foreach($members as $obj) { $obj->age = calculateAge($obj->published); } # Display our Jump Menu echo "<form name=\"jump\"> <p align=\"center\"> <select name=\"menu\" onchange='window.location.href=this.options[this.selectedIndex].value'> <option selected>All Characters</option> <option value=\"?sort=name\">Sort by Name</option> <option value=\"?sort=ageLoToHi\">Sort by Age (youngest to oldest)</option> <option value=\"?sort=ageHiToLo\">Sort by Age (oldest to youngest)</option> </select></p> </form>"; # Access the sort value from the url: blah.com/?sort=blam $sort = ''; if (isset($_GET['sort'])) { $sort = $_GET['sort']; } # Let's introduce all our members echo "<h2>Heroes and Villains Alike</h2>"; for ($i=0; $i < count($members); $i++) { switch ( $sort ) { # sort=name -- sorts alphabetically by 'name' in the member array case "name" : usort($members, 'sortByName_ascend'); displayProfile($members[$i]); break; case "nameRev" : usort($members, 'sortByName_descend'); displayProfile($members[$i]); break; # sort=ageLoToHi -- sorts alphabetically by 'age' ascending case "ageLoToHi" : usort($members, 'sortClassesByAgeLoHi'); displayProfile($members[$i]); break; # sort=ageHiToLo -- sorts alphabetically by 'age' descending case "ageHiToLo" : usort($members, 'sortClassesByAge_HiLo'); displayProfile($members[$i]); break; # sort=ageHiToLo -- sorts alphabetically by 'age' descending case "asseskicked" : uksort($members, 'sortAsseskicked'); displayProfile($members[$i]); break; # default -- spit out all band members according to their order in the array default : displayProfile($members[$i]); break; } } # This is a custom sorting function that works with usort(). # If you provide usort() with either an array or a set of objects, # it goes through all the items and compares them, and puts them in order # according to the rules below. function sortClassesByAgeLoHi($a, $b) { if ( $a->published == $b->published ) { #return 0; # this makes equivalent aged folks disappear return 1; } elseif ( $a->published > $b->published ) { return -1; } else { return 1; } } function sortClassesByAge_HiLo($a, $b) { return sortClassesByAgeLoHi($b, $a); # just reverse the arguments } function sortByName_ascend($a, $b) { if ( $a->name == $b->name ) { #return 0; # this makes equivalent aged folks disappear return 1; } elseif ( $a->name > $b->name ) { return 1; } else { return -1; } } function sortByName_descend($a, $b) { return sortByName_ascend($b, $a); # just reverse the arguments } # FUNCTIONS - Store all functions down here - I could also store them in another file function displayProfile($memberClass) { echo "<div class='memberProfile'><p>"; # spit out the image of our character # <img src="images/spiderman.jpg" /><br /> echo "<img src=\"".$memberClass->imagePath."\" width=200px /><br />"; #should make it so that when you refresh the page, it randomizes the order of the elements in the array shuffle($memberProfile); THE FOLLOWING IS SPECIFICALLY WHAT I WANT TO RANDOMIZE # spit out our caption echo "This is ".$memberClass->name.".<br>"; //counts the "+" for the power level echo "He has a power level of ".strlen($memberClass->powerlevel)." <br> "; echo "He resides in ".$memberClass->location.". <br>"; echo "He was first published in ".displayBirthdate($memberClass->published).".<br>"; echo "Making him ".calculateAge($memberClass->published)." years old! <br>"; //wraps the string after the specified # of characters echo "His superpower is ".wordwrap($memberClass->superpower,35,"<br>\n")."<br>"; echo "And in that time he's kicked the asses of ".$memberClass->asseskicked." people! <br>"; //finds the average & wraps the string after the specified # of characters echo "They normally capture their respective enemy ".average($memberClass->personscaught)." times a year.<br>"; echo "You can reach them at <a href=\"#\"> ".$memberClass->email.".</a>. <br> </p></div> "; } function displayBirthdate($bandmateBirthdate) { # January 1, 1984 $birthDateFormatted = date('F j, Y', strtotime($bandmateBirthdate)); return $birthDateFormatted; } function calculateAge($bandmateBirthdate) { #$currentTime = time(); # as a Unix timestamp list($year, $month, $day) = explode("-",$bandmateBirthdate); $elapsedYears = date('Y') - $year; $age = $elapsedYears; # calculates number of years elapsed # If current date < birthdate (i.e. Oct01 < Dec01), then subtract 1 year if ( date('n') < $month || ( date('n') == $month && date('j') < $day ) ) { $age = $age - 1; } return $age; } //example how to get the average in an array function average($average) { if (!is_array($average)) return false; return array_sum($average)/count($average); } ?> </body> <script type="text/javascript" src="js/bootstrap.js"></script> </html> Characters.php
  17. This is my php code if(mysqli_query($con,"INSERT INTO transactions (ID, Amount, To, From, Description, Type) VALUES ('23', '46', 'hello', 'hello', 'hell1', 'asddsa')")) { return "success"; } echo mysqli_error($con); I get this error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'To, From, Description, Type) VALUES ('23', '46', 'hello', 'hello', 'hell1', 'asd' at line 1 What am i doing wrong?
  18. Hi, I'm after a song search request script to be made for my website below is some info and bullet points of what I would like the script to have. > Search box and the php script will read a .csv file and show matching data > Search results to show up in table column 1 radio button, column 2 Artists, column 3 tracks, > Above results search box below search results a contact form that will email song request and Name (mandatory), email (mandatory) Dedicate (optional) comment (optional) to my own email address > Alphabetical listing (ie clicking A will show all artists beginning with A) Above search box I do have some other ideas - email me and I'll give you my Skype ID so we can talk more
  19. Hi There, I'm very new to PHP and i'm creating the website for my new home business. The HTML and most of the css i've managed to work myself through however, I hate the layout of my products page. It's currently displaying like this Price Option 1 Option 2 I would like it it to display: Price Option 1 Option 2 If you have the time, it would be very much appreciated if you explained how to create the dynamic columns. Im very new to PHP and this is very very confusing. <?php if ($price) { ?> <div class="price"> <span class="text-price"><?php echo $text_price; ?></span> <?php if (!$special) { ?> <span class="price-new"><?php echo $price; ?></span> <?php } else { ?> <span class="price-new"><?php echo $special; ?></span><span class="price-old"><?php echo $price; ?></span> <?php } ?> <?php if ($tax) { ?> <span class="price-tax"><?php echo $text_tax; ?> <?php echo $tax; ?></span> <?php } ?> <?php if ($points) { ?> <span class="reward"><small><?php echo $text_points; ?> <?php echo $points; ?></small></span> <?php } ?> <?php if ($discounts) { ?> <div class="discount"> <?php foreach ($discounts as $discount) { ?> <?php echo sprintf($text_discount, $discount['quantity'], $discount['price']); ?><br /> <?php } ?> </div> <?php } ?> </div> <?php } ?> <?php if ($profiles): ?> <div class="option"> <h2><span class="required">*</span><?php echo $text_payment_profile ?></h2> <br /> <select name="profile_id"> <option value=""><?php echo $text_select; ?></option> <?php foreach ($profiles as $profile): ?> <option value="<?php echo $profile['profile_id'] ?>"><?php echo $profile['name'] ?></option> <?php endforeach; ?> </select> <br /> <br /> <span id="profile-description"></span> <br /> <br /> </div> <?php endif; ?> <?php if ($options) { ?> <div class="options"> <h2><?php echo $text_option; ?></h2> <?php foreach ($options as $option) { ?> <?php if ($option['type'] == 'select') { ?> <div id="option-<?php echo $option['product_option_id']; ?>" class="option"> <label><?php if ($option['required']) { ?> <span class="required">*</span> <?php } ?> <b><?php echo $option['name']; ?>:</b></label> <select name="option[<?php echo $option['product_option_id']; ?>]"> <option value=""><?php echo $text_select; ?></option> <?php foreach ($option['option_value'] as $option_value) { ?> <option value="<?php echo $option_value['product_option_value_id']; ?>"><?php echo $option_value['name']; ?> <?php if ($option_value['price']) { ?> (<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>) <?php } ?> </option> <?php } ?> </select> </div> <?php } ?> <?php if ($option['type'] == 'radio') { ?> <div id="option-<?php echo $option['product_option_id']; ?>" class="option"> <label> <?php if ($option['required']) { ?> <span class="required">*</span> <?php } ?> <b><?php echo $option['name']; ?>:</b></label> <?php foreach ($option['option_value'] as $option_value) { ?> <label class="radio" for="option-value-<?php echo $option_value['product_option_value_id']; ?>"> <input type="radio" name="option[<?php echo $option['product_option_id']; ?>]" value="<?php echo $option_value['product_option_value_id']; ?>" id="option-value-<?php echo $option_value['product_option_value_id']; ?>" /><?php echo $option_value['name']; ?> <?php if ($option_value['price']) { ?> (<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>) <?php } ?> </label> <?php } ?> </div>
  20. Hello everyone, I am trying to create a database login but i am not having any luck. I am not sure what is wrong. I feel everything is in order but I am new and don't really know what to look for. If someone could help me get this up and running, i'd greatly appreciate it. I've spent over 20 hours. I know it isn't exteremely diffuclt but I am fustrated and about to give up . Some help would me great! 1st page: Login.html ( I left out the formatting, heres just the form) file:///C:/Users/Stahlsta/Desktop/PHP/Login.html <form name="form 1" method="post" action="KitchenDatabase.php"> <Center><table width="20%" border="0" cellspacing="0" bgcolor="blue" frame="box" > <tr> <td><h3>Username:</h3></td> <td><input name="username" type="text" id="username" ></td></tr> <tr> <td><h3>Password:</h3></td> <td><input name="password" type="text" id="password" ></td></tr> <tr> <td colspan="2" align="center"> <input type="submit" name="Submit" value="Login"/> <input type="submit" value="Guest Log in"/></td></tr> </table> </Center> </form> When I click login: I want to access KitchenDatabase.php 2nd page:KitchenDatabase.php - This page should link to loginsuccess.php <?php $host="localhost:3306"; // Host name $Owner_fName="username"; // Mysql username $Owner_password="password"; // Mysql password $db_name="2013-wstahl"; // Database name $tbl_name="Owner"; // Table name // Connect to server and select databse. mysql_connect("$host", "$Owner_fName", "$Owner_password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from form $Owner_fName=$_POST['username']; $Owner_password=$_POST['password']; // To protect MySQL injection (more detail about MySQL injection) $Owner_fName = stripslashes($Owner_fName); $Owner_password = stripslashes($Owner_password); $Owner_fName = mysql_real_escape_string($Owner_fName); $Owner_password = mysql_real_escape_string($Owner_password); $sql="SELECT * FROM $tbl_name WHERE username='$Owner_fName' and password='$Owner_password'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $username and $password, table row must be 1 row if($count==1){ // Register $Owner_fName, $Owner_password and redirect to file "loginsuccess.php" session_register("username"); session_register("password"); header("location:loginsuccess.php"); } else { echo "Wrong Username or Password"; } ?> Page 3:loginsuccess.php - This page should link to KitchenDatabase.html <?php session_start(); if(!session_is_registered(username)){ header("KitchenDatabase.html"); } ?> Page 4:I wont bore you witht he code, i dont think it's important for the login work. (file:///C:/Users/Stahlsta/Desktop/PHP/KitchenDatabase.html) Everything is based off this database. KitchenDatabase.sql # # DUMP FILE # # Database is ported from MS Access #------------------------------------------------------------------ # Created using "MS Access to MySQL" form http://www.bullzip.com # Program Version 5.1.242 # # OPTIONS: # sourcefilename=C:\Users\wstahl\Desktop\KBdatabase1.accdb # sourceusername= # sourcepassword= # sourcesystemdatabase= # destinationdatabase=2013-wstahl # storageengine=MyISAM # dropdatabase=0 # createtables=1 # unicode=1 # autocommit=1 # transferdefaultvalues=1 # transferindexes=1 # transferautonumbers=1 # transferrecords=1 # columnlist=0 # tableprefix= # negativeboolean=0 # ignorelargeblobs=0 # memotype=LONGTEXT # CREATE DATABASE IF NOT EXISTS `2013-wstahl`; USE `2013-wstahl`; # # Table structure for table 'Fridge' # DROP TABLE IF EXISTS `Fridge`; CREATE TABLE `Fridge` ( `Fridge_ID` INTEGER NOT NULL, `Owner_ID` INTEGER NOT NULL, `Room_Loc` VARCHAR(255), INDEX (`Owner_ID`), PRIMARY KEY (`Fridge_ID`), FOREIGN KEY (`Owner_ID`) REFERENCES `Owner` ) ENGINE=myisam DEFAULT CHARSET=utf8; SET autocommit=1; # # Dumping data for table 'Fridge' # INSERT INTO `Fridge` VALUES (100, 100, 'Kitchen'); INSERT INTO `Fridge` VALUES (101, 101, 'Wills'); INSERT INTO `Fridge` VALUES (102, 102, 'Taylors'); INSERT INTO `Fridge` VALUES (103, 103, 'Matts'); INSERT INTO `Fridge` VALUES (104, 104, 'Felixs'); INSERT INTO `Fridge` VALUES (105, 105, 'Anthonys'); INSERT INTO `Fridge` VALUES (106, 106, 'Sams'); # 7 records # # Table structure for table 'Guest' # DROP TABLE IF EXISTS `Guest`; CREATE TABLE `Guest` ( `Guest_ID` INTEGER NOT NULL AUTO_INCREMENT, `Guest_fName` VARCHAR(50), `Guest_lName` VARCHAR(50), `Over21` TINYINT(1) DEFAULT 0, `Owner_ID` INTEGER NOT NULL, INDEX (`Over21`), PRIMARY KEY (`Guest_ID`), FOREIGN KEY (`Owner_ID`) REFERENCES `Owner` ) ENGINE=myisam DEFAULT CHARSET=utf8; SET autocommit=1; # # Dumping data for table 'Guest' # INSERT INTO `Guest` VALUES (1, 'Harry', 'Potter', 1, 101); INSERT INTO `Guest` VALUES (2, 'Jamie', 'Kurtis', 1, 102); INSERT INTO `Guest` VALUES (3, 'Bucky', 'Smith', 0, 103); INSERT INTO `Guest` VALUES (4, 'Nick', 'Crawl', 1, 101); INSERT INTO `Guest` VALUES (5, 'Matt', 'Taylor', 0, 104); INSERT INTO `Guest` VALUES (6, 'Martha', 'Stewart', 1,105); INSERT INTO `Guest` VALUES (7, 'Kris', 'Durdon', 0, 105); INSERT INTO `Guest` VALUES (8, 'Mike', 'Micheals', 1, 102); # 8 records # # Table structure for table 'Item' # DROP TABLE IF EXISTS `Item`; CREATE TABLE `Item` ( `Item_ID` INTEGER NOT NULL AUTO_INCREMENT, `Item_Name` VARCHAR(255), `Item_Cost` DECIMAL(19,4), `Exp_Date` DATETIME, `Item_Qty` INTEGER, `Owner_ID` INTEGER, `Fridge_ID` INTEGER, `Store_ID` INTEGER, PRIMARY KEY (`Item_ID`), FOREIGN KEY (`Owner_ID`) REFERENCES `Owner`, FOREIGN KEY (`Fridge_ID`) REFERENCES `Fridge`, FOREIGN KEY (`Store_ID`) REFERENCES `Store`, INDEX (`Fridge_ID`), INDEX (`Owner_ID`), INDEX (`Store_ID`) ) ENGINE=myisam DEFAULT CHARSET=utf8; SET autocommit=1; # # Dumping data for table 'Item' # INSERT INTO `Item` VALUES (1, 'eggs', 2.09, '2013-11-11 00:00:00', 2, 100, 100, 200); INSERT INTO `Item` VALUES (2, 'milk', 3.49, '2013-11-07 00:00:00', 2, 100, 100, 201); INSERT INTO `Item` VALUES (3, 'Bread', 3.09, '2013-11-08 00:00:00', 1, 101, 101, 201); INSERT INTO `Item` VALUES (4, 'cheese', 4.01, '2013-12-30 00:00:00', 2, 101, 100, 200); INSERT INTO `Item` VALUES (5, 'hot dogs', .97, '2014-01-16 00:00:00', 3, 102, 102, 200); INSERT INTO `Item` VALUES (6, 'rolls', 3.09, '2013-11-25 00:00:00', 6, 102, 102, 200); INSERT INTO `Item` VALUES (7, 'noodles', .99, NULL, 4, 103, 103, 202); INSERT INTO `Item` VALUES (8, 'sauce', 4.09, '2013-11-20 00:00:00', 2, 103, 103, 202); INSERT INTO `Item` VALUES (9, 'rice', .98, NULL, 12, 104, 104, 200); INSERT INTO `Item` VALUES (10, 'beans', 1.49, '2013-12-18 00:00:00', 2, 104, 100, 202); INSERT INTO `Item` VALUES (11, 'hamburgers', 6.99, '2013-12-25 00:00:00', 8, 105, 100, 200); INSERT INTO `Item` VALUES (12, 'buns', 3.09, '2013-12-19 00:00:00', 8, 105, 105, 200); INSERT INTO `Item` VALUES (13, 'onions', .99, NULL, 3, 106, 106, 202); INSERT INTO `Item` VALUES (14, 'soup', 1.99, '2014-04-16 00:00:00', 5, 106, 106, 200); INSERT INTO `Item` VALUES (15, 'icream', 3.09, NULL, NULL, NULL, 101, NULL); INSERT INTO `Item` VALUES (16, 'Bacon', 5.15, '2013-10-16 00:00:00', 1, 101, 101, 202); INSERT INTO `Item` VALUES (17, 'Hot sauce', 2.79, '2013-11-22 00:00:00', 3, 101, 101, 200); INSERT INTO `Item` VALUES (18, 'ketchup', 3.5, NULL, 1, 101, 101, 201); INSERT INTO `Item` VALUES (19, 'crunch cereal', 3.49, '2014-01-22 00:00:00', 2, 101, 101, 201); # 19 records # # Table structure for table 'Owner' # DROP TABLE IF EXISTS `Owner`; CREATE TABLE `Owner` ( `Owner_ID` INTEGER NOT NULL, `Owner_fName` VARCHAR(255) NOT NULL, `Owner_lname` VARCHAR(255), `Owner_password` VARCHAR(50), PRIMARY KEY (`Owner_ID`) ) ENGINE=myisam DEFAULT CHARSET=utf8; SET autocommit=1; # # Dumping data for table 'Owner' # INSERT INTO `Owner` VALUES (100, 'All', 'NULL', 'NULL'); INSERT INTO `Owner` VALUES (101, 'Will', 'Stahl', password); INSERT INTO `Owner` VALUES (102, 'Taylor', 'Ryzuk', NULL); INSERT INTO `Owner` VALUES (103, 'Matt', 'Sheehan', NULL); INSERT INTO `Owner` VALUES (104, 'Felix', 'Burgos', NULL); INSERT INTO `Owner` VALUES (105, 'Anthony', 'Lombardi', NULL); INSERT INTO `Owner` VALUES (106, 'Sam', 'Gutzmer', NULL); # 7 records # # Table structure for table 'Store' # DROP TABLE IF EXISTS `Store`; CREATE TABLE `Store` ( `Store_ID` INTEGER NOT NULL, `Store_Name` VARCHAR(255) NOT NULL, `Store_City` VARCHAR(255), PRIMARY KEY (`Store_ID`) ) ENGINE=myisam DEFAULT CHARSET=utf8; SET autocommit=1; # # Dumping data for table 'Store' # INSERT INTO `Store` VALUES (200, 'Walmart', 'Oswego'); INSERT INTO `Store` VALUES (201, 'Bryne', 'Oswego'); INSERT INTO `Store` VALUES (202, 'Kinneys', 'Oswego'); INSERT INTO `Store` VALUES (203, 'Price Chopper', 'Oswego'); # 4 records Am I even close? I've come to far to quit. Please help me get this working Kudos, Fridge.html Fridge.php KitchenDatabase.html KitchenDatabase.php Login.html loginsuccess.php
  21. Hi all Im run across an error that i cant figure out a solution to.. I get this error "Warning: Illegal string offset 'quantity' when I try echo the value for quantity. This is obviously for a online cart.. <div class="cartWrapper"> <?php if(isset($_POST['submit'])){ foreach ($_POST['quantity'] as $key => $value){ if($val==0){ unset($_SESSION['cart'][$key]); }else{ $_SESSION['cart'][$key]['quantity']=$val; } } } ?> <table class="cartTable"> <tr style="text-align:left;"> <th width="20%">Product Name</th> <th width="10%">Quantity</th> <th width="15%">Unit Price</th> <th width="20%">Total</th> </tr> <?php $sql = "SELECT * FROM products WHERE id IN("; foreach ($_SESSION['cart'] as $id => $value){ $sql.=$id.","; } $sql=substr($sql, 0, -1). ") ORDER BY product_name ASC"; $query=mysql_query($sql); $totalprice=0; while($row=mysql_fetch_array($query)){ $subtotal=$_SESSION['cart'][$row['id']]['quantity']*$row['price']; $totalprice+=$subtotal; ?> <tr> <td><?php echo $row['product_name'];?></td> <td><?php echo $row['id']['quantity']?></td> //ERROR IN THIS LINE <td>R<?php echo $row['price'];?></td> <td>R<?php echo $_SESSION['cart'] [$row['id']]['quantity']* $row['price'];?></td> </tr> <?php } ?> <tr> <td>Cart Total : <?php echo $totalprice; ?> </tr> </table> <br/> <button type="submit" name="submit">Update Cart</button> </div> Have I made an error somewhere that I haven't seen. Thanks in advance
  22. Hi I have a small company so I cant hire programmers with full time or part time. And I got this idea to start a team online, so is there any software that will make the team work easier. I found this software : http://codassium.com/ I didn't get time to take a good look into it but I think it is what I need. so if there is any software can make this work more easy I hope you tell me about it.espically if it's a free software.
  23. Hi Guys. Im just trying to find a list of people with birthdays coming up in the next 14 days from a table in my db. I'm storing birthday as a unix timestamp. Currently I have one birthday coming up on the 10/12/1984 or unix time would be 471484800. My query is returning 0 as the number of birthdays when it should say 1. mysql_select_db($database_dbconnect, $dbconnect);$query_Birth = "SELECT StaffDOB FROM Staff WHERE StaffDOB BETWEEN UNIX_TIMESTAMP(CURDATE()) AND UNIX_TIMESTAMP(ADDDATE(CURDATE(), INTERVAL 14 DAY))";$Birth = mysql_query($query_Birth, $dbconnect);$totalRows_Birth = mysql_num_rows($Birth); echo $totalRows_Birth;
  24. Title says it all. Here is the error I get: Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '','1-11-111-11-11-11111','',now())' at line 1 Upload script looks like this: if($_POST['doSubmit'] == 'Add Distributor') { if (!$link) { die('Could not connect: ' . mysql_error()); } $name_dist=mysql_real_escape_string($_POST['name_dist']); $address_dist=mysql_real_escape_string($_POST['address_dist']); $city_dist=mysql_real_escape_string($_POST['city_dist']); $state_dist=mysql_real_escape_string($_POST['state_dist']); $zip_dist=mysql_real_escape_string($_POST['zip_dist']); $phone_dist=mysql_real_escape_string($_POST['phone_dist']); $ffl_dist=mysql_real_escape_string($_POST['ffl_dist']); $dob_dist=mysql_real_escape_string($_POST['dob_dist']); $sql="INSERT INTO `distributors` (name_dist,address_dist,city_dist,state_dist,zip_dist,phone_dist,ffl_dist,dob_dist,dateAdded_dist) VALUES ('$name_dist','$address_dist','$city_dist','$state_dist','$zip_dist',$phone_dist','$ffl_dist','$dob_dist',now())"; if (!mysql_query($sql,$link)) { die('Error: ' . mysql_error()); } echo "<div class=\"msg\">New Distributor Added....done.</div>"; } Form looks like this: <p><?php if(!empty($msg)) { echo $msg[0]; } ?></p> <table width="100%" border="0" cellpadding="5" cellspacing="2" class="myaccount"> <tr> <td style="text-align:right"><form name="addNew" id="addNew" method="post" action="distributors.php">Name of Distributor or Consignor: </td> <td style="text-align:left"><input name="name_dist" type="text" id="name_dist" size="40" class="required"></td> </tr> <tr> <td style="text-align:right">Street: </td> <td style="text-align:left"><input name="address_dist" type="text" size="40" class="required" id="address_dist"></td> </tr> <tr> <td style="text-align:right">City: </td> <td style="text-align:left"><input name="city_dist" type="text" size="40" class="required" id="city_dist"></td> </tr> <tr> <td style="text-align:right">State: </td> <td style="text-align:left"><input name="state_dist" type="text" size="40" class="required" id="state_dist"></td> </tr> <tr> <td style="text-align:right">Zip: </td> <td style="text-align:left"><input name="zip_dist" type="text" size="40" class="required" id="zip_dist"></td> </tr> <tr> <td style="text-align:right">Phone Number: </td> <td style="text-align:left"><input name="phone_dist" type="text" id="phone_dist" size="40" class="required"></td> </tr> <tr> <td style="text-align:right">FFL: </td> <td style="text-align:left"><input name="ffl_dist" type="text" id="ffl_dist" size="40"></td> </tr> <tr> <td style="text-align:right">DOB if no FFL: </td> <td style="text-align:left"><input name="dob_dist" type="text" id="dob_dist" size="40"></td> </tr> <tr> <td colspan="2" style="text-align:center"><input name="doSubmit" type="submit" id="doSubmit" value="Add Distributor"></form></td> </tr> </table> DB table looks like this: `id_dist` int(11) NOT NULL AUTO_INCREMENT, `name_dist` varchar(255) COLLATE latin1_general_ci NOT NULL, `address_dist` text COLLATE latin1_general_ci NOT NULL, `city_dist` varchar(100) COLLATE latin1_general_ci NOT NULL, `state_dist` varchar(2) COLLATE latin1_general_ci NOT NULL, `zip_dist` int(5) NOT NULL, `phone_dist` varchar(255) COLLATE latin1_general_ci NOT NULL, `ffl_dist` varchar(255) COLLATE latin1_general_ci NOT NULL, `dob_dist` varchar(10) COLLATE latin1_general_ci NOT NULL, `dateAdded_dist` date NOT NULL DEFAULT '0000-00-00', PRIMARY KEY (`id_dist`), UNIQUE KEY `name_dist` (`name_dist`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=9 ; Any ideas on why I am getting that error? I have other forms that use this same setup and they work fine so I am not sure what I am missing or have done wrong. Any help would be appreciated. Thanks, Clint
  25. Hello, I'm coding a log in page and I keep getting this problem with mysqli_result. It's a mysqli server. My error is: Fatal error: Cannot use object of type mysqli_result as array in /home/a7017672/public_html/login.html on line 34 My code is: <?PHP if(isset($_SESSION['loggedin'])) { die("You are already logged in!"); } if(isset($_POST['submit'])) { $email = mysqli_real_escape_string($con,$_POST['username']); $pass = mysqli_real_escape_string($con,$_POST['password']); $mysql = mysqli_query($con,"SELECT * FROM users WHERE email_address = '{$email}' AND password = '{$pass}'"); $mysql2 = mysqli_fetch_array($mysql); if (!$mysql ||mysqli_num_rows($mysql) < 1) { die("Incorrect password!"); } $_SESSION['loggedin'] = "YES"; $_SESSION['email'] = $email; $_SESSION['fname'] = $mysql['first_name']; $_SESSION['lname'] = $mysql['last_name']; $_SESSION['add1'] = $mysql['address_1']; $_SESSION['add2'] = $mysql['address_2']; $_SESSION['county'] = $mysql['county']; $_SESSION['postcode'] = $mysql['postcode']; $_SESSION['tel'] = $mysql['tel_no']; $_SESSION['mobile'] = $mysql['mobile_no']; $_SESSION['team'] = $mysql['team']; $_SESSION['ismanager'] = $mysql['is_manager']; $_SESSION['isadmin'] = $mysql['is_admin']; $_SESSION['sysadmin'] = $mysql['is_sysadmin']; die("You are now logged in!"); } echo "<form method='POST'> <p style='font-size: 14pt;'>Username (Email): <br><input type='text' name='username' maxlength='50' size='30'> <br /> <p style='font-size: 14pt;'>Password:<br><input type='text' name='password' maxlength='50' size='30'><br /> <input type='submit' name='submit' value='Login'> </form>"; ?> Any help is greatly appreciated!
×
×
  • Create New...

Important Information

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