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. In the following code I am validating a url in a practice page I am using from the stuff I learned in the book­. When I enter an invalid url in my form, I get an $url undefined error when running the code below. I am guessing the error is pretty easy to spot, but I am new at this. if (filter_var($scrubbed['url'], FILTER_VALIDATE_URL)){ $url = mysqli_real_escape_string($dbc, $scrubbed['url']); } else { echo '<p class="error">Please enter a valid url</p>'; }
  2. I am on Chapter 18, I created all the files and they seem to be all like it is written in the book, when I logout I can still see the user menu, if I click on one of the user links it takes me back to the index.php (some of the time) page which is great, meaning I am logged out. But why can I still see the Logged in User links even after I click on logout, sometimes when I click on the user links I can even get to the logged in page after I am logged out. I double checked my login and logout pages and they seem the same as in the book. Is this normal??
  3. hi i uploaded a website using the includes infrastructure exampled in this book my base uri for xamp is define ('BASE_URI', '/C:xamp/htdocs/'); and it works fine but im using filezilla to upload folders to my site hosting on go daddy and when i use my httpdocs path define ('BASE_URI', '/httpdocs/'); i get this error: PHP Fatal error: require(): Failed opening required '/httpdocs/mysql.inc.test.php' (include_path='.;.\includes;.\pear') in G:\PleskVhosts\axebs.com\httpdocs\index.php on line 16 any tips on what i need to set my path to to work on filezilla??
  4. i have to tables that are link and i want to view contents of a single item when i select it, what is the correct syntax of using $post in yii ie SELECT tbl_emp.emp_id, tbl_emp.sname, tbl_fname, tbl_educ.empl_id FROM tbl_emp, tbl_edu WHERE tbl_emp.emp_id=$_POST['emp_id'] AND tbl_edc.emp_id=$_PSOT['emp_id'];
  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. In page 99, session_regenerate_id() cause en error "Cannot regenerate session id - headers already sent". If i comment this function out, everything goes fine. Where I should check for problem? thanks
  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. Hello all, I am enjoying this book, and have had all success deploying the chapter 3 department select menu scripts on my local environment. When i try to implement the same when using a bootstrap style website, where the pages are outputted through the index.php file: https://mysite.com/index.php?page=dept_form&did=1 I run into problems. In your book on chapter 3 your dept.js file has the code pulling from (get, dept_results_ajax.php?did=' + encode...). Because of the bootstrap style site I am using will this be different? Also, does it matter if using https opposed to http? Any help would be great. Thanks
  11. I am almost finished the book, and I am not totally clear on how to use the $page_title variable that appears throughout the book, do we have to include the following code in the title tag of each php script in order to use $page_title. <?php echo $page_title; ?>. In most of the examples in this book the $page_title variable is used in the script without showing the code used in the title tag. Also since the $page_title variable appears below the title tag when I load the php script in my browser I get an error message saying that $page_title isn't a valid variable. Can someone explain to me how to properly use the $page_title variable when writing php scripts. Or is it just easier to write the title in the title tag without using this variable.
  12. I am attempting to develop a PHP script to record presence at an event for those persons in a mysql table Persons. I am attempting to use checkboxes to indicate who was present. Here is the script as currently written: <?php # Script require ('includes/mysqli_connect.php'); if(isset($_POST['checkbox'])) {$checkbox = $_POST['checkbox']; if(isset($_POST['activate'])?$activate = $_POST["activate"]:$deactivate = $_POST["deactivate"]); $id = "('" . implode( "','", $checkbox ) . "');" ; echo $id; $q="UPDATE Persons SET present = '".(isset($activate)?'Y':'N')."' WHERE id IN $id" ; $r = mysqli_query($dbc,$q) or die(mysqli_error()); } $q = "SELECT * FROM Persons"; $r = @mysqli_query ($dbc,$q); $count=mysqli_num_rows($r); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns=?http="//www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset="utf-8"" /> <title>Update multiple rows in mysql with checkbox</title> <script type="text/javascript"> <!-- function un_check(){ for (var i = 0; i < document.frmactive.elements.length; i++) { var e = document.frmactive.elements; if ((e.name != 'allbox') && (e.type == 'checkbox')) { e.checked = document.frmactive.allbox.checked; }}} //--> </script> </head> <body> <table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td><form name="frmactive" method="post" action="checkboxes.php"> <table width="400" border="0" cellpadding="3" cellspacing="1"> <tr> <td colspan="5"><input name="activate" type="submit" id="activate" value="Activate" /> <input name="deactivate" type="submit" id="deactivate" value="Deactivate" /></td> </tr> <tr> <td> </td> <td colspan="4"><strong>Update multiple rows in mysql with checkbox</strong> </td> </tr><tr> <td align="center"><input type="checkbox" name="allbox" title="Select or Deselect ALL" style="background-color:#ccc;"/></td> <td align="center"><strong>id</strong></td> <td align="center"><strong>first_name</strong></td> <td align="center"><strong>last_name</strong></td> <td align="center"><strong>present</strong></td> </tr> <?php while ($row = mysqli_fetch_array($r)) { ?> <tr> <td align="center"><input name="checkbox[]" type="checkbox" id="checkbox" id="checkbox[]" value="<? echo $rows['person_id']; ?>"></td> <td><? echo $row['person_id']; ?></td> <td><? echo $row['first_name']; ?></td> <td><? echo $row['last_name']; ?></td> <td><? echo $row['present']; ?></td> </tr> <?php } ?> <tr> <td colspan="5" align="center"> </td> </tr> </table> </form> </td> </tr> </table> </body> </html> The table Persons contains these columns: person_id, first_name,last_name,present. I inserted the echo line after the line defining $id which is copied below: $id = "('" . implode( "','", $checkbox ) . "');" ; echo $id; But $id only contains empty strings. Can anyone help me understand what I am doing wrong? Is $checkbox always ending up empty? Any direction will be appreciated. Wes Smith
  13. Can anyone provide me with a simple solution to the Pursue question in chapter 18, create a last_login field and make it so that a user can see how long it has been since they last logged in. thanks Graham
  14. Hi everyone. I've done everything I could think of to get Script 11.8 to work, but I keep getting the error message 'The username and password you entered do not match those on file'. The users.txt is where it should be (because it worked fine for register.php) and the script is almost exactly how it is in the book. I'm using the same user names and passwords as well. Is this happening because I'm on a Mac? Oh, I'm on PHP 5.3.6 and use XAMPP. <?php // Script 11.8 - login.php $file = '../users/users.txt'; if ($_SERVER['REQUEST_METHOD'] == 'POST') { // Handle the form. $loggedin = FALSE; // Not currently signed in. // Enable auto_detect_line settings: ini_set('auto_detect_line_endings', 1); // Open the file: $fp = fopen($file, 'rb'); // Loop through the file: while ( $line = fgetcsv($fp, 200, "\t") ) { // Check the file data against the submitted data: if ( ($line[0] == $_POST['username']) AND ($line[1] == md5(trim($_POST['password']))) ) { $loggedin = TRUE; // Correct username/password combination. // Stop looping through the file: break; } // End of IF. } // End of WHILE. fclose ($fp); // Close the file. // Print a message: if ($loggedin) { print '<p>You are now logged in.</p>'; } else { print '<p style="color: red;">The username and password you entered do not match those on file.</p>'; } } else { // Display the form. // Leave PHP and display the form: ?> <form action="login.php" method="post"> <p>Username: <input type="text" name="username" size="20" /></p> <p>Password: <input type="password" name="password" size="20" /></p> <input type="submit" name="submit" value="Login" /></form> <?php } // End of submission IF. ?> </body> </html>
  15. 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
  16. 2 problems with my code, the filter_var doesn't seem to work at all for any of my variables, also the spam_scrubber function doesn't seem to clean \r, and \n, when put in my contact form, it cleans all the rest though just fine. <?php // resources.php function spam_scrubber($value){ $very_bad = array('to:', 'cc:', 'bcc:', 'content-type:', 'mime-version:', 'multipart-mixed:', 'content-transfer-encoding:'); foreach ($very_bad as $v){ if (stripos($value, $v) !== false) return ''; } $value = str_replace(array( "\r", "\n", "%0a", "%0d"), ' ', $value); return trim($value); }//end of spam_scrubber function $scrubbed = array_map('spam_scrubber', $_POST); $comments = strip_tags($scrubbed['comments']); $url = $scrubbed['url']; if (isset($url)){ filter_var($url, FILTER_VALIDATE_URL, FILTER_SANITIZE_URL); } else { echo NULL; } $url2 = $scrubbed['url2']; if (isset($url2)){ filter_var($url2, FILTER_VALIDATE_URL, FILTER_SANITIZE_URL); } else { echo NULL; } $linkpageurl = $scrubbed['linkpageurl']; if (isset($linkpageurl)){ filter_var($linkpageurl, FILTER_VALIDATE_URL, FILTER_SANITIZE_URL); } else { echo NULL; } $linkpageurl2 = $scrubbed['linkpageurl2']; if (isset($linkpageurl2)){ filter_var($linkpageurl2, FILTER_VALIDATE_URL, FILTER_SANITIZE_URL); } else { echo NULL; } $email = $scrubbed['email']; if (isset($email)){ filter_var($email, FILTER_VALIDATE_EMAIL, FILTER_SANITIZE_EMAIL); } else { echo NULL; } $pagerank = $scrubbed['pagerank']; if (isset($pagerank)){ filter_var($pagerank, FILTER_VALIDATE_INT, FILTER_SANITIZE_NUMBER_INT); } else { echo NULL; } if (!empty($email) && !empty($url) && !empty($linkpageurl) && !empty($comments) && !empty($pagerank)){ $body = "Email: {$email}\n\n Url: {$url}\n\n Url2: {$url2}\n\n Pagerank: {$pagerank}\n\n Linkpageurl: {$linkpageurl} \n\n Linkpageurl2: {$linkpageurl2}\n\n Comments: {$comments}"; $body = wordwrap($body, 70); $headers = "From: {$email}\r\n"; mail('email@example.com', 'Link Exchange Form Submission', $body, $headers); echo '<p><em>Thank you for contacting us.</em></p><div id="formecho"><h3>Form submission received, we will get back to you soon.</h3></div>'; $_POST = array(); } else { echo '<p style="font-weight: bold; color: #C00">Please fill out the form completely.</p>'; } ?> <div id="form"> <form action="linkexchangecontactform2.php" method="post"> <p><b>Email:</b> <input type="text" size="30" maxlength="50" name="email" value="<?php if(isset($scrubbed['submit']))echo $scrubbed['email']; ?>" /></p> <p><b>Url:</b> <input type="text" size="30" maxlength="50" name="url" value="<?php if(isset($scrubbed['url']))echo $scrubbed['url']; ?>" /></p> <p><b>2nd Url (leave empty if you have just 1 website):</b><br /> <input type="text" size="30" maxlength="50" name="url2" value="<?php if(isset($scrubbed['url2']))echo $scrubbed['url2']; ?>" /></p> <p><b>Pagerank:</b> <input type="text" size="5" maxlength="10" name="pagerank" value="<?php if(isset($scrubbed['pagerank']))echo $scrubbed['pagerank']; ?>" /></p> <p><b>Link page url:</b> <input type="text" size="30" maxlength="50" name="linkpageurl" value="<?php if(isset($scrubbed['linkpageurl']))echo $scrubbed['linkpageurl']; ?>" /></p> <p><b>2nd Link page url (leave empty if you have just 1 website):</b><br /> <input type="text" size="30" maxlength="50" name="linkpageurl2" value="<?php if(isset($scrubbed['linkpageurl2']))echo $scrubbed['linkpageurl2']; ?>" /></p> <p><b>Comments:</b><br> <textarea name="comments" rows="7" cols="40"><?php if (isset($scrubbed['comments'])) echo $scrubbed['comments']; ?></textarea></p> <p><input type="submit" name="submit" value="Submit" /></p> </form></div>
  17. I want to create a contact form that has an email field where the user can't enter any white space in the field, for example: test@ex ample.com I am using a spam scrubbing function taught to us in the book to clean user inputs. I am using my variable like so. $email = strip_tags($scrubbed['email']); how can I add something like this $email = preg_replace('/\s+/', '', $email); to the existing $email = strip_tags($scrubbed['email']); I tried $email = (preg_replace('/\s+/', '', $email)(strip_tags($scrubbed['email']))); and all sorts of variations to that. it doesn't work.
  18. 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.
  19. I think my PEAR install is working and got the phpDocumentor installed but now get an error using it. "phpDocumentor.EMERGENCY: phpDocumentor detected that a requirement is missing in your system setup: The XSL writer was unable to find your XSLTProcessor: please check if you have installed the PHP XSL extension or XSLC ache extention." I have a windows 7 home premium 64 bit laptop with WAMP. My Wamp 2.2 settings are Apache: 2.2.22, PHP: 5.3.13, and MySQL: 5.5.24. I checked in my php.ini file from the wamp icon in my toolbar and it has the XSL extension on. What can I do now to get the phpDocumentor to work? Thanks.
  20. Hi, After following Larry's book and getting the helps from this forum, I finally get my first web project done. It has 4k product items and 1.5k users in the database. The website is fully functional in localhost. I carefully checked and killed all of bugs. Seems everything running without problem. So I need to looking into how to upload this project to the web host. I have never done anything like that before, so I am not sure what thing will go wrong and what things will screw up the project I have spent a year into. Please give some idea of what to avoid. I assume I just export the sql file from my local database and import it into web database with same name, and straightly upload all file in local host into web host. Change the BASE_URL value to web URL, and that will be all I need to do?
  21. Hi, Here the case is when user clicks a link, if he/she is not signed in yet, then he/she will be redirected to a login page. After the user successfully logged in, user should be redirected to the page url he/she intended to visit. I have no clue how to do this, but I found article online suggesting to store url into $_SESSION array before user has logged in. So I tried to store what url visitor clicked into $_SESSION['targetPage'], then redirect to login page. When user does a successful login, then $_SESSION ['targetPage'] is plugged into header function to redirect user back to the page intend. This method doesn't work, but I think the direction might be right. So please kindly give me some thought how to make this working. thank you very much! if(!isset($_SESSION['user_id'])){ // try storing the url that user clicked in $_SESSION $_SESSION['targetPage'] = $_SERVER['REQUEST_URI']; $url = 'login_page.php'; header("Location: $url"); exit(); } else { // save the session user id into $user_id $user_id = $_SESSION['user_id']; }
  22. 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>
  23. HI, again I tried to use the array looping technique from PHP advance book (chapter 1) on my project to output products category into <ul><li> list then apply superfish menu on them. But the output created extra <a>element which slightly messed up the superfish menu. I double check the make_list() function script and I can't tell why the extra <a> tabs are created. the code: <?php require ('includes/config.inc.php'); require (MYSQL); function make_list($parent) { global $cat_list; echo '<ul>'; foreach($parent as $catid => $c_list){ echo "<li>"; echo "<a href=\"index.php?cid=$catid\">"; echo $c_list; if(isset($cat_list[$catid])){ //$catid = parent_id make_list($cat_list[$catid]); } echo '</a></li>'; } echo '</ul>'; //close the ordered list } // end of make_list function $query = "SELECT cc.category_id, cc.parent_id, c.category FROM categories AS c INNER JOIN category_categories AS cc USING (category_id) WHERE c.publish = 1"; $result = mysqli_query($dbc, $query); if(!$result) echo mysqli_error($dbc); if(mysqli_num_rows($result)>=1){ $cat_list = []; while (list($c_id, $p_id, $cat) = mysqli_fetch_array($result, MYSQLI_NUM)){ $cat_list[$p_id][$c_id] = $cat; } } make_list($cat_list[0]); ?> the problem output(first few lines) <ul> <li> <a href="index.php?cid=1">Box Collection</a> <ul> <a href="index.php?cid=1"></a> <li> <a href="index.php?cid=1"></a> <a href="index.php?cid=32">Classic Preminum Brown Hardwood Boxes</a> </li> <li> <a href="index.php?cid=35">Hat Boxes</a> </li> <li> <a href="index.php?cid=36">Leatherette Boxes</a> </li> I expect the output to be: <ul> <li> <a href="index.php?cid=1">Box Collection</a> <ul> <li> <a href="index.php?cid=32">Classic Preminum Brown Hardwood Boxes</a> </li> <li> <a href="index.php?cid=35">Hat Boxes</a> </li> <li> <a href="index.php?cid=36">Leatherette Boxes</a> </li> From the make_list() function, which seems fine, I can't tell why the extra <a> is created. Please anyone can tell where is the problem?
  24. Hi, Larry In your Modern Javascript book, there is a dynamic select menu for picking operation system. Is that possible to create a similar menu in php? or manipulate that menu with php. I have 2 tables table 1: category contains category_id, category table 2: category_categories contains id, category_id, parent_id so I want to create a primary menu to have all categories that the parent_id equals to 0 (the top), when user select a category from primary menu, the subcategory menu become selectable and load the subcategory under the primary category that user has selected. Thank you all
  25. 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
×
×
  • Create New...