Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'mysql'.



More search options

  • 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


Found 86 results

  1. The select query below returns 1 row when it should be 3. I am pretty sure it is because of the AVG(k.sumtotal) field. If I rewrite the query and take out that AVG(k.sumtotal) column and take out the FROM inv_ratings AS k, I get my 3 rows. I looked online for hours trying to find information about returning results using the AVG clause and didn't find much. Do I have to use a group by clause, I tried that and only get errors. If it is a group by clause please type the exact group by clause to use if you could. thank you. $p = "SELECT i.invention_id, i.inv_title, i.date_submitted, i.category_id, i.approved, c.category_id, c.category, u.image_name, AVG(k.sumtotal) FROM inv_ratings AS k INNER JOIN inventions AS i USING (invention_id) INNER JOIN categories AS c USING (category_id) INNER JOIN images AS u USING (invention_id) WHERE c.category_id = $cat AND i.approved = 'approved' HAVING u.image_name < 2 ORDER BY date_submitted DESC LIMIT $start, $display"; $q = mysqli_query($dbc, $p) or trigger_error("Query: $p\n<br />mysqli Error: " . mysqli_error($dbc));
  2. I've got your first edition of Effortless E-Commerce with PHP and MySQL. I've downloaded the script files and installed into xampp. The first issue I've identified is that some stored procedures are missing. So far, get_shopping_cart_contents and get_wish_list_contents. Looking in my phpMyAdmin, I can see 3 routines. None of them the same as the procedures I'm looking for. Are these routines the same as stored procedures? Looking in the book I find code for get_shopping_cart_contents and 3 other procedures for the cart, so I presume I can create them in the database. However the procedure get_wish_list_contents can't be found in the book or errata. How do I get that info? How much more information am I missing?
  3. Hi. I'm modifying the 'quotes' script in chapter 13 to include a statement before the quotes that indicates a 'new' or 'recent' quote if the quote was entered within the last 30 days. I know I need to use $row[date_entered] (type timestamp in mysql, e.g. 2014-03-09 13:25:11). Is there a function to compare that timestamp with today (in number of days)? Thanks.
  4. Hello everyone, I am have a problem that I am not able to fix. As explained in the book I don't see any values for my dates and times for the message board. I have downloaded the file (http://dev.mysql.com/downloads/timezones.html) to update my mysql installation but with no success. My question is how can I update my mysql installation on a wamp environment? Your help will be greatly appreciated. Regards, Gralf
  5. In Chapter 19, the $_SESSION['customer_id'] variable is often used for things like isset($_SESSION['customer_id']) why though can't we use other table columns that are like customer_id in the $_SESSION[] for example $_SESSION['order_id'] In chapter 19 also, the $_GET['id'] is the same id as the customer's. Why is it the same? Where does it get declared as the same, I have searched through the scripts and I don't see it. I am trying to create a script where users can view their past orders. The trouble I am having is calculating the total amount of the order in the checkout.php script, because there is no customer_id field in the order_contents table. Here is where I am at with that in the checkout.php script: $u = "SELECT price * quantity AS amount FROM order_contents WHERE order_id=?not sure what to put here"; $total = mysqli_query($dbc, $u);
  6. hi im a java/ newbie php developer. I recently bought your book and it has great content, but I an failed to open stream error. I have removed the path/to/dir with the correct value which is '/C:/xampp/htdocs/' and im still getting an error could there be something wrong with my path variable??
  7. My question is why in the following mysql statement does the $id at the end, not have to be in single quotes, whereas other variables in this statement are in quotes. $u = "UPDATE customers SET first_name='$fn', last_name='$ln', email='$em', address='$add', zipcode='$zip', city='$city', state='$state', country='$coun' WHERE customer_id = $id";
  8. I am using the structure of Script 3.5 (Calculator.php) to tackle the issue of recording attendance for persons listed in a MySQL database. I am using this structure because I am attempting to create a web page that will handle a form and then display it again. Larry mentions this function on page 86. I plan to use input type="checkbox" name="checkbox[]" value="full_name". The value part is where I am having trouble. I want to select a person's name from a table in the database so that the name will appear on the form on the same line with the checkbox. The page is in two parts, the first part being for php code, and the second part being for the html form. To place on the form a checkbox I need to list a person's name with that input. I can query the database in the php section and fetch from the array of results each person's name. Can anyone suggest where in the code I can fetch the names and then use them in the input for checkboxes? I hope this makes sense. I want to record attendance for all persons in a table who are present at a meeting. I want to list the names of all persons in the table along with a checkbox that can be checked to indicate they were present. I will appreciate any guidance that can be shared to help me in designing a plan to accomplish this. Thank you. Wes (wesmith4@gmail.com)
  9. I have an HTML table generated by PHP querying from MySQL table. <table> <tr> <th>Sl</th> <th>ID</th> <th>Article Name</th> <th>Publish Status</th> </tr> <?php $i = 1; foreach ($obj->showAllFromTable('pattern') as $pattern) { extract($pattern); ?> <tr> <td><?php echo $i++; ?></td> <td><?php echo $id; ?></td> <td><?php echo $pattern_name; ?></td> <td id="publish_<?php echo $id; ?>" class="status_pattern"> <?php echo $publish; ?> </td> </tr> <?php } ?> </table> I want to change the status of any article by clicking on the 'publish' cell of the corresponding article row. I am trying to use ajax method of jquery for this purpose as shown in the following: <script type="text/javascript"> $(document).ready(function(){ $('.status_pattern').click(function(){ var thisid = $(this).attr('id'); $.ajax({ url: "status_change_pattern.php", data: { id: thisid }, success: function (response) { alert(response); } }); }); }); </script> In the "success" block, instead of "alert", I want to create a functionality to change the text of the specific cell which I clicked. The "status_change_pattern.php" has just a text "Hey Hey". Can anyone help? Please. Thanks.
  10. hey everybody, i have a request here,i'm a newbie in which called php and mysql.. i have finished the HTML of my website and now i want to implement a sidebar for Most Popular Posts.. i'masking if u can afford me with a tutorial from the scratch to build my sidebar? plz? thanks in advance
  11. I am going through chapter 9, "CMS with OOP", and I have encountered an error when I finally visited the site (after building a few files first). I reviewed my syntax thoroughly, then downloaded the files from this site just to see if my code was wrong, but the home page (index.php) still displays the following error: SQLSTATE[28000] [1045] Access denied for user 'username'@'localhost' (using password: YES)[/size] The "pages" table in the "cms" database does indeed have rows inside it, I am using the correct username and password for my database (checked in the mysql command line), and I ran a php_info( ) to verify that PDO is enabled. Can anyone offer a suggestion as to the issue? I reviewed the forums but saw no question pertaining to this; if this is a duplicate, I apologize. EDIT: My search engine of choice is telling me it's some sort of permissions issue, but I haven't found any fixes. Still looking. Now that that's the issue, I'm not sure if this question is still within the scope that the community can answer it since this is a PHP and not a MySQL book. If so, help would be much appreciated!
  12. Hi, I need some help with a php application. I want to write simple online scheduling/appointment application with PHP and MySQL. I am not sure how to begin. Basically these are what the application would allow: USERS : - to log in as member - choose the person (advisors) they want to make an appointment with - pick a date and time from available time slot For example, Feb 1, 2014, 8:00AM- 8:30AM - Submit the date to advisor (email confirmation) ADVISORS - to log in as an admin - set up their schedules (available date and time). - there are several advisors, each has seperate schedule. My questions are: - What tools/frameworks should be used to display Calendar and time? - What appropriate methods should I store advisors available date and time in MySQL? - If i use jquery UI to display calendar, how can I make it interact with the database? For example, GREEN is available time, RED is booked. Thanks for your input.
  13. Hi, Larry In page 294. I try to break down the add_order procedure into separated piece since my shared host doesn't support routine. The problem lies in the last two statement. I believe the subtotal is a temporary column to store the result of quantity * price_per and then deal with the UPDATE statement that comes after. So, what's the best way to rewrite those two statements as normal sql query? I personally try to combine those two queries since they should work as one: $query = "UPDATE orders SET total=((SELECT SUM(quantity*price_per) INTO subtotal FROM order_contents WHERE order_id=$oid) + $shipping ) WHERE id=$oid"; Do you think this gonna work?
  14. Hello Larry, Thanks for another great book. When I try to create users table for pdf store, I get an error: 'ERROR 1293 (HY000): Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause'. I tried couple times get the exactly same error. Is that mysql doesn't allow creation of two TIMESTAMP in two columns (date_created & date_modified) ?
  15. Last week I purchased Mr. Ullman's "PHP and MySQL for Dynamic Web Sites" 4 edition. I have never tried working with php, nor mysql before. From my home, I have a stand-alone computer acting as a server. I am running Microsoft 2008 server on this computer. I also have Apache 2.2 running with no problems. I have installed "MySQL 5.6, and PHP 5.3.27, and again, no problems. I have a static ip address, and am hosting a small experimental website. I made the site with Dreamweaver. Wanting to try some script, I skipped ahead to Chapter 5, and experimented with some of the script. Using the "MYSQL Command line" lessons, I created a Database named "Bfdata." I then created a Table named "Members," with only two columns. The first column is named "username," and the second column is named "password." I then inserted 3 different users with the name of 1, 2, and 3 (those are the actual names I created for experimental sake) I gave each a password of xyzzyx123321 (that's the actual password for each one I created, also for experimental sake) I then went ahead to Chapter 9, and tried out the script 9.2 called "mysqli_connect.php" Try as I may, I couldn't get the file to communicate with the "mysql server." According to Mr. Ullman's tips, my php version might not support the "mysqli" function. So I searched the web and found a configuration that works good. The script reads as follows: <?php $link = mysql_connect('localhost' ,'john' , 'xyzzyx'); if (!$link) { die('could not connect: ' . mysql_error()); } echo 'connected successfully'; ?> My question is this: Obviously with the above script, I'm connecting to the Mysql server, but what I want the script to do, is not only successfully connect, but to then access the table called "members," and check for the "username" called 1 and check 1's password which is "xyzzyx123321," or "username 2, or 3 which also have the same password. Once the user name and password are successful , I'd like the script to pass the successful user on to a html page called upload that I made. Would someone write that script and either post it, or send it to my johninbellingham@hotmail.com email address. Thank you much, johnjwe
  16. Hello, I have been having trouble with this for quite some time I have tired to narrow it down the best I can. I able to complete the registration process, I went and check the sql database all fields have been filled. I think that the activation page cannot access the database to remove the active code. I tried to print or echo out the query value with echo "<p>Q: $q</p>" or print "<p>Q: $q</p>" all I see on the screen is "Q:" When I click the link from my email it doesn't seem to fail as it does not redirect me to index.php. I also do not get any error on my screen either. Any would help would be greatly appreciated. Regards Alex <div id="activate"> <?php /** * @author Alex Power * @copyright 2013 */ # Script 18.7 - activate.php require ('includes/config.inc.php'); $page_title='Activate Your Account'; if (isset($_GET['x'], $_GET['y']) && filter_var($trimmed['email'],FILTER_VALIDATE_EMAIL) && (STRlen($_GET['y']) == 32 )) { require (MYSQL); $q = "UPDATE users SET active=NULL WHERE (email='" . mysqli_real_escape_string($dbc, $_GET['x']) . "' AND active='" .mysqli_real_escape_sting($dbc, $_GET['y']) . "') LIMIT 1"; print "<p> Q: $q</p>"; $r = mysqli_query($dbc, $q) or trigger_error("Query:$q\n<br />)MySQL Error:" . mysqli_error($dbc)); if (mysqli_affected_rows($dbc)== 1 ) { echo "<h3>Your account is now active. You may now login.</h3>"; } else { echo '<p class="error">Your account could not be activated. Please re-check the link or contact the system administrator.</p>'; } mysqli_close($dbc); } else { //Redirect $url = BASE_URL . 'index.php'; ob_end_clean(); header("location:$url"); exit(); } // END of main IF-ELSE ?> </div>
  17. Hello, I tried to insert multiple image into image table using a foreach loop. The images insertion have returned no problem. But I wanted to catch the image_id of each insert and putted them into an array ($iid). Here is problem, no matter what I tried, the result always return 2 separated array: Array([0]=>9193) Array([1]=>9194). Is there anyway to solve this problem? I want Array([0]=>9193 [1]=>9194). Thank you all!. CODE: // query for media $query = 'INSERT INTO media (file_title, file_mimetype, file_type, file_url, file_url_thumb, file_is_product_image, created_on) VALUES (?,?,?,?,?,?,NOW())'; $stmt = mysqli_prepare($dbc, $query); $i = 0; foreach ($image_name as $key => $value){ $dot = strpos($value, '.'); $file_title = substr($value, 0, $dot); $extension = str_replace('.','',substr($value, $dot)); $file_mime = 'image/'.$extension; $file_type = 'product'; $file_url = $value; $file_url_thumb = 'images/product/resized/'.$file_title. $upload->getSuffix().$extension; $fipi = 1; mysqli_stmt_bind_param($stmt, 'sssssi', $file_title, $file_mime, $file_type, $file_url, $file_url_thumb, $fipi); mysqli_stmt_execute($stmt); // check result: if(mysqli_stmt_affected_rows($stmt) == 1){ // get the image id $iid = array(); $iid[$i++] = mysqli_stmt_insert_id($stmt); print_r($iid); // RESULT: Array([0]=>9193)Array([0]=>9194) } else { echo 'Insertion failed' . mysqli_stmt_error($stmt); } } // End of foreach
  18. 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); }
  19. 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);
  20. 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 :-)
  21. 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!
  22. 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
  23. 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!
  24. 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.
  25. 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
×
×
  • Create New...