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 87 results

  1. This part of the login code does not seem to be working. I know the information is in the database and the activation field says NULL. I believe that the browser - Firefox on a Mac - is accepting cookies. I have tried this with several users and they all have the same password. I am getting the error message that indicates that the Email and Password does not match those on file. I am set up to use PHP 7. // Query the database: $q = "SELECT user_id, first_name, user_level, pass FROM users WHERE email='$e' AND active IS NULL"; $r = mysqli_query($dbc, $q) or trigger_error("Query: $q\n<br>MySQL Error: " . mysqli_error($dbc)); if (@mysqli_num_rows($r) == 1) { // A match was made. // Fetch the values: list($user_id, $first_name, $user_level, $pass) = mysqli_fetch_array($r, MYSQLI_NUM); mysqli_free_result($r);
  2. Chapter 7: Advanced SQL and MySQL - Fifth Edition of PHP and MySQL for Dynamic Web Sites Visual QuickPro Guide Page 229 - Table 7.3 It says I don't understand the difference between lowering importance and lowering ranking. Doesn't decreasing the importance decrease the ranking? Can someone please explain to me the difference between the 2? Thanks, Varun
  3. Am trying to put mysqli result set into an array for later use and this is how I did it(but is not working) $split = []; $sql_money = "SELECT j_id, amount_invested FROM j_members WHERE j_activated = 1 LIMIT 5"; $result_money = mysqli_query($conn, $sql_money); while($data = mysqli_fetch_assoc($result_money)){ $split[] = ['id' => $data['id'], 'invest' => $data['amount_invested']]; //echo $data['j_id']; } foreach($split as $s){ echo $s['id'] . '<br>'; } Who can put me through
  4. Hi all. I need some assistance with dynamically populating a mega drop-down menu across 6 columns (Bootstrap 4) with the languages retrieved from a database query (Forum project - Chapter 17). I have searched the internet without any success. Any help will be much appreciated. My code is included below. Regards // Select a language: echo '<li class="nav-item nav-item-icon hidden-md-down dropdown megamenu"> <a class="nav-link dropdown-toggle" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">' . $words['lang'] . ' <span><i class="fa fa-globe"></i></span></a> <div class="dropdown-menu"> <div class="mega-dropdown-menu row row-no-padding"> <div class="col-md-4 col-lg-2 ml-lg-auto"> <ul class="megadropdown-links"> <li>'; // RetrRetrieve all the languages and add to the pull-down menu: $q = "SELECT id, lang FROM languages WHERE status='Active' ORDER BY lang ASC"; $r = mysqli_query($dbc, $q); if (mysqli_num_rows($r) > 0) { while ($menu_row = mysqli_fetch_array($r, MYSQLI_NUM)) { echo '<a class="dropdown-item" href="?lid=' . $menu_row[0] . '">' . $menu_row[1] . '</a>'; } } mysqli_free_result($r); echo '</li> </ul> </div> </div> </div> </li>';
  5. I'm trying to run a query of existing employee records in order to update their information, and am receiving the error: Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in /home/schill54/public_html/Capstone/htdocs/Home/updateform.php on line 8 Below is my script. I've tweaked the query several times with no luck. Originally I had it set to SELECT * from my users table but then realized there was 1 column that I didn't want it to return and therefore I didn't account for it in my form, so then listed the desired columns individually but still getting the error. From the google searching I've done so far I realize there is probably still something wrong with my query but can't figure out what it is. <?php { include ("../includes/header.php"); require_once ('../../mysqli_connect.php'); $lname=$_GET['last_name']; $query = "SELECT first_name, last_name, phone, username, pass, admin FROM users WHERE last_name='$lname'"; $result = mysqli_query ($dbc, $query); $num = mysqli_num_rows($result); if ($num > 0) { // If it ran OK, display all the records. while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){ ?> <form action="updatemp.php" method="post"> <p>First Name: <input name="text" size=30 value="<? echo $row['first_name']; ?>"></p> <p>Last Name: <input name="text" size=30 value="<? echo $row['last_name']; ?>"></p> <p>Phone Number: <input name="text" size=30 value="<? echo $row['phone']; ?>"></p> <p>User Name: <input name="text" size=30 value="<? echo $row['username']; ?>"></p> <p>Password: <input name="text" size=30 value="<? echo $row['pass']; ?>"></p> <p>Admin Access?: <input name="text" size=30 value="<? echo $row['admin']; ?>"></p> </form> <? } //end while statement } //end if statement mysqli_close($dbc); //include the footer include ("../includes/footer.php"); } ?>
  6. Why cannot I enter more than 127 items as quantity in the cart. I have tried and changed quantity in carts table from tinyint to smallint and that does not help. The maximum quantity of one item that can be selected is 127.
  7. Hi Larry, I am loving the book, as I work towards converting lots of Classic ASP to PHP 7. I have in the past created hundreds of Stored Procedures in MSSQL. One thing that has bugged me in the past was that I found it hard to search for variables, etc., in the Stored Procedures when I changed something. In addition to liking the fact that they will be in my (easily searchable) code, I like the security and performance perks of using Prepared Statements as I translate these Stored Procedures... but I am wondering: Would Stored Procedures or Stored Functions be faster than Prepared Statements? Again, thank you for making such an excellent book - it's really helping me get up to the next level in my coding abilities. Thanks, Jim
  8. Hello Larry and Hello Community, I bought book php and mysql for dynamic web sites in english from USA since i didn't see it in my native language. I gave a look all book for make general feeling and then i will read better and careful example and teching suggestions. Book is very very good in my opinion. My question is about what is best techinque to store html inside mysql database. I'm studying a bit how work CKeditor, but i think many html editor work more or less in same way, and it use a textarea to collect the html, so what you really need to do after a submit or similar processes is simply get the value of texarea and use php to store html in database. I'm asking how handle security, quote and double symbols or other problems. If i have understand i can use directly mysql_real_escape when i get textarea, simply before send html inside mysql or i can use prepared statement and in this case i think i can't use mysql_real_escape so i need pheraps to use htmlentities. I'm a little confuse about conflict you could have use both htmlentities, prepared statement, mysql_real_escape, etc.. I'm not exactly sure how i is best way general speaking in term of 100% secutiry and in term or not ruin html inside mysql and also i'm not sure what is procedure to make the contrary, i mean get html from mysql and serve i in page. Thanks very much. Andrea
  9. Dear Larry, I started learning MySQL through your book. To get started, I followed you instruction to set a password to the root using MyPhpAdmin. After I have entered the password, I updated the config.inc.php file to include the password. However, I am no longer able to access the root ever since. The error message is 1045, Access denied for user root@local host (using password:YES). I researched the web for password reset but the techniques (MySQLD) could not resolve my problem. Could you advise what I can do. Thank you so much.
  10. Hi everyone, I'm building my own shopping website. I haven't figured out how to populate two dropdown lists with available sizes and colors of a product_id from database. Here is the result I've got from querying database. id product_name style size color price image sku stock 1 Neck Top 104 S White $30.00 104.jpg 104-1 5 2 Neck Top 104 S Black $30.00 104.jpg 104-2 5 3 Neck Top 104 M Red $30.00 104.jpg 104-3 10 4 Neck Top 104 L Blue $30.00 104.jpg 104-4 10 5 Neck Top 104 XL Black $30.00 104.jpg 104-5 5 And here are my tables: tblProduct tblSizes tblColors tblSpecific_Products id id id id product_name size color product_id style size_id price color_id image stock category (tops,dresses,bottoms,...) subcategory (bodycon,work,evening,cocktail) Is there any way I can have it done without duplicating the values in each dropdown list? Also for each product_id, how can I store 3 different images (front view,back view and side view) for each color? Does it mean I have to create another attribute table for those images and store their names in database? I'm confused.
  11. Hello, I want to purchase "MySQL: Visual QuickStart Guide" by Larry Ullman but can find only the Second Edition which seems to have been published in 2006. I just wanted to know if a later version is available, or is planned for publication soon. If not, could you please advise if the contents of the Second Edition are still valid for use in 2018. Thanks
  12. so when starting up the wishlist.php using the book scripts of the second site, I'm getting an error that An error occurred in script '/var/www/html/ex2/html/wishlist.php' on line 81: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given Array. what does this error and mean. How do I go about fix it? Is it a problem with the data in the database?
  13. I've followed the tutorial as closely as possible, yet continue to have problems with this particular script. I am receiving the following error message on an INSERT clause, despite all the columns lining up with my table. An error occurred in script 'C:\xampp\htdocs\register.php' on line 63: Query: INSERT INTO users (email, pass, first_name, last_name, active, registration_date) VALUES ('test@test.com', SHA1('test'), 'test', 'test', '125b7b06df899c3ab98189e3077f5f0c', NOW() ) Would anyone be able to point me to what is going wrong here? Here is the full script: <?php # Script 18.6 - register.php // This is the registration page for the site. require ('includes/config.inc.php'); $page_title = 'Register'; include ('includes/header.html'); if ($_SERVER['REQUEST_METHOD'] == 'POST') { // Handle the form. // Need the database connection: require (MYSQL); // Trim all the incoming data: $trimmed = array_map('trim', $_POST); // Assume invalid values: $fn = $ln = $e = $p = FALSE; // Check for a first name: if (preg_match ('/^[A-Z \'.-]{2,20}$/i', $trimmed['first_name'])) { $fn = mysqli_real_escape_string ($dbc, $trimmed['first_name']); } else { echo '<p class="error">Please enter your first name!</p>'; } // Check for a last name: if (preg_match ('/^[A-Z \'.-]{2,40}$/i', $trimmed['last_name'])) { $ln = mysqli_real_escape_string ($dbc, $trimmed['last_name']); } else { echo '<p class="error">Please enter your last name!</p>'; } // Check for an email address: 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>'; } // Check for a password and match against the confirmed password: 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 { echo '<p class="error">Please enter a valid password!</p>'; } if ($fn && $ln && $e && $p) { // If everything's OK... // Make sure the email address is available: $q = "SELECT user_id FROM users WHERE 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) { // Available. // Create the activation code: $a = md5(uniqid(rand(), true)); // Add the user to the database: $q = "INSERT INTO users (email, pass, first_name, last_name, active, registration_date) VALUES ('$e', SHA1('$p'), '$fn', '$ln', '$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) { // If it ran OK. // Send the email: $body = "Thank you for registering at <whatever site>. To activate your account, please click on this link:\n\n"; $body .= BASE_URL . 'activate.php?x=' . urlencode($e) . "&y=$a"; mail($trimmed['email'], 'Registration Confirmation', $body, 'From: admin@sitename.com'); // Finish the page: echo '<h3>Thank you for registering! A confirmation email has been sent to your address. Please click on the link in that email in order to activate your account.</h3>'; include ('includes/footer.html'); // Include the HTML footer. exit(); // Stop the page. } 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 { // The email address is not available. echo '<p class="error">That email address has already been registered. If you have forgotten your password, use the link at right to have your password sent to you.</p>'; } } else { // If one of the data tests failed. echo '<p class="error">Please try again.</p>'; } mysqli_close($dbc); } // End of the main Submit conditional. ?> <h1>Register</h1> <form action="register.php" method="post"> <fieldset> <p><b>First Name:</b> <input type="text" name="first_name" size="20" maxlength="20" value="<?php if (isset($trimmed['first_name'])) echo $trimmed['first_name']; ?>" /></p> <p><b>Last Name:</b> <input type="text" name="last_name" size="20" maxlength="40" value="<?php if (isset($trimmed['last_name'])) echo $trimmed['last_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. Must be between 4 and 20 characters long.</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> <?php include ('includes/footer.html'); ?> Thank you very much for any help.
  14. I'm having a bit of a problem which I think I might know the solution, but I'm really struggling to know the correct syntax. If somebody could point me in the right direction I'd be very grateful. I've created an application where users can create projects, and within the projects there are 'outputs' and 'inputs'. All of which is stored in separate MySql tables. It works fine. I have now been asked to create an addition layer, a 'programme' layer, which sits above projects (ie there can be multiple projects within one programme). I think I have got my table normalisation correct, I created 2 tables, 'programmes' which stores programme id and name etc, and 'programmes_projects' which stores only the programme id and the project id. That seems to work ok. What I'm having trouble with, is displaying the results correctly. I need to retrieve information from 4 (actually 5) related MySql tables. Phew. I think I need to create an associative array and a foreach loop, but because of the number of tables and the relationships, I'm getting very confused. I'm not sure if I should be focussing on the sql statements, the php, or what. I tried using while loops, because that's what I know, but wasn't surprised that it didn't work. progId = $_GET['prog']; //get the individual projects from the linking db table $get_projects = "SELECT * FROM programmes_projects WHERE prog_id=$progId"; $run_projects = mysqli_query($conn, $get_projects); $i = 0; while($row_projects=mysqli_fetch_array($run_projects)){ $prog_proj_id = $row_projects['prog_proj_id']; $prog_id = $row_projects['prog_id']; $projectId = $row_projects['proj_id']; $i++; //attempting to collect project details from the outputs table $get_proj_details = "SELECT * FROM projects WHERE project_id=$projectId"; $fetch_projects = mysqli_query($conn, $get_proj_details); $i = 0; while($row_details=mysqli_fetch_array($fetch_projects)){ $proj_name = $row_details['project_name']; $proj_whatever = $row_details['date']; $i++; // project outputs $fetch_outputs = "SELECT * FROM projects_outputs WHERE project_id=$projectId"; $get_outputs = mysqli_query($conn, $fetch_outputs); $i = 0; while($row_outputs=mysqli_fetch_array($get_outputs)){ $out_id = $row_outputs['output_id']; $output_desc = $row_outputs['output_desc']; $i++; }}}?> Please could someone help?? Even if it's just a nudge in the right direction. Thank you very much.
  15. Hi all, and especially Larry, I have encountered an interesting issue when uploading images using a reference from recently uploaded MySQL data. What I am trying to do is, in one page, send data regarding a property (real estate in US) and an image. I want the image to have the same reference number as the property. This is the schematic:... 1) Input html and upload image -> POST to php. 2) INSERT property data -> MySQL 3) SELECT property reference (Primary key) generated by MySQL. 4) Use the property reference + ".jpg" as filename -> the image to a subdirectory on server. The issue is that it seems that MySQL can take a bit too long to do the SELECT query which then throws up a '$image_no undefined variable and the image is saved as '.jpg' instead of e.g. 234.jpg. I think that I have solved it thus (my comments in red): Section of whole program: Check if user has sent html POST and uploaded an image (other conditionals not shown here for conciseness): if(isset($_FILES['upload'])) { ....then insert the data into MySQL: $q = "INSERT INTO db655736144.Properties (Property_name, Owner_name, Owner_phone_number, Owner_email, Description, Electricity, Water, Price, Commission, TCC_Comments) VALUES ('$pty', '$owner', '$phone', '$owner_email', '$desc', '$elec', '$water', '$price', '$comm', '$TCC')"; $r =@mysqli_query ($dbc, $q); //Run the query - could put this in a while loop as well? $allowed = array ('image/pjpeg', 'image/jpeg', 'image/JPG', 'image/jpg'); if(in_array($_FILES['upload']['type'], $allowed)) //Check for correct file type { $prop_id = "SELECT Property_Ref FROM Properties WHERE Property_name = '$pty'"; //Get property reference number $prop_id_action = @mysqli_query ($dbc, $prop_id); //Do query //$Property_ref is the array containing property ref no generated by MySQL while ($Property_ref = @mysqli_fetch_array($prop_id_action)) { $image_no = $Property_ref['Property_Ref']; // $image_no is the property ref no generated by MySQL. This while loop should only run once as Property_Ref is Primary key. } If MySQL hasn't done its bit yet, then you are left with $image_no equalling NULL and an error, AND an image called .jpg on the server. Also the program has to open a new subdirectory with the name Property Ref (e.g. Main/Properties/Adds/123 for additional images to be uploaded to later. This won't happen. This is the bit --------------------------------------------------------------------------------------------------- I have added a while loop that seems to work here:..... while (!$image_no) // If the image number from the query = NULL (!$image_no) { while ($Property_ref = @mysqli_fetch_array($prop_id_action)) // Repeat the query until we have a value for $image_no { $prop_id_action = @mysqli_query ($dbc, $prop_id); //Do query $image_no = $Property_ref['Property_Ref']; // $image_no is the property ref no generated by MySQL } } -------------------------------------------------------------------------------------------------- $_FILES['upload']['name'] = $image_no . '.jpg'; //Add file extension This is just to check that there isn't a subdirectory with the same name (shouldn't be)... if (move_uploaded_file($_FILES['upload']['tmp_name'], "images/properties/{$_FILES['upload']['name']}")) { if(is_dir('images/properties/more_images/' . $image_no)) { echo "<h2>There was a system problem - please call Max.</h2>"; echo '<p style = "font-weight: bold; font-size: 120%"><a href = "admin.php">Return to menu</a></p>'; die(); } No directory exists so we can contine by creating it: else { mkdir('images/properties/more_images/' . $image_no); Some HTML to return to menu etc:... echo '<p style = "font-weight: bold; font-size: 120%">File uploaded....<a href = "add_images.php?image_no=' . $image_no . '">Add more images</a>...or...<a href = "admin.php">Return to menu</a>....or just continue.....</p>'; } ....cont } else { echo "There was a system problem - please call Max."; die(); } } else { echo'<p class="emph">Please upload a .jpg image</p>'; } } I'd be very interesed in your comments regarding this 'fix'. Regards Max
  16. I created various websites (based on Larry's code) that worked fine for years, but after my web hosting company upgraded to PHP Version 5.6.27, I repeatedly receive this error message: "An error occurred in script '.../mysql_connect.php' on line 8: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead" I was able to suppress that error message on one website by prepending the "@" symbol to the expression, but strangely it did not work on another site. I'd like to know why (as a quick fix), and whether I can do something to suppress error messages for an entire site instead of using "@" multiple times. I'd also love to know how to change my code to work with PDO (preferably) or MySQLi; my web host supports both. It would be great to see an example of PHP handling data with old MySQL code and PHP working with PDO or MySQLi, to see how to "translate" it, so to speak. However, I don't want to use PDO if that requires me to learn Object-Oriented PHP; all my sites are based on procedural PHP. The above error message is generated in response to this mysql_connect.php code: <?php error_reporting(0); // didn't suppress error message ini_set('display_errors',0); // didn't suppress error message DEFINE ('DB_USER', '***'); DEFINE ('DB_PASSWORD', '***'); DEFINE ('DB_HOST', '***'); DEFINE ('DB_NAME', '***'); if ($dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD)) { // this is the line generating the error message if (@!mysql_select_db (DB_NAME)) { trigger_error("Could not select the database!\n<br />MySQL Error: " . mysql_error()); exit(); } } else { trigger_error("Could not connect to MySQL!\n<br />MySQL Error: " . mysql_error()); exit(); } function escape_data ($data) { if (ini_get('magic_quotes_gpc')) { $data = stripslashes($data); } if (function_exists('mysql_real_escape_string')) { global $dbc; $data = @mysql_real_escape_string (trim($data), $dbc); } else { $data = @mysql_escape_string (trim($data)); } return $data; } ?> Thank you!
  17. I'm having an issue with mysql_real_escape_string. This is used to display a custom post type (food menu items) for the WooThemes Diner theme (for WordPress). Food menu items no longer display on the Diner menu page because they are being called with mysql_real_escape_string. What is the proper way to call these items? Theme: Diner by WooThemes version 1.9.8 (now retired from active support) Affected file: admin-interface.php Lines: 111 & 118 /*-----------------------------------------------------------------------------------*/ /* WooThemes Admin Interface - woothemes_add_admin */ /*-----------------------------------------------------------------------------------*/ if ( ! function_exists( 'woothemes_add_admin' ) ) { function woothemes_add_admin() { global $query_string; global $current_user; $current_user_id = $current_user->user_login; $super_user = get_option( 'framework_woo_super_user' ); $themename = get_option( 'woo_themename' ); $shortname = get_option( 'woo_shortname' ); // Reset the settings, sanitizing the various requests made. // Use a SWITCH to determine which settings to update. /* Make sure we're making a request. ------------------------------------------------------------*/ if ( isset( $_REQUEST['page'] ) ) { // Sanitize page being requested. $_page = ''; $_page = mysql_real_escape_string( strtolower( trim( strip_tags( $_REQUEST['page'] ) ) ) ); // Sanitize action being requested. $_action = ''; if ( isset( $_REQUEST['woo_save'] ) ) { $_action = mysql_real_escape_string( strtolower( trim( strip_tags( $_REQUEST['woo_save'] ) ) ) ); } // End IF Statement // If the action is "reset", run the SWITCH. /* Perform settings reset. ------------------------------------------------------------*/
  18. So...I'm just getting really frustrated now. I've been reading through several of these chapters several times. My school always tends to not choose books well. On to the issue though. In several sections I've noted it stating "Connect to MySQL and select the forum database." This is where the issue lies. I have MySQL and PHP installed in both operating systems of my laptop (Linux and Windows) and in neither does the referenced database exist. The book does not even state WHERE or HOW to have this included. How is a person supposed to follow the examples if some crucial components were left out? It's like giving directions by saying "Just follow me" while in a car to a person on a bicycle. Saying follow me would be completely worthless. If someone can at least point me in the right direction to actually have these referenced databases...or to a quality book. Either way.
  19. hello, I have starting reading the PHP and MySQL 4th edition book by LarryUllman. So far I have completed first four chapters and now starting 5th chapter. But, with time as I read further, I also want to develop good skills i.e be good in what I am learning. So can anyone suggest me some startup projects? or scripts etc I can try to code, so I can be more good in programming. Regards,
  20. When I tried to run the downloaded SQL commands in phpMyAdmin, various error messages appeared, stating that no author table exists. So I searched for all occurrences of the word "author" and replaced them with "user", except for this line: `type` enum('public','author','admin') NOT NULL, Is this correct? The file I downloaded is: yiibook2_cms.sql.zip Thanks.
  21. I am wondering if there is a way to use this book without performing the complex joins that have UNION statements in them. I think it is chapter 9 or 10 of the book, the chapter that shows the most complex mysql statements. How could I go about using this book without using those complex mysql joins.
  22. Hello! I'm doing the appendix test PHP and SQL page and i keep getting a 'object not found' page. The requested URL was not found on this server. Can anyone fill in what i maybe doing wrong here. I checked the spelling it's not that.
  23. I want to get the primary key values of movie and actor table. When i selected values in radio button primary key has been created automatically to the movie and actor table. Now I want to get that primary key value and insert to the movie_actor table. my code connect.php <?php $dbc = mysqli_connect('localhost','root','black98765','db_name') OR die("Cannot connect to MySQL:" . mysqli_connect_error()); //insert into actor table $q = "INSERT INTO actor (name) VALUES ('$actor')"; //insert into movie table $q2 = "INSERT INTO movie (movie_name, release_year) VALUES ('$movie','$year')"; //movie_actor table $q3 = "INSERT INTO movie_actor (movie_no,actor_no,rate) VALUES ('$rate')"; //what value i need to put inside values for movie_no and actor_no? //connect and insert $q $r = mysqli_query($dbc,$q); $r2 = mysqli_query($dbc,$q2); $r3 = mysqli_query($dbc,$q3); if($r && $r2 && $r3){ echo "Inserted Successfully!"; }else{ echo "Failed to Insert Data!"; mysqli_error($dbc); } mysqli_close($dbc); ?> form.php <?php if(isset($_POST['submit'])){ if($_SERVER['REQUEST_METHOD'] == 'POST'){ $error = array(); //choose actor if(!isset($_POST['actor'])){ $error[] = "Please choose of the following actors!"; }else{ $actor = $_POST['actor']; } //choose movie if(!isset($_POST['movie'])){ $error[] = "Please choose of the following movies!"; }else { $movie = $_POST['movie']; } //choose release year if(!isset($_POST['year'])){ $error[] = "Please choose of the following release year!!"; }else{ $year = $_POST['year']; } //choose rate if(!isset($_POST['rate'])){ $error[] = "Please choose of the following rate!"; }else{ $rate = $_POST['rate']; } //if no errors if(empty($error)){ require('connect.php'); }else{ echo "<p>System Error!</p>"; foreach($error as $msg){ echo $msg."<br/>\n"; } } } } ?> <form action="form.php" method="POST"> <p>Select on the following Selections</p> <p><label for="actor">Name of Actor:</label> <input type="radio" name="actor1" value="Jet Li"/>Jet Li <input type="radio" name="actor2" value="Sylvester Stallone"/>Sylvester Stallone <input type="radio" name="actor3" value="Jason Statham"/>Jason Statham</p> <p><label for="movie">Name of Movie:</label> <input type="radio" name="movie1" value="Expendables 3"/>Expendables 3 <input type="radio" name="movie2" value="Rocky"/>Rocky <input type="radio" name="movie3" value="Kiss of the Dragon"/>Kiss of the Dragon</p> <p><label for="movie">Release Year:</label> <input type="radio" name="year1" value="2014"/>2014 <input type="radio" name="year2" value="1976"/>1976 <input type="radio" name="year3" value="2001"/>2001</p> <p><input type="submit" name="submit" value="Insert"/></p> </form>
  24. in the book it shows us how to drop an index by using the following sql statement. ALTER TABLE t DROP INDEX i i being the name of the index. I went into phpmyadmin and I don't see an option for removing an index unless there is a name attached to the index. If I would write an sql statement to drop the index how would I write it if the index doesn't have a name.
  25. Ok, so I imported the SQL code for the second site. Now im in the designer view so I can physically see everything. When I start to create the foreign key links it goes well until i try to link "non_coffee_products" to "sales". I successfully linked "specific_coffees" to "sales" and after I did I still could not link "non_coffee_products" to "sales", but this time I get Error: Relation already exists. So my questions are 1. Why wont the foreign key work between "non-coffee-products" and "sales"? 2. How do I link them both to "sales" if only one relation can be set up? Thank you for looking into my inquiry.
×
×
  • Create New...