Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'php'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Single Editions
    • Modern Javascript: Develop and Design
    • The Yii Book
    • Effortless Flex 4 Development
    • Building a Web Site with Ajax: Visual QuickProject
    • Ruby: Visual QuickStart Guide
    • C++ Programming: Visual QuickStart Guide
    • C Programming: Visual QuickStart Guide
    • Adobe AIR: Visual QuickPro Guide
  • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (5th Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
    • PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide (3rd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (2nd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (1st Edition)
  • PHP for the Web: Visual QuickStart Guide
    • PHP for the Web: Visual QuickStart Guide (5th Edition)
    • PHP for the Web: Visual QuickStart Guide (4th Edition)
    • PHP for the Web: Visual QuickStart Guide (3rd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (2nd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (1st Edition)
  • Effortless E-commerce with PHP and MySQL
    • Effortless E-Commerce with PHP and MySQL (2nd Edition)
    • Effortless E-Commerce with PHP and MySQL
  • PHP Advanced: Visual QuickPro Guide
    • PHP Advanced and Object-Oriented Programming: Visual QuickPro Guide (3rd Edition)
    • PHP 5 Advanced: Visual QuickPro Guide (2nd Edition)
    • PHP Advanced: Visual QuickPro Guide
  • MySQL: Visual QuickStart Guide
    • MySQL: Visual QuickStart Guide (2nd Edition)
    • MySQL: Visual QuickStart Guide (1st Edition)
  • Other
    • Announcements
    • Newsletter, Blog, and Other Topics
    • Forum Issues
    • Social

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


  1. Hi, I get a strange problem when I try to insert images data into media table. I decided to break down the problems section by sections. I rewrite the query using basic mysqli_query() function and insert one row at a time for testing purpose. Here is the strange thing, when I pass the value as variable into the VALUES, the insertion will fail and return an error: 'insertion failedUnknown column 'edvard' in 'field list''. However, If I just pass the string into VALUES(), the insertion goes without problem. I haven't run into this sort of problem before, can anyone explain the reason please. Thanks again! Failed Code: $file_title = 'edvard-much-the-scream'; $file_mime = '.jpg'; $product_type = 'product'; $file_url = 'edvard-much-the-scream.jpg'; $fipi = 1; $query = "INSERT INTO media (file_title) VALUES ($file_title)"; // this fails mysqli_query($dbc, $query); if(mysqli_affected_rows($dbc)==1){ $iid = mysqli_insert_id($dbc); echo $iid; } else { echo 'insertion failed' . mysqli_error($dbc); } Success Code: $file_title = 'edvard-much-the-scream'; $file_mime = '.jpg'; $product_type = 'product'; $file_url = 'edvard-much-the-scream.jpg'; $fipi = 1; $query = "INSERT INTO media (file_url) VALUES ('edvard-much-the-scream')"; // this works mysqli_query($dbc, $query); if(mysqli_affected_rows($dbc)==1){ $iid = mysqli_insert_id($dbc); echo $iid; } else { echo 'insertion failed' . mysqli_error($dbc); }
  2. Hello there, It's my first time asking question here, so I want to introduce myself a little bit. I was a graphic designer and 3D artist and I have never done any website except using iWeb. The company I work for needs to rebuild its website which has roughly four thousand products in the database. The website was built by hosting company using a open source CMS called OScommerce. My given project was to create a independent website using php and mysql that can be easily modified to suit the need when time is changing. When I receive the project around beginning of this year, I knew nothing about php and mysql so I went to amazon to buy 2 books. One was "PHP Solutions Dynamic Web Design Made Easy" and other one "Modern Javascript". I studied through both books. The PHP Solution is a good book, but not for absolute beginner. The way it organizes its content, mixing basic and advance concerts and methods together into one book keeps new learner confused and frustrated. So I wasn't really fully understand the material I have learned. As comparison, Modern Javascript is much clear to me and easy to learn. After finished Modern Javascript, I found Mr. Larry also wrote other php books, so I decided to pick up PHP and MySQL for Dynamic from Amazon. As I studied through (followed all examples), I found this book really helped me clear up the concert that I wasn't really clear of. So ends up, I purchased all php book from Larry and finished all of them. Now back to the question, I run into problem to insert timestamp into prepare statement, after some goolge search, there is answer in stackoverflowhttp://stackoverflow.com/questions/14096220/datetimes-now-function-does-not-work-with-pdo-mysql-prepared-statements I change my script according to it, but it returns an error: mysqli_stmt_bind_param(): Number of elements in type definition string doesn't match number of bind variables. I have no idea now, can anyone show me the right way to this please. Thanks. CODE: // query for products table $query = 'INSERT INTO products (product_sku, product_name, product_size, product_color, product_packaging, product_desc, created_on, new_arrival, feature, publish) VALUES (?,?,?,?,?,?,NOW(),?,?,?)'; $stmt = mysqli_prepare($dbc, $query); mysqli_stmt_bind_param($stmt,'ssssissiii', $sku,$name,$size,$color, $packaging,$desc, $new_arrival,$feature,$publish ); mysqli_stmt_execute($stmt);
  3. I just wanted to say a huge thanks to Larry for writing the book "PHP and MySQL for Dynamic Web Sites" (I have the 4th edition). To give a little history - I started using PHP about 10 years ago when I was asked to create a portal for some members of a small department that wanted to share information relating to health care. I initially looked at creating a static HTML site but soon came across PHPNuke. I know this particular CMS has had better days but for me 10 years ago it was revolutionary. I managed to set up a website and installed PHPNuke (including the database on MySQL). I was hooked from that point. However, I have become lazy over the years and although I have always wanted to create my own dynamic site, I have always stuck to using CMS/Portals (such as WordPress, Drupal, Joomla etc.) and never moved on. Now, don't get me wrong - these PHP based scripts are excellent and I will continue to use them but I have always just amended code within an already written script and never actually created a site of my own (from scratch) - although I would consider myself an intermediate PHP programmer (I use C# and .Net at work). Even after reading numerous books on the subject I still felt as though I was missing the glue that held everything together. I understood everything about XHTML, CSS, PHP, MYSQL, SESSIONS, COOKIES etc but could never join all the dots to make something work - so I was stuck in a sort of "head knowledge" state. That is changing now - thanks to the book above. This book is excellent and I am finally joining the dots and have a new found excitement for the language again. Thanks Larry - I don't know what makes your book so different and usable - but it is - and it's working. I have already purchased the Advanced book on the subject for the next stage of my journey. I look forward to updating you all on my progress. Thanks again :-)
  4. Hello, I am fairly new at php and mysql but finding the book very useful. I am having trouble with trying to register an account I fill out the registration form but when I click submit all I get is "Please enter your username" I am not getting any error appearing so I can not find out what the problem is. Here is my code I hope it is easy enough to read. I am also using a test server on 000webhost ("http://testwebserver.comli.com/register.php") I also have a localhost. <?php # register.php require('includes/config.inc.php'); $page_title = 'Register'; if ($_SERVER['REQUEST_METHOD'] == 'POST') { require (MYSQL); $trimmed = array_map('trim', $_POST); $un = $e = $p = FALSE; if (preg_match ('/^[A-z \' .-]{4,20} $/i', $trimmed['user_name'])) { $un = mysqli_real_escape_string ($dbc, $$trimmed['user_name']); } else { echo '<p class="error">Please enter your username! </p>'; } if (filter_var($trimmed['email'], FILTER_VALIDATE_EMAIL)) { $e = mysqli_real_escape_string ($dbc, $trimmed['email']); } else { echo '<p class="error>Please enter a valid email address! </p>'; } if (preg_match ('/^\w{4-20} $/', $trimmed['password1'])) { if ($trimmed['password1'] == $trimmed['password2']) { $p = mysqli_real_escape_string ($dbc, $trimmed ['password1']); } else { echo '<p class="error">Your password did not match the confirmed password!</p>'; } } else { '<p class="error">Please enter a vaild password!</p>'; } if ($un && $e && $p) { $q = "SELECT user_id From users WHERE user_name='$un', email='$e'"; $r = mysqli_query ($dbc,$q) or trigger_error("Query: $q\n<br />MYSQL Error:" . mysqli_error($dbc)); if (mysqli_num_rows($r) ==0) { $a = md5(uniqid(rand() , true)); $q = "INSERT INTO users (user_name, email, pass, active, reg_date) VALUES ('$e', '$un', SHA1('$p'), '$a', NOW())"; $r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MYSQL Error:". mysqli_error($dbc)); if (mysqli_affected_rows($dbc) == 1) { $body = "Thank you for reistering at PowerPlay. To activate your account, please click on this link:\n\n"; $body .= BASE_URL . 'activate.php?x='.urencode($e) . "&y=$a"; mail($trimmed['email'], 'Registration Confirmation', $body, 'From alexp2510@hotmail.com'); echo '<h3>Thank you for registering! A confirmation email has been sent to your email address. Please click on the link in order to activate your account.</h3>'; exit(); } else { // if it did not run OK. echo '<p class="error">You could not be registered due to a system error. we apologize for any inconvenience.</p>'; } } else { echo '<p class="error">That email address or username is already in use. If you have forgotten your password use the link at the right to have your password sent to you.</p>'; } } else { echo '<p class="error">Please try again.</p>'; } mysqli_close($dbc); } ?> <h1>Register</h1> <form action="register.php" method="POST"> <fieldset> <p><b>Username:</b> <input type="text" name="user_name" size="20" maxlength="20" value="<?php if (isset($trimmed['user_name'])) echo $_POST['user_name'];?>" /> </p> <p><b>Email Address:</b> <input type="text" name="email" size="30" maxlength="60" value="<?php if (isset($trimmed['email'])) echo $trimmed ['email']; ?>" /> </p> <p><b>Password:</b> <input type="password" name="password1" size="20" maxlength="20" value="<?php if (isset($trimmed['password1'])) echo $trimmed ['password1']; ?>" /> <small> Use only letters, numbers, and the underscore. <p>Must be between 4 and 20 characters long.</p></small></p> <p><b>Confirm Password:</b> <input type="password" name="password2" size="20" maxlength="20" value="<?php if (isset($trimmed['password2'])) echo $trimmed['password2']; ?>" /> </p> </fieldset> <div align="center"> <input type="submit" name="submit" value="Register" /></div> </form> Any help would be great. Thanks Alex
  5. My brain must be dead, because while I read the book, I am having trouble devising a solution to this problem. I would like to include a button on a page of query results that allows users to filter the results to those that match only certain criteria. I realize that it's not a good idea to run a whole new query just for this filtering, so I have been trying to look for a solution, but to no avail. Any tips? I'm sorry for being vague, I'd just rather not give away too much about the site's structure. Thank you!
  6. The most basic of questions .... how do I access the phpmyadmin dashboard (fig 4.8, p 120? I was initially able to get this dashboard using /localhost/phpmyadmin. I then set a root password in App. A in order to use MySQL Client. After that I wasn't able to get the phpmyadmin dashboard, getting the error shown in fig 4.9 on p121 instead, which referred me to App A to create a user. I did this. Created a user in Appendix A, and validated it, getting the blank screen shown in fig. A-15 on p. 599. But when I type in the URL of localhost/ phpmyadmin, I'm still getting fig 4.9. What am I missing?
  7. I have been working on a website where users from all around the world would post their suggestions, upload photos and create events for hangouts and so on. Its just like a social network. I need to how to store the Data and time of all the users in the correct format so that it would be the best choice for the future of the website. For example if a user in US creates an event then a person in india seeing it must be seeing it correctly in his time format. If he chooses to fly to US and login's in US then the time for the user in that specific timezone must match. The thing is any where the user may be, any time or date related activity in the website must store the time which can be common to all. I am aware of the two things, UTC and GMT where both are similary but with the DST. I dono which one to use wether to use GMT or UTC. Should i calculate time by adding or subtracting the offset, or coverting the timezone stored to the timezone of the user. I also need to know how to get the timezone or the offset of the user for a specific region. Thanks.
  8. how can i add login and registration to the forum example in chptr 15? Why doesnt it tell u exactly how to do to implement the login functionality?
  9. In this example why does the procedural way fail with this error: Error: Warning: mysql_fetch_assoc() expects parameter 1 to be resource, object given in /Users/joel/Sites/people_test/public_html/index.php on line 14 PHP: $dbc = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die ('Could not connect to MySQL: ' . mysqli_connect_error() ); $q = "SELECT first_name, last_name FROM person LIMIT 0,30"; $r = mysqli_query($dbc, $q); Procedural: while($data = mysql_fetch_assoc($r)) { $rows[] = $data; } //prints out null echo json_encode($rows); OOP: while($data = $r->fetch_assoc()) { $rows[] = $data; } echo json_encode($rows); I thought I was doing the procedural way right from reading the PHP.net fetch_assoc() procedural and oop examples. Obviously I'm missing something. Could use some help seeing what it is.
  10. Edit: Nevermind do not worry about this thread. Apparently my action attribute for my login form should have been "index.php?p=login". When I give correct login info, it works correctly so I just need to fix the conditional for when the login info is incorrect. Okay so I tried setting up a modular website with the standard header + left sidebar, content, and right sidebar + footer. I also want to include the ability to register / login and put up a "Home | Login" or "Home | Settings" links up at the to of the header depending on whether someone is logged in or not. Now, for some reason when someone logs in successfully and the $_SESSION array is supposed to take in the data from the users table and then head to index.php, it seems that the $_SESSION array is not being set at all... it is empty. I am trying to figure out exactly what is going wrong here. Here is part of my login page: if(mysqli_num_rows($user_check_result) == 1) { //start of valid single match $_SESSION = mysqli_fetch_array($user_check_result, MYSQLI_ASSOC); //update most recent log in $last_logged_query = "UPDATE users SET last_logged_in = NOW() WHERE user_id = {$_SESSION['user_id']} LIMIT 1"; $last_logged_result = dbc_query ($dbc, $last_logged_query); if(mysqli_affected_rows($dbc) != 1) { //if one row was not affected $notes['last_logged_in_failure'] = "There was an error recording the login."; }//end of one row not being affected mysqli_free_result($user_check_result); if(isset($last_logged_result)) mysqli_free_result($last_logged_result); mysqli_close($dbc); $exit_url = BASE_URL . '/index.php'; header("Location: $exit_url"); exit(); } Also, since the else clause after this if clause is not being executed, and the page is being redirected to index.php I assume that the $_SESSION variable is being set. For some reason the redirect seems to be losing the $_SESSION array when it goes over to index.php. I even had to separate the login.php script into a login.inc.calc.php script to be executed befor ethe header.php file and a login.inc.out.php to be executed after the header.php file since a redirect has to occur before HTML output. A rar file of everything (except images) from my site (only 11kb because I just started it) is located here: http://ipredict.danconia.us/ipredict.danconia.us.rar This whole modular thing is making things a bit confusing and I'm wondering whether it's really worth it... if it might not be worth it to go back to the non-modular way of doing things. On the other hand I don't want to back down from a good challenge. Any help would be appreciated. Thank you! Edit: Also, for the record the first real line in index.php is a require('./includes/config.inc.php'); and that config file's first line is start_session(); so I just don't get why that wouldn't be occurring: /* * index.php (homepage) for http://iPredict.danconia.us * Script created by Kylan Hurt * http://kylan.danconia.us */ require('./includes/config.inc.php'); $errors = array(); $notes = array();
  11. Hello! I have been reading over the great guide for Stripe integration. Great stuff. Thank you for doing those posts. What I want to do though, is use the custom button CHECKOUT method, which is shown here: https://stripe.com/docs/checkout#api along with the "saving customer details for later", method. Which is shown here: https://stripe.com/docs/tutorials/charges#saving-credit-card-details-for-later Can these two things be combined with your methods at all? I am having no luck at all with this.
  12. Hello, I have been trying to get my form to validate the radio button which allows my user to agree to the terms and conditions, however, it either prints at the top of the page or not at all. The other prompts print near the form input which is what I would like to happen for the radio button. Following is my code. if (isset($_POST['radio_Agree'])) { $Agree = mysqli_real_escape_string($connect, $_POST['Agree']); } else { $reg_errors['radio'] = 'Please agree to the user Terms and Conditions.'; } <p><label> <input type="radio" name="Agree" value="Agree" /></label> <a name="Agree" id="Agree"></a>I agree to the user Terms and Conditions.<br /> <?php create_form_input('radio', 'Agree', $reg_errors); ?></p>
  13. Hi Larry, Great fan of you books! I've recently gone over Chapter 11 and I had a question regarding passing data from JSON to PHP using the code provided in the book for test.js (434-436). I've modified the script to use JSON and that works beautifully. I'd like to know if there is a clean JS solution to pass data to PHP without relying on jQuery.ajax({ data })? I've looked everywhere for a solution but the solution seems easily resolved with jQuery, but I'd like to avoid that if possible. Here is the code I've used as dictated in the book: window.onload = function() { 'use strict'; var ajax = getXMLHttpRequestObject(); ajax.onreadystatechange = function() { if ( ajax.readyState == 4 ) { if ( (ajax.status >= 200 && ajax.status < 300) || (ajax.status == 304) ) { var data = JSON.parse(ajax.responseText); var file = ''; file += 'Original: ' + data['org'].file + '<br>'; file += 'Processed: ' + data['pre'].file + '<br>'; document.getElementById('output').innerHTML = file; } else { document.getElementById('output').innerHTML = 'Error: ' + ajax.statusText; } } }; document.getElementById('btn').onclick = function() { ajax.open('POST', 'resources/test.json', true); ajax.setRequestHeader('Content-Type', 'application/json'); ajax.send(null); }; }; I would like to be able to echo out the data['org'].file and data['pre'].file in PHP after the request is made. Any guidance or suggesting would be appreciated.
  14. Per instructions and examples in the book, I am using javascript to initiate use of mysql within a php file to populate the data in a grid within my original javascript file. Everything works fine! However, sometimes, it takes a few seconds for the php file to complete running. I am finding that I need to disable the grid until the php file has completed. I know how to disable the grid using jquery $.blockUI(); and re-enable the grid using $.unblockUI(); using javascript commands in my javascript file. But I cannot figure out how to delay the $.unblockUI(); until the php file has completed. How can I do that? Thank you.
  15. Hello there! The thread referenced (at the bottom) covers how to display two forms on a single page. However . . . In the case referenced, both forms are visible on the page by default, and it is only *after* a submit has been detected that the script detects the form sent, and calls the appropriate code. It seems possible to display only one of the forms based on a user's site visit status. For example, assume a page contains code for both 'Form A' and 'Form B'. What I'm looking for is: 1) When the user visits the page for the first time, 'Form A' is displayed by default, then; 2) On any subsequent visit to the page by the same user, during the same session, 'Form B' is displayed by default. Of course, the submit still gets handled by the processing script, but that's already been covered in the thread referenced. What's got me snookered is how to determe the visitors status (i.e., new or return visit) so that the appropriate form can be displayed. ~ David Reference: http://www.larryullman.com/forums/index.php?/topic/1362-two-forms-on-one-page/
  16. version 0.5 Page 129 As I read this book, I keep scratching my head, wondering what's so good about OOP (Object Oriented Programming). The clips example is a case in point. Why write 5 lines of code when you can write just 2, like this? $stockQuote = 'AAPL: $533.25'; echo $stockQuote; I can modularize my procedural code by using includes. So how can all the fuss and bother of OOP be worthwhile? I've read plenty of rationales defending OOP, written by people who studied it in college, but it seems more like a religion to me. Sorry, I don't mean to offend anyone. I've read some books on OOP php, and I'm patiently reading through this one, only because I want to take advantage of the code that's automatically generated and tailored to whatever tables I need. But frankly, I will probably write most custom code, queries etc, as procedural php.
  17. I have gone into the database and explored what might happen after PayPal has been activated and is live. So I have manually changed some of the expiry dates of my users. This is my code when the registrant originally joins: $q = "INSERT INTO users (username, email, pass, first_name, mid_initial, last_name, agree, date_expires) VALUES ('" . stripslashes($u) . "', '$e', '" . get_password_hash($p) . "', '" . stripslashes($fn) . "', '" . stripslashes($mi) . "', '" . stripslashes($ln) . "', '$agree', SUBDATE(NOW(), INTERVAL 1 DAY) )"; Thus their expiry date is one day less than when they joined. The whole time I have been testing my site I have left these dates and my registrants have always been allowed into the site as long as their passwords and email are correct, even though the login form is asking for a date that is greater than or equal to NOW so that doesn't make sense to me. I am assuming NOW means right this minute. $q = "SELECT id, username, type, IF(date_expires >= NOW(), true, false) FROM users WHERE (email='$e' AND pass='" . get_password_hash($p) . "')"; SO I went in and changed some of the years from the current year to a year in the future. THESE registrants are not being allowed into the site. These registrants are getting the following error message when they try to login. $login_errors['login'] = 'The email address and password do not match those on file. '; This doesn't make any sense to me and I am wondering if this alone would keep the registrant from entering the site once paypal is integrated. I have found that one can only do so much testing when the site is "live" with PayPal because if you try to use a credit card too many times, PayPal blocks you. So I want to try to figure out as many bugs as I can beforehand. Marie
  18. After my web hosting company (1and1.com) switched from PHP 4 to 5, a script that once returned the current year A-OK no longer works; it now generates this error message that is e-mailed to me every time a page bearing this include is accessed: An error occurred in script '----------/includes/footer.php' on line 4: <br />date_default_timezone_get() [<a href='function.date-default-timezone-get'>function.date-default-timezone-get</a>]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EST/-5.0/no DST' instead <br />Date/Time: 1-30-2013 07:51:12 <br /><pre>Array .... Here is the code, including some changes I thought should correct the error or at least suppress the error messages: <?php if(function_exists("date_default_timezone_set") and function_exists("date_default_timezone_get")) @date_default_timezone_set(@date_default_timezone_get()); // date_default_timezone_set('America/New_York'); $startyear = 2009; $currentyear = date("Y"); if ($startyear == $currentyear) { echo 'Copyright © 2009'; } else { echo 'Copyright © 2009 - ' . $currentyear; } ?> How can I fix this error?
  19. hi guys ! i have question about output buffering(chapter 18 page 561) i have searched google about it and it came with alot of debates, some say its good practice, some say its bad practice to use it, but they dont provide any code for testing why its good and why its bad.. so the question is : is it a good practice to always use it ? as Larry's statement in the book that says "There can be a performance improvement with output buffering, but the main benefit is that it eradicates those pesky headers already sent error messages." if its bad practice, please give good reasons + codes(if neccessary) to prove why its bad
  20. I have modified form_functions.inc.php to radio button for suit for me. But It seems its not working.. This is my code so far.. from form function if (preg_match('/sex\d{1}$/', $name)) { $i = substr($name, -1); $name = substr($name, 0, 3); $sex = array(1=>'Male', 'Female' ); // Display the error first: if (array_key_exists($name, $errors)) { echo ' <span class="inline-error">' . $errors[$name] . "</span>\n"; } echo '<input type="' . $type . '" name="' . $name . '" value="' . $i . '" /> ' . $sex[$i] . ' '; } This is from validation code.. // Check for gender: $sex = array(); for ($i=1, $count=2; $i <= $count; $i++) { if (isset($_POST['sex'. $i])) { $sex[] = $_POST['sex'. $i]; } } // end for loop if (empty($sex)){ $reg_errors['sex1'] = 'You have NOT entered your gender type!'; } This from HTML <div class="last-child"> <?php for ($i=1, $count=2; $i <= $count; $i++) { create_form_input('sex' . $i, 'radio', $reg_errors); } ?> </div> radio button working.. but validation not working its always going to error message.. hope someone help me out this.. thank you.
  21. Hello... I have a form to get some urls from users. Eg: Web Address, Facebook Address, Twitter Address, Google+ address etc... My problem is how I validate these urls when they submit the form. I tried to validate URL in PHP by using the FILTER_VALIDATE_URL or simply, using regular expression. Here, I would like to know what are the best methods to get such a urls from users. Is it always good to let them to enter protocol? sometimes they may not know it is http, https, ftp, ftps.. etc. I think it is something hard to do some users. I tried something like this using FILTER_VALIDATE_URL, But it always use protocol and sometime I am confusing how its work.. // validate url $url = '[url="http://www.example.com%27;"]http://www.example.com';[/url] if (filter_var( $url, FILTER_VALIDATE_URL)){ echo "<br>valid"; } else { echo "<br>invalid"; } [b]OUTPUT[/b] : valid // validate url $url = 'hp://www.example.com'; if (filter_var( $url, FILTER_VALIDATE_URL)){ echo "<br>valid"; } else { echo "<br>invalid"; } [b]OUTPUT[/b] : valid // validate url $url = 'http://example.com'; if (filter_var( $url, FILTER_VALIDATE_URL)){ echo "<br>valid"; } else { echo "<br>invalid"; } [b]OUTPUT[/b]: valid // validate url $url = 'http://example.com?id=32&name=kamalani'; if (filter_var( $url, FILTER_VALIDATE_URL)){ echo "<br>valid"; } else { echo "<br>invalid"; } [b]OUTPUT[/b] : valid Can you tell me what are the best ways to get urls from user and how those validate? Any comments are greatly appreciating.. Thank you.
  22. So I am looking at developing a jobsboard, which has three tables: Company - Store details of companies looking to advertise jobs, build profile. Jobs - Store details of Jobs being advertised for a certain period of time. Orders - Store details of the transactions for the jobs being posted. The way it works is the company completes registration form, then has the option of posting jobs which they will be charged a fix fee. Now what foreign key would I store in the Orders table? since I am using Paypal and don't know how much information you can carry over. Would I store the CompanyID or the JobsID or both? PHP5 MySQL 5 Chrome
  23. I am going to create a HTML form dynamically with php. Using that form users can select subjects under different category. A category and Its subjects have broken to one logical section and have applied jquery accordion. In my form I need to create more logical section like that. this is the HTML structure of the form..(which need to create dynamically with php) <form action="" method="post"> <div id="accordion"> <!-- logical section 1 --> <div> <h3>Category 01: <span>category name</span><span></span></h3> <div class="container"> <table> <tr> <td width="50%"> <input type="checkbox" value="1" name="subject[]">subject1 </td> <td width="50%"> <input type="checkbox" value="2" name="subject[]">subject2 </td> </tr> </table> </div> </div> <!-- logical section 2 --> <div> <h3>Category 02: <span>category name</span><span></span></h3> <div class="container"> <table> <tr> <td width="50%"> <input type="checkbox" value="1" name="subject[]">subject1 </td> <td width="50%"> <input type="checkbox" value="2" name="subject[]">subject2 </td> </tr> </table> </div> </div> </div> </form> Can anybody tell my where I am going wrong? I troubled how to create inner table with 2 columns.
  24. Hi ,this book are really good , simple and easy to understand , don't have any problem on understanding your words so far. I have apply to two of my project . This is not really a problem , just not sure where to start off . I was trying to improve the login system , because when the user forget to click the logout button , the session doesn't logout automatically.What i trying to do is make a session expire after 15 minutes of inactivity ? Any ideas ? [sOLVED] used this solution apply to include/config.inc.php just after the session_start() Hope this can helps $live = false; // Errors are emailed here: $contact_email = 'abc@gmail.com'; define ('BASE_URI','.'); define ('BASE_URL','www.domain.com/'); define ('MYSQL', BASE_URI . '/include/mysql.inc.php'); // Start the session: session_start(); $timeout = 15; // Set timeout minutes $logout_redirect_url = "index.php"; // Set logout URL $timeout = $timeout * 60; // Converts minutes to seconds if (isset($_SESSION['start_time'])) { $elapsed_time = time() - $_SESSION['start_time']; if ($elapsed_time >= $timeout) { $_SESSION = array(); // Destroy the variables. session_destroy(); setcookie (session_name(), '', time()-86400, '/'); // Destroy the cookie. header("Location: $logout_redirect_url"); } } $_SESSION['start_time'] = time();
  25. Hi, Having a bit of a problem with regard to someone logging in on my site. It will not display Register page if I include certain files. Here is my header.php file which stores all the navigation links, and the sign-in option or to display their profile options: <body> <section class="navbar navbar-fixed-top"> <div class="navbar-inner"> <div class="container"> <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </a> <a class="brand text-info" href="http://www.webzoost.com" name="top">abaloo</a> <div class="nav-collapse collapse"> <ul class="nav pull-right"> <li><a href="http://www.webzoost.com/profiles/register.php">register</a></li> <li class="divider-vertical"></li> <li><a href="#">search</a></li> <li class="divider-vertical"></li> <li class="dropdown"> <?php if (isset($_SESSION['user_id'])) { echo '<a class="dropdown-toggle" href="#" data-toggle="dropdown">Your Profile <strong class="caret"></strong></a> <div class="dropdown-menu" style="padding: 15px; padding-bottom: 0px;">'; } else { echo '<a class="dropdown-toggle" href="#" data-toggle="dropdown">sign in <strong class="caret"></strong></a> <div class="dropdown-menu" style="padding: 15px; padding-bottom: 0px;">'; require ('includes/login_form.inc.php'); } ?> </div> </li> </ul> </div> </div> </div> </section> Now the problem comes when i add the following files: - login.inc.php since when i put this file in my index.php file I cannot seem to link to any other part of the website such as "register" which then throws up a blank page, but if I take out the file all-together then register displays. So what I am saying is where do I put file (login.inc.php) with-out it interfering with other links on my website, also could it be a directory issue, I know larry has his navigation in the footer, but mine is in the header.php file. here is my directory setup: index profiles - register.php includes - login.inc.php - login_form.inc.php - header.php // This is where all my navigation is, and also the login form as well. - footer.php I am now getting the following error when I only view the source code, this error is not being displayed for some reason on output to the user(I can't find an option to paste a screenshot/image of the code): An error occurred in script '/home/sites/webzoost.com/public_html/includes/header.php' on line 52:<br /> require(includes/login_form.inc.php) [<a href='function.require'>function.require</a>]: failed to open stream: No such file or directory<br /> <pre>Array<br /> Any comments, suggestions would be much appreciated. PHP5 MySQL5 Chrome
×
×
  • Create New...