PHP - Sort By Category Function. How Can I Solve It More Efficiently?
Since I'm new to programming I still don't know how to solve problems the most efficient way, I'd like to have your advice on this one. This is how I solved it and it works.
I have my categories as input buttons (I'm planning to change it into a drop down menu later). Sort by Category: <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <input type='submit' name='All' value='All' /> <input type='submit' name='Smileys' value='Smileys' /> <input type='submit' name='Faces' value='Faces' /> <input type='submit' name='Love' value='Love' /> </form> When the input boxes are clicked the corresponding script below is being run, very simple and to a point primitive, definitely not really efficient, because if you have a lot of categories you'll end up with a lot of code and if you wanted to change one thing you'd have to change it in all the IF BLOCKS. Basically every input button has its own IF BLOCK. <?php if (isset($_POST['All']) OR (!isset($_POST['Smileys']) && !isset($_POST['Faces']) && !isset($_POST['Love']) { // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); // Retrieve the score data from MySQL $query = "SELECT * FROM asciiart"; $data = mysqli_query($dbc, $query); // Loop through the array of score data, formatting it as HTML while ($row = mysqli_fetch_array($data)) { echo '<table class="asciiartTable">'; // Display the score data echo '<tr><td class="asciiart_name">'; echo '<strong>' . htmlentities($row['asciiart_name']) . '</strong><br /></td></tr>'; echo '<tr><td class="asciiart_contribution"><pre>' . htmlentities($row['asciiart_contribution']) . '</pre><br /></td></tr>'; echo '<tr><td class="asciiart_categoryDate">' . htmlentities($row['asciiart_category']) . ' | ' . date('M d, Y', strtotime ($row['created_date'])) . ' </td></tr>'; echo '</table>'; } mysqli_close($dbc); } if (isset($_POST['Smileys'])) { // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); // Retrieve the chosen category from MySQL $query2 = "SELECT * FROM asciiart WHERE asciiart_category = 'Smileys'"; $data2 = mysqli_query($dbc, $query2); //Loop through the array of data while ($row2 = mysqli_fetch_array($data2)) { echo '<table class="asciiartTable">'; // Display the score data echo '<tr><td class="asciiart_name">'; echo '<strong>' . htmlentities($row2['asciiart_name']) . '</strong><br /></td></tr>'; echo '<tr><td class="asciiart_contribution"><pre>' . htmlentities($row2['asciiart_contribution']) . '</pre><br /></td></tr>'; echo '<tr><td class="asciiart_categoryDate">' . htmlentities($row2['asciiart_category']) . ' | ' . date('M d, Y', strtotime ($row2['created_date'])) . ' </td></tr>'; echo '</table>'; } mysqli_close($dbc); } if (isset($_POST['Faces'])) { // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); // Retrieve the chosen category from MySQL $query3 = "SELECT * FROM asciiart WHERE asciiart_category = 'Faces'"; $data3 = mysqli_query($dbc, $query3); //Loop through the array of data while ($row3 = mysqli_fetch_array($data3)) { echo '<table class="asciiartTable">'; // Display the score data echo '<tr><td class="asciiart_name">'; echo '<strong>' . htmlentities($row3['asciiart_name']) . '</strong><br /></td></tr>'; echo '<tr><td class="asciiart_contribution"><pre>' . htmlentities($row3['asciiart_contribution']) . '</pre><br /></td></tr>'; echo '<tr><td class="asciiart_categoryDate">' . htmlentities($row3['asciiart_category']) . ' | ' . date('M d, Y', strtotime ($row3['created_date'])) . ' </td></tr>'; echo '</table>'; } mysqli_close($dbc); } if (isset($_POST['Love'])) { // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); // Retrieve the chosen category from MySQL $query4 = "SELECT * FROM asciiart WHERE asciiart_category = 'Love'"; $data4 = mysqli_query($dbc, $query4); //Loop through the array of data while ($row4 = mysqli_fetch_array($data4)) { echo '<table class="asciiartTable">'; // Display the score data echo '<tr><td class="asciiart_name">'; echo '<strong>' . htmlentities($row4['asciiart_name']) . '</strong><br /></td></tr>'; echo '<tr><td class="asciiart_contribution"><pre>' . htmlentities($row4['asciiart_contribution']) . '</pre><br /></td></tr>'; echo '<tr><td class="asciiart_categoryDate">' . htmlentities($row4['asciiart_category']) . ' | ' . date('M d, Y', strtotime ($row4['created_date'])) . ' </td></tr>'; echo '</table>'; } mysqli_close($dbc); } My question is: is there a way to have just one block of script and the script automatically inserts the right INPUT BUTTON into the query in the script? Something similar to this, even though it doesn't work I'm just showing it for showcase purposes: if (isset($_POST['Smileys']) || (isset($_POST['Faces']) || (isset($_POST['Love'])) { // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); // Retrieve the chosen category from MySQL $query2 = "SELECT * FROM asciiart WHERE asciiart_category = 'Smileys' || 'Faces' || 'Love'"; $data2 = mysqli_query($dbc, $query2); Notice in the query, it is looking for THAT keyword that has been PRESSED on the INPUT BUTTON. How would I be able to create a logic like this so I can create a whole chain of categories? Thanks for advice. Similar TutorialsHello everyone, I am currently working on the script taken from www.phpwebcommerce.com I am only a beginner and have been using it in a little project for an online game just to help my mates be able to trade items and such. I have managed to get almost everything sorted apart from one thing. The function which gets the categories for a drop down select box: Code: [Select] /* Generate combo box options containing the categories we have. if $catId is set then that category is selected */ function buildCategoryOptions($catId = 0) { $sql = "SELECT cat_id, cat_parent_id, cat_name FROM tbl_category ORDER BY cat_id"; $result = dbQuery($sql) or die('Cannot get Product. ' . mysql_error()); $categories = array(); while($row = dbFetchArray($result)) { list($id, $parentId, $name) = $row; if ($parentId == 0) { // we create a new array for each top level categories $categories[$id] = array('name' => $name, 'children' => array()); } else { // the child categories are put int the parent category's array $categories[$parentId]['children'][] = array('id' => $id, 'name' => $name); } } // build combo box options $list = ''; foreach ($categories as $key => $value) { $name = $value['name']; $children = $value['children']; $list .= "<optgroup label=\"$name\">"; foreach ($children as $child) { $list .= "<option value=\"{$child['id']}\""; if ($child['id'] == $catId) { $list.= " selected"; } $list .= ">{$child['name']}</option>\r\n"; } $list .= "</optgroup>"; } return $list; } Basically the problem is that it only creates a category list of two levels e.g. Parent Child and I wish to be able to have more sub categories e.g. Parent Child Child Child Is there anyway of adapting this code so it can do something like that? Many thanks for any help. The web application should allow the user to view the items in a catalogue, add items to a shopping cart, remove items from the shopping cart, and to view the contents of the shopping cart. Hey guys. Right ill try explain as best i can. Basicly we were told to write a php script that can view a shopping cart. The items in the catalogue should be stored as an array of objects. (The next assignment will require you to store this list of objects in a database). There should also be pages to allow the user to add, edit and delete items in the catalogue. Thats taken from a brief.Ive spent the most of the week getting it to view a catalog and now it can add items.view the cart its added them to and remove them from the cart and return. What im having trouble with is making the add function for the the other users or admin* to add/edit/delete.i reckoned adding and deleting wouldnt be so bad considering ive alrready done so.But im kinda stumped on how to do it.i think what the brief wanted was a seprate product add that would actully let u add another product to the cart list on the same page and then u can add that to the shopping basket etc. Yea real stumped.if only it was through sql it would be so much handier. ill post the code below.if anyone can help at all in the slightest id be so grateful.Thank you. Hello, I have been searching and trying all sorts of ways to get my sub categories drop down to show the correct info after selecting a category from the main drop down but im getting stuck. It's pulling the categories and sub categories from the mysql database fine but no matter which main category i pick it keeps showing the same result in the sub category. My brother said i need to use some sort of onchange do this so the sub category list refreshs but everything i have tried doesn't work.. PLEASE could some one help. MANY MANY THANKS This is the category form Code: [Select] <select name="job_cats" style="width:165px"> <?PHP $query1 = "SELECT * FROM job_cats"; $result1 = mysql_query($query1) or die ("query 1 failed"); $count1 = mysql_num_rows($result1); for ($i = 0; $i < $count1; $i++) { $row1 = mysql_fetch_array($result1); $job_cats_title1 = $row1['title']; $job_cats_id1 = $row1['id']; echo '<option value="'.$job_cats_id1.'">'.$job_cats_title1.'</option>'; echo $job_cats_id1; } ?> </select> this would echo this in the main category list: cat1 cat2 cat3 cat4 this is the sub category form Code: [Select] <select name="job_sub_cats" style="width:165px"> <?PHP $query1 = "SELECT * FROM job_sub_cats WHERE job_cats_id = $job_cats_id1"; $result1 = mysql_query($query1) or die ("query 1 failed"); $count1 = mysql_num_rows($result1); for ($i = 0; $i < $count1; $i++) { $row1 = mysql_fetch_array($result1); $sub_cats_id1 = $row1['id']; $sub_cats_title1 = $row1['subTitle']; $cats_id1 = $row1['job_cats_id']; echo '<option value="'.$sub_cats_id1.'">'.$cats_id1.'</option>'; } ?> </select> this should echo this: 1 2 3 4 but it keeps echoing just the number 4. THANKS PLEASE HELP ricky Would anyone have the answer to solve this error message? Deprecated: Function split() is deprecated in /includes/modules/shipping/table.php on line 57 Here is the code. Line 57 is in Bold. Preg_split is suppose to work. Tried preg_explode but that didn't work. Appreciate any help! $table_cost = preg_split("/[:,]/" , MODULE_SHIPPING_TABLE_COST); $size = sizeof($table_cost); for ($i=0, $n=$size; $i<$n; $i+=2) { if ($order_total <= $table_cost[$i]) { $shipping = $table_cost[$i+1]; break; } } Hi All i am wanting a column list like this http://extensions.joomla.org/extensions basically the database is set up as (id, category, parent) I want the parent to group the category section and list like the the joomla example in three columns search various threads throughout the internet but none seem to cover this entirely can any one please help????? I'll start by apologizing for the stupid decision that led to this question. A few years ago, I created a PHP/Myysql site with a login system and I created a field in the MySQL called "password" and it stored literally the exact password people entered (I know, I know).
The site has proven to have nice traffic potential, so I am going to re-vamp everything, including storing passwords properly (i.e. hashed).
My first question... Is there a way to convert regular text passwords to hashed passwords? For example, I could create a new field in the "User" table for "hashedpassword" and write a script that takes all the insecure passwords and turns them into hashed passwords. Then deleted the previous "bad" password field from the database. This would allow me to do it without the customer every knowing anything changed.
Quick googling appears to support that it IS doable rather easily, with something like...
UPDATE mytable SET password = MD5(password)If not, I guess I would have to create a thing where the first time omeone logged in after I put hashing in place, the site would force them to change their password. I'd rather not annoy the visitors if it all possible. Second question, what is the proper/recommended hashing method to use? Some people seem to poo-poo MD5. If you agree, should I use: MD5 SHA MD5 with a salt SHA with a salt Something else i never heard of NOTE: My site is a fantasy sports site, so the data involved is not overly important. Maybe a salt is overkill? Or is being overly safe never a bad thing? Lastly, don't need to address this, but if anyone can explain it like I'm 5 that would be great because i must be missing something... if you can easily turn a regular password into a hashed password, couldn't hackers easily do the reverse, which would render the hashing almost useless? I get that salting helps, but before salting (i.e. doing ONLY MD5), I don't see how hashing helped that much (if you could reverese figure out the password). What am I missing? Thanks! Greg Edited by galvin, 13 November 2014 - 09:44 AM. PHP Websockets Rate limiter (Thanks to @Kicken for the help) How do I setup let's say... no more than 5 requests per second? Any idea? // anti flood protection if (isset($users[$clientID]['last_session_request'])) { if($users[$clientID]['last_session_request'] > ''.microtime(true).'' - 1){ // users will be redirected to this page if it makes requests faster than 1 seconds echo "Limit Reached... Simmer down!"; wsClose($clientID); }else{ } $users[$clientID]['last_session_request'] = microtime(true); } Edited by Monkuar, 20 December 2014 - 03:28 PM. I'm hoping to get a little feedback on what you all believe is the best way to handle this efficiently in PHP. I am working on a script that imports a large amount of data from remote feeds; this facilitates the quick deployment of real estate web sites, but has to download a large number of images to each new site. Assuming for right now that the bottleneck isn't in the method (fsock vs curl vs...) and that for each imported listing we're spending between .89439 and 17.0601 seconds on the image import process alone... what would you suggest for handling this over the space of 100-1000 occurrences? As of right now I have two ideas in mind, both fairly rudimentary in nature. The first idea is to shut the script down every 30-45 seconds, sleep for a second and fire off another asynchronous request to start the script again. The second idea is to fire off a new asynchronous to run the image imports separate from the main script. This would let the efficient ones clear out rather quickly while the slower imports would have their own process to run in. The only thing that worries me about this is the fact that 100 of these could be fired off every second. Even assuming half of them complete before the next round are fired off, they would still pile up. This is how it should look. basic xml file http://wiistream.net/php/user/pictures/gallery.xml but this is how it looks. http://wiistream.net/php/user/pictures/gallery.php?username=Mancent&user_folder=Mancent_Pictures mysql php xml file with category's. This is whats making it so hard the category's Im using 3 tables one table is for my friends and one table is the category folder name and the other table is the picture holder with the category folder name so I thought i could do a if statement if user_folder = user_folder from the two tables it would keep the correct images in the correct category. But 3 weeks later still no luck. Heres what I got so far. <?php //lets get the mysql connection information. include "../../connect.php"; //we need this because the flash stores the xml file in temp internet history. Header('Cache-Control: no-cache'); Header('Pragma: no-cache'); //ok flash sent out the username $username = mysql_real_escape_string($_GET['username']); //ok flash sent out the folder name $user_folder = mysql_real_escape_string($_GET['user_folder']); $user_folder = (isset($_GET['friend'])) ? ' AND b.user_folder = \'' . mysql_real_escape_string($_GET['user_folder']) . '\' ' : NULL; //this part will be used becasue we need to see if friendship has ben made. $friend = (isset($_GET['friend'])) ? ' AND b.friend = \'' . mysql_real_escape_string($_GET['friend']) . '\' ' : NULL; //Ok lets select the username from the accounts table to see if they are a user.. $get_username = "SELECT * FROM accounts WHERE username = '$username'"; $username_results = mysql_query($get_username) or die("Data not found."); //Get the number of results from the query. $check_username_mysql_rows = mysql_num_rows($username_results); //If there is a match for the username, echo the the users xml data. if($check_username_mysql_rows == 1) { $sql1 = "SELECT a.username,a.user_folder,b.username FROM user_image_folders as a JOIN `user_friends_list` as b ON (b.friend = a.username)WHERE (b.username = '$username' $user_folder $friend AND b.status = 1)"; $result1 = mysql_query($sql1); //TODO MAKE THE FRIENDSHIP WORK WITH THIS $sql = "SELECT a.username,a.user_folder,a.user_folder,a.large_pic,a.small_pic,a.pic_title,a.pic_discription,b.username FROM user_photo_gallery as a JOIN `user_friends_list` as b ON (b.friend = a.username)WHERE (b.username = '$username' $user_folder $friend AND b.status = 1)"; $result2 = mysql_query($sql); $user_xml = "<?xml version=\"1.0\"?>\n"; $user_xml .= "<settings>\n"; $user_xml .= "<sceneHeight>600</sceneHeight>\n"; $user_xml .= "<sceneWidth>1000</sceneWidth>\n"; $user_xml .= "<titleColor>#000000</titleColor>\n"; $user_xml .= "<descriptionBgAlpha>70</descriptionBgAlpha>\n"; $user_xml .= "<showFullscreenBtn>no</showFullscreenBtn>\n"; $user_xml .= "<waterMark useImage=\"no\"><![CDATA[THIS]]></waterMark>\n"; $user_xml .= "</settings>\n"; $user_xml .="<galleries>\n"; //{ while ($i_get_myfriends = mysql_fetch_assoc($result1)) { $user_xml .="<gallery theName=\"". $i_get_myfriends['user_folder'] ."\" itemsPerRow=\"3\" autoStart=\"no\" playTime=\"5\" autoResize=\"yes\" xOffset=\"5\" yOffset=\"10\" showTitleOnThumbs=\"yes\" allowDownload=\"yes\">\n"; while ($i_get_myfriends2 = mysql_fetch_assoc($result2)) { //if($i_get_myfriends['user_folder'] ==$i_get_myfriends2['user_folder']) //{ $user_xml .="<picture largePicture=\"". $i_get_myfriends2['large_pic'] ."\" smallPicture=\"". $i_get_myfriends2['small_pic'] ."\" theTitle=\"". $i_get_myfriends2['pic_title'] ."\"><![CDATA[". $i_get_myfriends2['pic_discription'] ."]]>\n"; $user_xml .="</picture>\n"; //} } $user_xml .="</gallery>\n"; } $user_xml .="</galleries>\n"; echo $user_xml; } else { echo "Wiistream Eorror!\n"; } ?> See all the images are going into one folder.. and they are sopost to go into the friends folder it they are the friends pictures. but they are all in my folder.. Can some PHP guru help me with this scenarios? I've been wondering around these for hours and can't find my way around it. Please... 1. Write a function in PHP that takes three parameters (representing day, month and year) and calculates the day/month/year of the following day (for example, if the parameter is 31/10/2010, the result should be 01/11/2010). No need to take into account leap years. You cannot use any date/time specific functions, you must do it "by hand" (no built-in functions).. 2. Write a function in PHP that takes a string and counts the number of occurrences of any given letter in it (for example, given the string "HELLO" as a parameter, there are two occurrences of "L", one of "H", one of "E", one of "O" and zero of any other character). Code: [Select] Warning: SimpleXMLElement::addChild() [simplexmlelement.addchild]: unterminated entity reference limit=50&method=GET&access_token=AAACd5Mcn7VQBAKaupEZCocujRuoBzzWeZCj945ZApHEsv5BZAxZCJfS62cSSz4txlZBUZAec03GcjpHdk0NTotnglt2ZB41GzzeYl8xqIZBmsvlS6UZAoHZB1A4&offset=50 in /home/content/71/8432771/html/facebook/get/friends.php on line 62 Code: [Select] <?php /** * Copyright 2011 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. You may obtain * a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. */ require '../../src/facebook.php'; // Create our Application instance (replace this with your appId and secret). $facebook = new Facebook(array( 'appId' => 'APPID', 'secret' => 'SECRET', )); // Get User ID $user = $facebook->getUser(); // We may or may not have this data based on whether the user is logged in. // // If we have a $user id here, it means we know the user is logged into // Facebook, but we don't know if the access token is valid. An access // token is invalid if the user logged out of Facebook. if ($user) { try { // Proceed knowing you have a logged in user who's authenticated. $user_profile = $facebook->api('/me/friends?fields=id,name,first_name,last_name,picture&limit=50'); } catch (FacebookApiException $e) { error_log($e); $user = null; } } // Login or logout url will be needed depending on current user state. if ($user) { $logoutUrl = $facebook->getLogoutUrl(); } else { $loginUrl = $facebook->getLoginUrl(); } $profile = array ($user_profile); $xml = new SimpleXMLElement('<root/>'); arrayToXML( $xml, $profile ); echo $xml->asXML(); function arrayToXML( SimpleXMLElement &$xml, $array ) { foreach( $array as $name => $value ) { if( !is_array($value) ) $xml->addChild( $name, $value ); else { $child = $xml->addChild( $name ); <----------------------------------------------LINE 64 arrayToXML( $child, $value ); } } } ?> Here is the array Code: [Select] { "data": [ { "name": "Pauline Latty", "id": "312293" }, { "name": "Noah Ethan Schinasi", "id": "55101245" }, { "name": "Luis Guerrero", "id": "194803212" }, { "name": "Nakia Johnson", "id": "500350828" }, { "name": "Bethany Vallerie", "id": "502062429" }, { "name": "Caroline Franks", "id": "505331027" }, { "name": "Andrew Shivers", "id": "505749817" }, { "name": "Sandra G Garcia", "id": "508006303" }, { "name": "Catherine Davis", "id": "511006416" }, { "name": "Marc Watson", "id": "511201074" }, { "name": "Laura Clarke", "id": "513653820" }, { "name": "Amanda Rice", "id": "514062403" }, { "name": "Scott Alan Buss", "id": "514197867" }, { "name": "Evangelist Josephus", "id": "515837621" }, { "name": "Chet Fontenot", "id": "516199085" }, { "name": "Sharon Howard", "id": "516580144" }, { "name": "Chatt Franco", "id": "517211511" }, { "name": "Lydgia Vanessa Staples", "id": "518094760" }, { "name": "Corry Bell", "id": "521043483" }, { "name": "Lessie Tyson", "id": "521855454" }, { "name": "Jawahar Peter", "id": "523159934" }, { "name": "Sheena Shiko", "id": "523461577" }, { "name": "Pat Larry Thomas", "id": "523555768" }, { "name": "Oyenuga Kunle Johnson Matthew", "id": "524263978" }, { "name": "Angela Whitten", "id": "524631356" } ], "paging": { "next": "https://graph.facebook.com/me/friends?limit=25&access_token=2227470867|2.AQAMMvJya05xkLhR.3600.1318057200.0-100001957015772|IUAhNlekyalf7sxy-OjdJd7KCwo&offset=25" } } its that paging, I can not seem to get that to work yet. Hello guys, I'm trying to solve my hometask . I tried in many different ways to solve the task related with Advanced SQL Syntax. Please check the pic below: The Quiz is asking for make location appear in all uppercase letters, the character associated with a given ASCII value and the table is people. I tried the last one in this way: SELECT CONCAT(name,'is from',strtoupper(location),' The ASCII character of the number ',number,' is ',ASCII(number)) FROM `people` WHERE 1 but it doesn't work. Can someone help me? Thanks
<!DOCTYPE html> <html> <body> <form action="Practice 1.1.php" method="post"> Catagory Code:<input type="text" name="n" size="2"><br> Units Used <input type="text" name="u" size="2"> <br> <input type="submit" value="Calculate"> </form> <?php $a=$_POST['n']; $b=$_POST['u']; if ($b<=3.75) { echo ""; } ?> </body> </html>
My code is $answer = (1/212500); output is 4.90205690308E-6 while I need I output as 0.00000470588 Please help, and tell me what is the specific problem, This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=306725.0 Hey.. hoping someone can help me on a this issue I have been having for 4 days now. My host has tried to figure out what is causing it and has told me they are finding it very strange, everytime my website is up on their server it will take 600%-800% CPU so they must take it down for fair usage on other customers of course. They said they can easily track and trace websites that are overloading the resources but mine seems too complicated to understand as it is having legitmate traffic (on average 30 users online and 300 visits daily) which would never be the cause of CPU spikes to 600%-800%. They either believe it is a "clever attack" or some PHP script perhaps looping like mad. Anyone help me and my host figure out the problem as we obviously both don't like the website to continue to be offline. The website has very standard content CMS running and clean database it makes no sense to the both of us. Like to mention the last activity I had done on the website was when I tried to insert into database:- Code: [Select] Query failed: errorno=126 error=Incorrect key file for table './teamxcom_webspell/ws_bi2_cup_matches.MYI'; try to repair it query=DELETE FROM ws_bi2_cup_matches WHERE matchno='5' && type='gs' && ladID='0' && 1on1='1' Then after I tried to perform query from database: Code: [Select] Error SQL query: SELECT * FROM `ws_bi2_cup_matches` ORDER BY `ws_bi2_cup_matches`.`matchID` DESC LIMIT 0 , 30 MySQL said: #1030 - Got error 134 from storage engine Then found out the table on phpmyadmin had wrong page numbers in sequence:- 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 379, 746, 1113, --, --, --7349 After I contacted web host they mentioned it is causinga massive problem and took it down after that. Anyone can shed some light on this please? Sorry if it is posted in wrong section! Thanks very much Hi, My hosting company (Bluehost) told me when someone goes to my home page, it sends these series of queries and this is the reason for my high cpu usage and this is why my site says Error Establishing Database. The hosting company gave me these: Each script is using a decent about of CPU. [2:09:33 AM] hollane3 31881 6.2 0.1 186084 49000 ? RN 01:59 0:26 | \_ /ramdisk/bin/php5 /home4/hollane3/public_html/index.php hollane3 934 6.6 0.1 184012 48652 ? RN 01:59 0:25 | \_ /ramdisk/bin/php5 /home4/hollane3/public_html/index.php hollane3 5344 7.1 0.1 184008 48440 ? RN 02:01 0:21 | \_ /ramdisk/bin/php5 /home4/hollane3/public_html/wp-cron.php hollane3 5164 7.1 0.1 186444 48772 ? RN 02:01 0:22 | \_ /ramdisk/bin/php5 /home4/hollane3/public_html/index.php hollane3 7246 6.9 0.1 184116 48196 ? RN 02:02 0:18 | \_ /ramdisk/bin/php5 /home4/hollane3/public_html/index.php hollane3 11221 5.8 0.1 185160 47852 ? RN 02:03 0:09 | \_ /ramdisk/bin/php5 /home4/hollane3/public_html/index.php hollane3 11236 6.4 0.1 182992 47620 ? RN 02:03 0:10 | \_ /ramdisk/bin/php5 /home4/hollane3/public_html/wp-cron.php hollane3 12595 5.4 0.1 183088 47264 ? RN 02:04 0:07 | \_ /ramdisk/bin/php5 /home4/hollane3/public_html/index.php hollane3 13969 5.4 0.1 184648 47396 ? RN 02:04 0:05 | \_ /ramdisk/bin/php5 /home4/hollane3/public_html/index.php hollane3 14161 6.1 0.1 182480 47140 ? RN 02:04 0:06 | \_ /ramdisk/bin/php5 /home4/hollane3/public_html/wp-cron.php hollane3 14198 6.7 0.1 183092 47204 ? RN 02:04 0:06 | \_ /ramdisk/bin/php5 /home4/hollane3/public_html/index.php hollane3 16343 4.9 0.1 181968 46496 ? RN 02:05 0:02 | \_ /ramdisk/bin/php5 /home4/hollane3/public_html/index.php I am not well versed with scripting, so I don't know what this mean. Can anyone PLEASE help me to answer these questions: + Is this related to a particular plugin or widget or theme? + What could be the possible source of this issue, that is, which file should I look at to resolve this? + Can I fix this myself or do I need a php coder to help me? Thanks! I have following errors in below coding. Can anyone point out me where i went wrong?? Undefined variables: fname,focu,foad,ftp,fmf,mname,mocu,moad,mtp,mmf,gname,gocu,goadd,gtp,gmf in C:\wamp\www\Student registration\manage studnt parent details\manageStudentRegistrationParentDetailsForm.php manageStudentRegistrationParentDetailsForm.php Code: [Select] <?php $query="SELECT state,name,occupation,office_address,office_telephone,mobile_number FROM parent_info where admission_no='$admission_no'"; $result=mysql_query($query); while($row=mysql_fetch_array($result)){ $first=$row['state']; if($first=='father'){ $fname=$row['name']; $focu=$row['occupation']; $foadd=$row['office_address']; $ftp=$row['office_telephone']; $fmf=$row['mobile_number']; } if($first=='mother'){ $mname=$row['name']; $mocu=$row['occupation']; $moadd=$row['office_address']; $mtp=$row['office_telephone']; $mmf=$row['mobile_number']; } if($first=='guardians'){ $gname=$row['name']; $gocu=$row['occupation']; $goadd=$row['office_address']; $gtp=$row['office_telephone']; $gmf=$row['mobile_number']; } } ?> ---- ---- <tr> <td> </td> <td colspan="5"><h3> <label><strong>Parents/Guardian information</strong></label> <strong> </strong></h3></td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td><label>Admission No</label> </td> <td colspan="2" align="left"><?php echo $admission_no ;?></td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"> <input type="checkbox" name="checkbox" id="checkbox" <?php if($fname!=null){ ?> checked="checked" <?php }?> onclick="father()" /> <label>fathers details</label></td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"><label> Name</label> </td> <td><input type="text" name="Name1" id="textfield" value="<?php echo $fname; ?>" disabled="disabled" /></td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"><label>Occupation</label> </td> <td> <input type="text" name="Occupation1" id="textfield2" value="<?php echo $focu; ?>" disabled="disabled"/> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"><label>Office Address</label> </td> <td> <textarea name="Office_Address1" id="office_address" cols="45" rows="5" disabled="disabled"><?php echo $foadd; ?></textarea> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"><label>Office Telephone Number</label> </td> <td> <input type="text" name="Office_tel1" id="textfield4" value="<?php echo $ftp; ?>" disabled="disabled" /> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"><label>Mobile Phone Number</label></td> <td> <input type="text" name="Mobile_pho1" id="textfield5" value="<?php echo $fmf; ?>" disabled="disabled" /> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"> <input type="checkbox" name="checkbox2" id="checkbox2" <?php if($mname!=null){ ?> checked="checked" <?php }?> onclick="mother()" /> <label>Mothers details</label></td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"><label> Name</label> </td> <td> <input type="text" name="Name2" id="textfield3" value="<?php echo $mname; ?>" disabled="disabled"/> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"><label>Occupation</label> </td> <td> <input type="text" name="Occupation2" id="textfield7" value="<?php echo $mocu; ?>" disabled="disabled"/> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"><label>Office Address</label> </td> <td> <textarea name="Office_Address2" id="textarea" cols="45" rows="5" disabled="disabled"><?php echo $moadd; ?></textarea> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"><label>Office Telephone Number</label> </td> <td> <input type="text" name="Office_tel2" id="textfield8" value="<?php echo $mtp; ?>" disabled="disabled" /> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"><label>Mobile Phone Number</label> </td> <td> <input type="text" name="Mobile_pho2" id="textfield9" value="<?php echo $mmf; ?>" disabled="disabled" /> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"> <input type="checkbox" name="checkbox3" id="checkbox3" <?php if($gname!=null){ ?> checked="checked" <?php }?> onclick="Guardian()"/> <label>Guardian details</label></td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"><label> Name</label> </td> <td> <input type="text" name="Name3" id="textfield6" value="<?php echo $gname; ?>" disabled="disabled"/> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"><label>Occupation</label> </td> <td> <input type="text" name="Occupation3" id="textfield10" value="<?php echo $gocu; ?>" disabled="disabled"/> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"><label>Office Address</label> </td> <td> <textarea name="Office_Address3" id="textarea2" cols="45" rows="5" disabled="disabled"><?php echo $goadd; ?></textarea> </td> <td> </td> <td> </td> <td> </td></tr> <tr> <td> </td> <td colspan="2"><label>Office Telephone Number</label> </td> <td> <input type="text" name="Office_tel3" id="textfield11" value="<?php echo $gtp; ?>" disabled="disabled"/> </td> <td> </td> <td> </td> <td> </td> </tr> <tr><td> </td> <td colspan="2"><label>Mobile Phone Number</label> </td> <td> <input type="text" name="Mobile_pho3" id="textfield12" value="<?php echo $gmf; ?>" disabled="disabled" /> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"> </td> <td></td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"> </td> <td> <input type="submit" name="button" id="button" value="Save" /> </td> <td> </td> <td> </td> <td> </td> </tr> </table> <p> </p> <p> </p></td> </tr> I have the following result that I am getting from a source. Code: [Select] SimpleXMLElement Object ( [CategoryID] => 1 [Name] => Other [Order] => 0 [link] => http://www.link.com?sub=1 ) SimpleXMLElement Object ( [CategoryID] => 1233916011 [Name] => ceramic [Order] => 1 [ChildCategory] => SimpleXMLElement Object ( [CategoryID] => 1234016011 [Name] => dish [Order] => 1 ) [link] => http://www.link.com?sub=13476 ) SimpleXMLElement Object ( [CategoryID] => 1233917011 [Name] => laminate [Order] => 2 [link] => http://www.link.com?sub=98247 ) I need to get it into a database with the following structure Code: [Select] id categoryID cName cOrder clink cparent By using Code: [Select] foreach($this->resp->Store->CustomCategories->CustomCategory as $cat) { $sub = $cat->CategoryID; $ord = $cat->Order; $linkto = "$stlink?fsub=$fsub"; $nm = htmlspecialchars($cat->Name); $par=$cat->ChildCategory->Order; $query = "INSERT INTO Cat (categoryID,cName,cOrder,clink,cparent) VALUES ('$sub','$nm','$ord','$linkto','$par')"; $result = @mysql_query ($query); // Run the query. } I can get Code: [Select] id categoryID cName cOrder clink cparent 1 1 Other 0 http://www.link.com?sub=1 0 2 1233916011 ceramic 1 http://www.link.com?sub=13476 0 2 1233917011 laminate 2 http://www.link.com?sub=98247 0 But I need to get the ChildCategory in there w/ cparent like Code: [Select] id categoryID cName cOrder clink cparent 1 1 Other 0 http://www.link.com?sub=1 0 2 1233916011 ceramic 1 http://www.link.com?sub=13476 0 3 1234016011 dish 1 1 <--- like this 4 1233917011 laminate 2 http://www.link.com?sub=98247 0 any help appreciated... |