Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'mysql'.

  • 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. I'm having a strange problem here. I created the registration.php and connect.php files, but I cannot seem to add the info entered into the form to the SQL table, unless I have the $dbc constants inside the register.php file. Originally, I was using the require() function to pull in the SQL connect file. But I keep getting the "System Error You could not register due to a system error." message when I submit the form. I did several tests to try find out where the problem is and I believe it has something to do with the constants not being able to be used in the require() and include() functions. Also, I found if I copy the contents in the connect.php file into the register.php, it works. I checked my php.ini file, both allow_url_fopen and allow_url_include are on. So I'm not sure why I can't include/require constants in my PHP files. Also, when I used the require() function I was using an absolute URL path to the connect.php file. Any ideas? Thanks!
  2. The code below produces a syntax error, saying there is unexpected T-String in the line that starts with "Load Data......". Can anyone tell me wyat I am doing wrong? ========================================= <?php require ('./mysqli_connect.php'); LOAD DATA LOCAL INFILE 'c:/Users/CourseOfStudy.txt' INTO TABLE CourseOfStudy FIELDS TERMINATED BY ',' IGNORE 1 LINES; ?> ======================================== Thanks for any directions for a new user. Wes Smith
  3. I am wondering if someone can help me with an intermittent database connection problem that I have started to experience. My environment is: . Windows 7 Home Premium 64 bit . Internet Explorer 10 . Firefox 22.0 . Dreamweaver MX2004 as the text editor . Xampplite 1.7.3 which comprises: .. Apache 2.2.14 .. PHP 5.3.1 .. MySQL 5.1.41 The problem occurs intermittently in both IE10 and Firefox, so appears not to be related to the browser. The message that I get is (and I stress that I don't always get it): Warning - mysql_connect() [function MySQL-connect]: Unknown MySQL server host 'localhost' (11001) with a reference to the PHP line of code. This is immediately followed by Fatal error Unknown MySQL server host 'localhost' (11001) with a reference to the same PHP line of code. My connection code is: $dbc = mysql_connect($local_hostname_xx, $local_username_xx, $local_password_xx) or trigger_error(mysql_error(),E_USER_ERROR); I am using the PHP mysql functionality as the production system does not support the mysqli functionality. If I have a look at the database with HeidiSQL (which provides MySQL admin-like functionality) the database and its data are all there. Can you also provide some specific guidance re the following: 1) I have a lot of PHP scripts that enable an administrator to update many aspects of the database tables. Most use Larry's PHP redux technique. In each script I require_once the php connection code followed immediately by the mysql_select_db statement. Should I be using 'require' rather than 'require_once'? 2) The database connection code does not use a persistent mysql_connect - should I be using a persistent connection i.e., mysql_pconnect function instead? 3) I do not close the database connection in the PHP scripts - should I? I have been using similar code for years without a problem. The problem seems to have started when I was experimenting with 'require' and 'require_once' to include the database connection code. I was also experimenting with mysql_connect versus mysql_pconnect in the connection code itself. Any advice will be most appreciated and thank you in anticipation. Best regards, Necuima.
  4. 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!
  5. Just as a short note, the SQL commands to create the three tables for the real-world site project in chapter 15, pg. 556 caused errors in phpMyAdmin with MAMP. I removed all of the single quotation marks throughout the code and everything ran smoothly. I guess this is a phpMyAdmin issue or maybe I'm using a different version than that used in the book. Still love Mr. Ullman's books and have nearly all of them now! Thanks
  6. 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.
  7. 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?
  8. 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.
  9. Hi guys, i read about PDO in the book, then i read some PDO articles.. Most of the articles say that we should turn off PDO::ATTR_EMULATE_PREPARES if using MYSQL latest driver.. is this true? i searched some explanation why with recent mysql i should turn of PDO::ATTR_EMULATE_PREPARES, but unfortunately my newbie brain doesn't understand their explanation... all i know is PDO will send the query to the MYSQL when we use : $stmt = $pdo->prepare('query'); then PDO will send the data(placeholder's value) : $stmt->bindValue(':val', $value, PDO::PARAM_STR); $stmt->execute(); my mysql version : 5.x php version : 5.4 please guide me here , if possible with example codes
  10. Can anyone help me get the sample data and SQL commands into Workbench? The book says "You can download the complete SQL commands, along with some sample data, from the account page on the book’s Web site." (Page 64) Are these files for use in MySQL Workbench? If so, how can I get the commands and sample data into Workbench? I have already opened the yii_cms.mwb fil in Workbench, and I can see the visual of the table relationships. But I don't know how to import the data and SQL commands. This is not obvious to me, since Workbench is new for me. I have already downloaded and unzipped these files: SQL commands MySQL WorkBench file for the CMS site Edited Code for the CMS Example I am using version 0.5 of Larry Ullman's Yii book. I'm on Win XP, with XAMPP and Workbench running. Any help would be much appreciated. Thanks in advance!
  11. Hi, I hope someone can help me, i am going crazy. I am trying to populate the time zone tables, but everytime i try i get the same error message: ERROR 1064 (42000): 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 './mysql_tzinfo_to_sql /usr/share/zoneinfo | /Applications/MAMP/Library/bin/mysql' at line 1 Now, i had read the MySQL manual several times, and tried: mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql; somebody suggested using this variation since i am using MAMP: ./mysql_tzinfo_to_sql /usr/share/zoneinfo | /Applications/MAMP/Library/bin/mysql -p -u root mysql; or this one: ./mysql_tzinfo_to_sql /usr/share/zoneinfo | ./mysql -p -u root mysql i get the same ERROR 1064 message. I had check the path to the folders and i am sure is correct, AM I MISSING SOMETHING? Thanks in advance for any help MySQL version 5.5.9 Mac 10.5.8
  12. hi Interesting book especially the stored procedures. I'd be interested to hear from anyone who is interested in extending or generalising the database; thus creating more variables to search upon. After all, not all of us want to sell coffee do we? I'm especially interested in filters or searching by specific categories see: http://acookson.org/wp-content/uploads/2013/01/shop-screenshot.png for an example of what's on my mind. In my fictitional jeans shop example, I was playing around with MySQL workbench to come up with some possibilities for an ER diagram: http://acookson.org/wp-content/uploads/2013/01/ecommerce3.png It's totally at prototype stage and was looking for some inspiration really; maybe an on-going discussion around this topic. best wishes Andrew
  13. 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
  14. I have a couple of questions regarding stored functions. 1. Where are they stored? (Can I see a stored function using phpMyAdmin or mysql client? If yes, how?) 2. Will the stored functions be available for as long as database exists, or only for the duration of the current database connection? (To rephrase it, should a custom function be stored just once, or it should be recreated every time the script runs?) Thank you for help, as always!
  15. Hello Forum! Asking yet another one of my typical questions. Do I understand it correctly that the underlying notion of the "normal form" databases is to eliminate repetition from every database, so as a result there's a bigger number of smaller databases? I'm asking this question because in Chapter 3 of the 3rd edition of this book Larry is using a database that contains repeated values in the same column: I also often find myself using databases like that, which seems to work perfectly fine. Am I missing something, as always? Do I understand the idea of the "normal form" database incorrectly, or should there be (if we deal with the example above) a separate databases for all UNIQUE, STANDARD and PO BOX zip code types, and a separate databases for HOTSVILLE, AGUADILLA, ARECIBO and so on? Would appreciate your input!
  16. Hiya - I'm having difficulty connecting to the database with the mysql.inc.php. Here's the error message: <-- error message ========== An error occurred in script '/hermes/waloraweb004/b1384/moo.laissezfairelondonco/wolfcut/index.php' on line 9: require(/home/users/web/b1384/moo.laissezfairelondonco/wolfcut/wolfcut/includes/mysql.inc.php) [function.require]: failed to open stream: No such file or directory ========= --> Really basic, I know, but I'm trying to follow an example in another book and the above error keep happening. As far as I can gather, the 'user, password, host, db name' are all correct. Assistance much appreciated
  17. 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
  18. 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 :-)
  19. Can someone - (Larry?) - please explain in lay terms the esoteric Paragraph 1 from Chapter 7, sub-chapter "Outer Joins": "Whereas an inner join returns records based upon making matches between two tables, an outer join will return records that are matched by both tables, and will return records that don’t match. In other words, an inner join is exclusive but an outer join is inclusive." It's the second time I'm trying to go through this chapter, and the second time I stumble at that paragraph! Would be grateful for help from knowledgeable person!
  20. 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();
  21. hello, I made the second draft of the book, but I was a little mistake to be solved. I have a problem with the postal code, after completing the contact form on the site, the database I get a bad zip code, when I type in a ZIP code sample form 21-150 (in Poland we have a code of 5 digits) in the database shows me 00000. I'm Polish and I had to change the code included with the book. What can be wrong? please help. checkout.php: if (preg_match ('/^(^\d{2}-\d{3})$/', $_POST['zip'])) { $z = $_POST['zip']; } else { $shipping_errors['zip'] = 'Podaj kod pocztowy!'; } billing.php if (preg_match ('/^(^\d{2}-\d{3})$/', $_POST['cc_zip'])) { $cc_zip = $_POST['cc_zip']; } else { $billing_errors['cc_zip'] = 'Wpisz kod pocztowy!'; } TABLE `customers` in Mysql `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `email` varchar(80) NOT NULL, `first_name` varchar(20) NOT NULL, `last_name` varchar(40) NOT NULL, `address1` varchar(80) NOT NULL, `address2` varchar(80) DEFAULT NULL, `city` varchar(60) NOT NULL, `state` char(2) NOT NULL, `zip` mediumint(5) unsigned zerofill NOT NULL, `phone` int(10) NOT NULL, `date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `email` (`email`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;
  22. Can someone echo out their $q variable from Chapter 17 Script 17.4 and show me the output? My query is failing as the result of $r is FALSE so I'm getting a Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result when I test forum.php When I echo out the $q variable ( I used echo '<p>The query $q is ' . $q . '</p><br /><br />'; on line 21) I get these results in web browser: The query $q is SELECT t.thread_id, t.subject, username, COUNT(post_id) - 1 AS responses, MAX(DATE_FORMAT(CONVERT_TZ(p.posted_on, 'UTC', 'America/New_York'), '%e-%b-%y %l:%i %p')) AS last, MIN(DATE_FORMAT(CONVERT_TZ(p.posted_on, 'UTC', 'America/New_York'),'%e-%b-%y %l:%i %p')) AS first FROM threads AS t INNER JOIN posts AS p USING (thread_id) INNER JOIN users AS u ON t.user_id = u.user_id WHERE t.lang_id = GROUP BY (p.thread_id) ORDER BY last DESC I'm wondering why {$SESSION['lid']} is missing from the output. Here is my line 19 code (matches the book): $q = "SELECT t.thread_id, t.subject, username, COUNT(post_id) - 1 AS responses, MAX(DATE_FORMAT($last, '%e-%b-%y %l:%i %p')) AS last, MIN(DATE_FORMAT($first, '%e-%b-%y %l:%i %p')) AS first FROM threads AS t INNER JOIN posts AS p USING (thread_id) INNER JOIN users AS u ON t.user_id = u.user_id WHERE t.lang_id = {$SESSION['lid']} GROUP BY (p.thread_id) ORDER BY last DESC";
  23. Here's what I'm trying do. Let's say my database has 30 entries in it. I want to display the first 15 in one section of my page and the remaining 15 in a different section. So, I figured I would use mysql_affected_rows() to see how many entries were being returned. This works fine, but now I'm stuck on how exactly to write an if/while loop that loops through and prints out only the first half or the second half. Or should I be going about it completely differently and simply writing a query that only returns the first or second half? Any advice or direction would be greatly appreciated! Thanks.
  24. I have recently created a menu using php that gives several options for searching a database using mysql:- 1. display all records 2. display a particular record 3. display records beginning with a letter this works correctly but if I select another option the first results still appear on my display and i cannot remember how to clear the display between searches. Any advice please kind regards Tony
  25. I'm just trying to use an alias in a select query and I'm having a problem. It's not a big deal, but I don't know why I'm getting an error. Can anyone answer this: Why does SELECT title, text, id FROM memos LEFT JOIN memos_associations USING (id) WHERE CONCAT_WS(' ',title,text) REGEXP '[[:<:]]potassium[[:>:]]' = 1 work ok, but SELECT title, text, id, CONCAT_WS(' ',title,text) AS combo FROM memos LEFT JOIN memos_associations USING (id) WHERE combo REGEXP '[[:<:]]potassium[[:>:]]' = 1 not? The latter generates the error, "ERROR 1054 (42S22): Unknown column 'combo' in 'where clause'." Thanks! ...Jason
×
×
  • Create New...