Jump to content

Search the Community

Showing results for tags 'mysql'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. Hi, i have 2 table, a table alat and a table mutasi_alat. Every I do action insert to the table mutasi_alat, with a relation alat.id_alat and insert date newer then the value that is in the table mutasi_alat.id_cabang. The table will trigger an update to the table alat.cabang_terakhir. Table 1 : alat Table 2 : mutasi_alat I want to be trigger update into table alat after any action insert in table mutasi_alat. Do I have to make a single trigger or storeprocedure with this conditions? thanks
  2. hi is there any way to create an .edu email address with php ? without a .edu website ?
  3. hi im new at prestashop and i need to know a couple things so i can change a query for the search... i need to know how to have the php search for a product id and the product from two different tables ... is this the code that uses the word from the search box to look in the database tables or is this the wrong query ? im just trying to find the query public static function find($id_lang, $expr, $page_number = 1, $page_size = 1, $order_by = 'position', $order_way = 'desc', $ajax = false, $use_cookie = true, Context $context = null) { if (!$context) $context = Context::getContext(); $db = Db::getInstance(_PS_USE_SQL_SLAVE_); // Only use cookie if id_customer is not present if ($use_cookie) $id_customer = $context->customer->id; else $id_customer = 0; // TODO : smart page management if ($page_number < 1) $page_number = 1; if ($page_size < 1) $page_size = 1; if (!Validate::isOrderBy($order_by) || !Validate::isOrderWay($order_way)) return false; $intersect_array = array(); $score_array = array(); $words = explode(' ', Search::sanitize($expr, $id_lang)); foreach ($words as $key => $word) if (!empty($word) && strlen($word) >= (int)Configuration::get('PS_SEARCH_MINWORDLEN')) { $word = str_replace('%', '\\%', $word); $word = str_replace('_', '\\_', $word); $intersect_array[] = 'SELECT si.id_product FROM '._DB_PREFIX_.'search_word sw LEFT JOIN '._DB_PREFIX_.'search_index si ON sw.id_word = si.id_word WHERE sw.id_lang = '.(int)$id_lang.' AND sw.id_shop = '.$context->shop->id.' AND sw.word LIKE '.($word[0] == '-' ? ' \''.pSQL(Tools::substr($word, 1, PS_SEARCH_MAX_WORD_LENGTH)).'%\'' : '\''.pSQL(Tools::substr($word, 0, PS_SEARCH_MAX_WORD_LENGTH)).'%\'' ); if ($word[0] != '-') $score_array[] = 'sw.word LIKE \''.pSQL(Tools::substr($word, 0, PS_SEARCH_MAX_WORD_LENGTH)).'%\''; } else unset($words[$key]); if (!count($words)) return ($ajax ? array() : array('total' => 0, 'result' => array())); $score = ''; if (count($score_array)) $score = ',( SELECT SUM(weight) FROM '._DB_PREFIX_.'search_word sw LEFT JOIN '._DB_PREFIX_.'search_index si ON sw.id_word = si.id_word WHERE sw.id_lang = '.(int)$id_lang.' AND sw.id_shop = '.$context->shop->id.' AND si.id_product = p.id_product AND ('.implode(' OR ', $score_array).') ) position'; $sql = 'SELECT cp.`id_product` FROM `'._DB_PREFIX_.'category_group` cg INNER JOIN `'._DB_PREFIX_.'category_product` cp ON cp.`id_category` = cg.`id_category` INNER JOIN `'._DB_PREFIX_.'category` c ON cp.`id_category` = c.`id_category` INNER JOIN `'._DB_PREFIX_.'product` p ON cp.`id_product` = p.`id_product` '.Shop::addSqlAssociation('product', 'p', false).' WHERE c.`active` = 1 AND product_shop.`active` = 1 AND product_shop.`visibility` IN ("both", "search") AND product_shop.indexed = 1 AND cg.`id_group` '.(!$id_customer ? '= 1' : 'IN ( SELECT id_group FROM '._DB_PREFIX_.'customer_group WHERE id_customer = '.(int)$id_customer.' )'); $results = $db->executeS($sql);
  4. I am working on a project, that lets users register, upload a photo and have that photo as a profile image which then other users can view. I am not sure how to structure this. Here is how I would imagine the process goes. 1-During user registration, user mkdir to create a a new directory that uses the users email address for the name of this new directory. 2-Take users to a upload image page, if users dont upload one, then use a default image. 3-User uploads image. 4-Image gets stored into the directory, and the image name is sent to mysql database. 5-Echo image in users profile by using a SELECT query. 6-using an image tag, select directory name by echoing out the users email from the db, and echo the image name from the db at appropriate areas. Step 6 would kinda look like this: //Grab user email from db and set it to a variable, do the same for image name $user_email = $email_from_db; $user_image = $image_from_db; <img src="image/<?php echo=$user_email; ?>/<?php $user_image; ?> /> Not sure if this is how its done, or if this is a secure way, also I have no idea how I would let users upload an image. Can anyone give me some advice?
  5. Hey Guys, So i have a while loop bringing back some information for me from my database. pretty basic: $query = 'SELECT * from `db` WHERE `id` = '. $id; $run = mysql_query($query); while($rows = mysql_fetch_assoc($run)){ extract($rows); } Now in this loop i am trying to add a link using an anchor tag: echo '<a href="'.$domain . '">'.$domain.'</a><br>'; ( I WILL USE EXAMPLE LINK DONT CLICK BELOW FOR DEMO PURPOSES) which basically makes something like : http://ExampleLinkDontClick.com Now my issue is that for the life of me i cant understand why my link is being given and shown correctly, but the link is firing as so as you can see the anchor tag is looking for a page that i created or is on file in the directory, instead of going to the designated source of the url. any suggestions ? am i just missing something very basic ? usually this works flawlessly but maybe today is just one of those days .. lol thanks guys -justin7410
  6. I have been trying to finish up a website for a while now and I can't seem to figure out how to do this. Right now I want one out of four pictures to randomly be selected and presented on a webpage. I have already achieved this through the shuffle() function. However, I want the name of whichever picture shows up to be recorded in my MySQL database. How do I go about doing this? I searched online and came across the function serialize(), but then I was advised not to use it since I only wanted the name of one of the pictures in the array instead of all of them. Does anyone have any functions/sample code that may be of use? (Example in case I didn't explain clearly: I have four pictures: a.ipg, b.jpg, cjpg, d.jpg Let's say the shuffle() function choses b.jpg to be displayed on the webpage. How could I get b.jpg to be sent to my database?) Thank you.
  7. Hi guys. I have following code to delete particular row from a table based on the title. But how can I delete all data from the table? <?php require 'connpdo.php'; $naslov = $_POST['naslov']; #DELETE DATA //delete some data $sqlInsert = 'DELETE FROM bloging WHERE title=:title'; $preparedStatement = $conn->prepare($sqlInsert); $preparedStatement->execute(array(':title' => $naslov)); //REDIRECT TO HOME PAGE header('Location: http://localhost/ITAPHP/index.php'); ?> So I would need something which would say DELETE * FROM bloging...Basically I have this table bloging with 3 fields id, title and text, and above code will identify specific post based on the title and delete that particular post. But I need button to delete all posts, to empty table. Thank you in advance!
  8. Hey guys, I'm having the hardest time trying to access data within my foreach loop. Here is the var_dump right before the foreach. array(19) { [0]=> string( "Thursday" [1]=> string( "Saturday" [2]=> string(6) "Monday" [3]=> string(6) "Friday" [4]=> string(6) "Monday" [5]=> string(9) "Wednesday" [6]=> string(7) "Tuesday" [7]=> string(7) "Tuesday" [8]=> string( "Thursday" [9]=> string(6) "Sunday" [10]=> string(7) "Tuesday" [11]=> string(7) "Tuesday" [12]=> string(6) "Monday" [13]=> string(6) "Friday" [14]=> string(9) "Wednesday" [15]=> string(6) "Monday" [16]=> string(9) "Wednesday" [17]=> string(6) "Sunday" [18]=> string(6) "Monday" } array(19) { [0]=> string(90) "http://www.mylink.com/1" [1]=> string(90) "http://www.mylink.com/2" [2]=> string(90) "http://www.mylink.com/3" [3]=> string(90) "http://www.mylink.com/4" [4]=> string(90) "http://www.mylink.com/5" [5]=> string(90) "http://www.mylink.com/6" [6]=> string(90) "http://www.mylink.com/7" [7]=> string(90) "http://www.mylink.com/8" [8]=> string(90) "http://www.mylink.com/9" [9]=> string(90) "http://www.mylink.com/10" [10]=> string(90) "http://www.mylink.com/11" [11]=> string(90) "http://www.mylink.com/12" [12]=> string(90) "http://www.mylink.com/13" [13]=> string(90) "http://www.mylink.com/14" [14]=> string(90) "http://www.mylink.com/15" [15]=> string(90) "http://www.mylink.com/16" [16]=> string(90) "http://www.mylink.com/17" [17]=> string(0) "" [18]=> string(0) "" } array(19) { [0]=> string(6) "715.00" [1]=> string(6) "912.00" [2]=> string(6) "715.00" [3]=> string(6) "715.00" [4]=> string(6) "715.00" [5]=> string(6) "715.00" [6]=> string(6) "715.00" [7]=> string(6) "912.00" [8]=> string(6) "715.00" [9]=> string(6) "715.00" [10]=> string(6) "715.00" [11]=> string(6) "715.00" [12]=> string(6) "715.00" [13]=> string(6) "912.00" [14]=> string(6) "912.00" [15]=> string(6) "715.00" [16]=> string(6) "715.00" [17]=> string(6) "715.00" [18]=> string(6) "912.00" } array(19) { [0]=> string(6) "330.00" [1]=> string(6) "400.00" [2]=> string(6) "330.00" [3]=> string(6) "330.00" [4]=> string(6) "330.00" [5]=> string(6) "330.00" [6]=> string(6) "330.00" [7]=> string(6) "400.00" [8]=> string(6) "330.00" [9]=> string(6) "330.00" [10]=> string(6) "330.00" [11]=> string(6) "330.00" [12]=> string(6) "330.00" [13]=> string(6) "400.00" [14]=> string(6) "400.00" [15]=> string(6) "330.00" [16]=> string(6) "330.00" [17]=> string(6) "330.00" [18]=> string(6) "400.00" } array(19) { [0]=> string(6) "220.00" [1]=> string(6) "275.00" [2]=> string(6) "220.00" [3]=> string(6) "220.00" [4]=> string(6) "220.00" [5]=> string(6) "220.00" [6]=> string(6) "220.00" [7]=> string(6) "275.00" [8]=> string(6) "220.00" [9]=> string(6) "220.00" [10]=> string(6) "220.00" [11]=> string(6) "220.00" [12]=> string(6) "220.00" [13]=> string(6) "275.00" [14]=> string(6) "275.00" [15]=> string(6) "220.00" [16]=> string(6) "220.00" [17]=> string(6) "220.00" [18]=> string(6) "275.00" } array(19) { [0]=> string(6) "187.00" [1]=> string(6) "225.00" [2]=> string(6) "187.00" [3]=> string(6) "187.00" [4]=> string(6) "187.00" [5]=> string(6) "187.00" [6]=> string(6) "187.00" [7]=> string(6) "225.00" [8]=> string(6) "187.00" [9]=> string(6) "187.00" [10]=> string(6) "187.00" [11]=> string(6) "187.00" [12]=> string(6) "187.00" [13]=> string(6) "225.00" [14]=> string(6) "225.00" [15]=> string(6) "187.00" [16]=> string(6) "187.00" [17]=> string(6) "187.00" [18]=> string(6) "225.00" } array(19) { [0]=> string(6) "157.00" [1]=> string(6) "192.00" [2]=> string(6) "157.00" [3]=> string(6) "157.00" [4]=> string(6) "157.00" [5]=> string(6) "157.00" [6]=> string(6) "157.00" [7]=> string(6) "192.00" [8]=> string(6) "157.00" [9]=> string(6) "157.00" [10]=> string(6) "157.00" [11]=> string(6) "157.00" [12]=> string(6) "157.00" [13]=> string(6) "192.00" [14]=> string(6) "192.00" [15]=> string(6) "157.00" [16]=> string(6) "157.00" [17]=> string(6) "157.00" [18]=> string(6) "192.00" } array(19) { [0]=> string(6) "138.00" [1]=> string(6) "165.00" [2]=> string(6) "138.00" [3]=> string(6) "138.00" [4]=> string(6) "138.00" [5]=> string(6) "138.00" [6]=> string(6) "138.00" [7]=> string(6) "165.00" [8]=> string(6) "138.00" [9]=> string(6) "138.00" [10]=> string(6) "138.00" [11]=> string(6) "138.00" [12]=> string(6) "138.00" [13]=> string(6) "165.00" [14]=> string(6) "165.00" [15]=> string(6) "138.00" [16]=> string(6) "138.00" [17]=> string(6) "138.00" [18]=> string(6) "165.00" } array(19) { [0]=> string(5) "89.00" [1]=> string(6) "125.00" [2]=> string(5) "75.00" [3]=> string(5) "95.00" [4]=> string(5) "86.00" [5]=> string(5) "86.00" [6]=> string(5) "75.00" [7]=> string(6) "150.00" [8]=> string(5) "79.00" [9]=> string(5) "77.00" [10]=> string(6) "103.00" [11]=> string(6) "103.00" [12]=> string(5) "75.00" [13]=> string(6) "118.00" [14]=> string(6) "125.00" [15]=> string(5) "89.00" [16]=> string(5) "75.00" [17]=> string(5) "86.00" [18]=> string(6) "135.00" } array(19) { [0]=> string(5) "97.00" [1]=> string(6) "115.00" [2]=> string(5) "97.00" [3]=> string(5) "97.00" [4]=> string(5) "97.00" [5]=> string(5) "97.00" [6]=> string(5) "97.00" [7]=> string(6) "115.00" [8]=> string(5) "97.00" [9]=> string(5) "97.00" [10]=> string(5) "97.00" [11]=> string(5) "97.00" [12]=> string(5) "97.00" [13]=> string(6) "115.00" [14]=> string(6) "115.00" [15]=> string(5) "97.00" [16]=> string(5) "97.00" [17]=> string(5) "97.00" [18]=> string(6) "115.00" } array(19) { [0]=> string(5) "81.00" [1]=> string(6) "105.00" [2]=> string(5) "60.00" [3]=> string(5) "81.00" [4]=> string(5) "71.00" [5]=> string(5) "71.00" [6]=> string(5) "61.00" [7]=> string(6) "125.00" [8]=> string(5) "69.00" [9]=> string(5) "69.00" [10]=> string(5) "81.00" [11]=> string(5) "81.00" [12]=> string(5) "60.00" [13]=> string(5) "96.00" [14]=> string(6) "105.00" [15]=> string(5) "75.00" [16]=> string(5) "60.00" [17]=> string(5) "71.00" [18]=> string(6) "115.00" } array(19) { [0]=> string(5) "78.00" [1]=> string(5) "90.00" [2]=> string(5) "78.00" [3]=> string(5) "78.00" [4]=> string(5) "78.00" [5]=> string(5) "78.00" [6]=> string(5) "78.00" [7]=> string(5) "90.00" [8]=> string(5) "78.00" [9]=> string(5) "78.00" [10]=> string(5) "78.00" [11]=> string(5) "78.00" [12]=> string(5) "78.00" [13]=> string(5) "90.00" [14]=> string(5) "90.00" [15]=> string(5) "78.00" [16]=> string(5) "78.00" [17]=> string(5) "78.00" [18]=> string(5) "90.00" } array(19) { [0]=> string(5) "50.00" [1]=> string(5) "60.00" [2]=> string(5) "50.00" [3]=> string(5) "50.00" [4]=> string(5) "50.00" [5]=> string(5) "50.00" [6]=> string(5) "50.00" [7]=> string(5) "60.00" [8]=> string(5) "50.00" [9]=> string(5) "50.00" [10]=> string(5) "50.00" [11]=> string(5) "50.00" [12]=> string(5) "50.00" [13]=> string(5) "60.00" [14]=> string(5) "60.00" [15]=> string(5) "50.00" [16]=> string(5) "50.00" [17]=> string(5) "50.00" [18]=> string(5) "60.00" } array(19) { [0]=> string(5) "28.00" [1]=> string(5) "35.00" [2]=> string(5) "28.00" [3]=> string(5) "28.00" [4]=> string(5) "28.00" [5]=> string(5) "28.00" [6]=> string(5) "28.00" [7]=> string(5) "35.00" [8]=> string(5) "28.00" [9]=> string(5) "28.00" [10]=> string(5) "28.00" [11]=> string(5) "28.00" [12]=> string(5) "28.00" [13]=> string(5) "35.00" [14]=> string(5) "35.00" [15]=> string(5) "28.00" [16]=> string(5) "28.00" [17]=> string(5) "28.00" [18]=> string(5) "35.00" } array(19) { [0]=> string(5) "13.00" [1]=> string(5) "25.00" [2]=> string(5) "13.00" [3]=> string(5) "13.00" [4]=> string(5) "13.00" [5]=> string(5) "13.00" [6]=> string(5) "13.00" [7]=> string(5) "25.00" [8]=> string(5) "13.00" [9]=> string(5) "13.00" [10]=> string(5) "13.00" [11]=> string(5) "13.00" [12]=> string(5) "13.00" [13]=> string(5) "25.00" [14]=> string(5) "25.00" [15]=> string(5) "13.00" [16]=> string(5) "13.00" [17]=> string(5) "13.00" [18]=> string(5) "25.00" } Here is the foreach: foreach ($values as $cell) { echo "<a href=\"".$link."\" class=\"".$class."\">" . $cell . "</a>"; } $class is supposed to be the first iteration of the array: Thursday, Saturday, Monday, etc. $link is supposed the be the second iteration of the array: http://www.mylink.com/... I can get the $cell data, but I cannot access the $link or $class values. Thank you so much for any help you can provide. ~SarahB
  9. I am using MYSQL ,MYISAM table type and php version 5.4.16 and am doing a fulltext search based on the (product_name) column and i want to randomize the result of rest of the columns but the problem is rand()not giving the random values. I tried something like this: SELECT `product_name`,`main_cat_id`,`sub_cat_id`,`prod_cat_id`,`prod_short_desc`,`com_id`,`product_id`,product_ratings, `min_order_quantity`, `fob`,`country_id`,`company_name`,`attributes`,`attr_values`,`verify`,`image`,product_additionals , MATCH (`product_name`)AGAINST ('"girls top"'IN BOOLEAN MODE) AS relevance, MATCH (`product_name`)AGAINST ('girl* +top*'IN BOOLEAN MODE) AS relevance1 FROM pep_browse_com_prods WHERE (MATCH (`product_name`) AGAINST ('"girls top"'IN BOOLEAN MODE) OR MATCH (`product_name`) AGAINST ('girl* +top*'IN BOOLEAN MODE)) AND STATUS = '0' AND display = '0' ORDER BY relevance DESC,relevance1 DESC,RAND() limit 20; I want to set the relevance first then i want the random values of rest columns.
  10. Hi Just messing about with MySQL and would like to try and set up (for educational purposes) a MySQL Load Balancing environment. Just like you do with Apache where you round robin requests between two or more servers for the web app, I want to also set up this for the database setup. I have looked on the internet and havent found much help or answers but surely this is possible. I am guessing from setting up the apache load balancer that you will need shared storage (for the database files / config files) and then also two nodes each being a DB server which is connected to the shared storage. If this is not possible then how do people set up environments that need many servers due to load? Thanks
  11. Hi , i have a database (dept_db) it contents of 3 tables (web , net , prog) , when i choose Dept like for example i makes Dept to (Web) so the (Web) group appears in the Students that get the inserted data from web table and display it in Students .and when i choose (Net) the Net group appears ,and when i don't choose any group ,i want it to disable the Students Select Tag which function must i use and where and how ! this is a example : http://www.redsn0w.us/2010/03/download-direct-links-jailbreak-guides.html
  12. I have a website that has two separate databases - customdbase2 and sfdsomni. There are two problems I believe are caused by the system not pulling configs and coupons tables from the correct database: 1. Coupon amount is posted on the form, but the authorize.net transaction is for the non-coupon amount. The coupons table is in the customdbase2 database NOT the sfdsomni database. 2. Email is supposed to be generated (Thanks for signing up kind of thing). The email that goes through is blank. The configs tables contains the email text used to create the body of the message. The configs table is in the customdbase2 database NOT the sfdsomni database. There is a form that uses authorize.net to process a credit card for customers to make purchases. I've tested it and the purchase works and it goes through but it does not apply the coupon to the price and processes the transaction without the coupon. After the transaction goes through, I get the following: Thank you for signing up! You should receive an e-mail confirmation of your purchase soon. You may start right away by logging in here: http://www.x1234.com/driving/. Table 'sfdsomni.configs' doesn't exist Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in/home/content/90/11644390/html/www.x1234.com/includes/config.inc.php on line 296 Table 'sfdsomni.configs' doesn't existTable 'sfdsomni.configs' doesn't existTable 'sfdsomni.coupons' doesn't exist It seems to be asking for the two tables "configs" and "coupons" from the sfdsomni db when it should be getting them from customdbase2. In session.inc.php the database connects to customdbase2 as $sqlbase and sfdsomni as @sqlbase_de. I have looked in buynow.php and it is setting a $global that looks suspicious. <? session_start(); // removed these slashes to turn on https 1-13-2014 1116am if ($_SERVER[HTTPS] != "on") header("Location: https://".$_SERVER[HTTP_HOST].$_SERVER[REQUEST_URI]); // turn these off if you want to disable adding the users to the database $adduser_normal = true; $adduser_driversed = true; $root_dir = "./"; require_once($root_dir."includes/config.inc.php"); require_once($root_dir."includes/overall_header.inc.php"); require_once($root_dir."includes/dbconnect.php"); $action = $_REQUEST[action]; if (empty($action)) $action = "showform"; $sqlbase = dbConnect(); $id = mysql_real_escape_string($_REQUEST[id]); if (empty($id)) exit; $sql = "SELECT * FROM packages WHERE packageID='$id'"; $query = mysql_query($sql, $sqlbase); echo mysql_error(); $pkg = mysql_fetch_array($query); if (empty($pkg[packageID])) exit; function create_uid() { global $sqlbase_de; /* THIS IS WHAT I AM SUSPICIOUS OF */ $size = 16; $str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; do { do { $id = ""; for($i=0;$i<$size;$i++) { $id = $id . substr($str,mt_rand(0,strlen($str)-1),1); } $row = mysql_fetch_array(mysql_query("SELECT id FROM ac_users WHERE UID='".mysql_real_escape_string($id)."'", $sqlbase_de)); } while ($row); } while(strlen($id) != 16); return $id; } if ($action == "checkcoupon") { $sql = "SELECT * FROM coupons WHERE code='".mysql_real_escape_string($_REQUEST )."' "."AND maxuses > timesused "."AND (expiration > NOW() OR expiration IS NULL)";$query = mysql_query($sql); echo mysql_error();$coup = mysql_fetch_array($query); if ($coup[code=auto:0] && $coup[minpurchase] <= $pkg[price]) {$_SESSION[couponID] = $coup[couponID];$dollaroff = $coup[amount] / $pkg[payments];$pkg[price] = number_format($pkg[price] - $dollaroff, "2", ".", ",");$action = "showform";}elseif ($coup[code=auto:0]){echo "You entered a correct coupon code, however the minimum purchase price for this coupon is ".displayAsCurrency($coup[minpurchase]).". Please try again.";$action = "applycoupon";}else{echo "You entered an invalid coupon code.<br /><br />";$action = "applycoupon";}} if ($_SESSION[couponID]){$sql = "SELECT * FROM coupons WHERE couponID='".mysql_real_escape_string($_SESSION[couponID])."' ";$query = mysql_query($sql); echo mysql_error();$coup = mysql_fetch_array($query);} $authnet_payments = $pkg[payments];$authnet_charge = $pkg[price];$product_title = $pkg[title];$product_desc = $pkg[description]; if ($action == "applycoupon"){?><a href="<?= $_SERVER[php_SELF]; ?>?id=<?= $id; ?>">Back</a> to order form.<br /><br /><form method="POST" action="<?= $_SERVER[php_SELF]; ?>"><input type="hidden" name="action" value="checkcoupon" /><input type="hidden" name="id" value="<?= $id; ?>">Coupon Code: <input type="text" name="code" size="30" value="<?= $_REQUEST[code=auto:0]; ?>" /><br /><br /><input type="submit" value="Apply Coupon" /></form><?} buynow.php config2.inc.php
  13. Hi. Sorry if I've posted in the wrong forum or something - I joined this forum a few seconds ago. I'm trying to create something which displays all of the users in a database table in a drop-down menu. I've tried this code: <?php include 'config.php'; session_start(); $suser = $_SESSION['user']; $con = mysql_connect($config['mysql_host'], $config['mysql_user'], $config['mysql_pass']); mysql_select_db($config['database']); $cpuTable = $config['cpuTable']; $query = mysql_query("SELECT * FROM $cpuTable WHERE suser='$suser'"); while($row = mysql_fetch_assoc($qa)) { $users = $row['username']; echo " <select name='cpuser'> <option value='user'>$users</option> </select>"; } I created two users in the database - "cp_test1" and "cp_test2", tried the code and it outputted this: Instead of listing the users in one drop-down menu, it creates two and lists one in each. Can anyone help? Thanks
  14. Hello to all! I have a question about how to do something with php and mysql. On my site, user can upload photos and choose if they want to let others users rate this photos (from 1 to 10). So actually, on my website, i have a section to shows members with best rating... .but the problem that users told me... is if a members has 3 pics with 3 different rate (let say 9, 8 and 7) this members will be show 3 time.... once at the position 9, another time to the position 8 and a last time at the position 7.... So the list can be very long..... My question is: Now i try to make is simple and better.. so i will show photo with best rate as i already did, but the difference is a same members will only appears once... so if a members has 3 pics... i will show the pics with the best rate and i want to add at the bottom of this pic a list of all other photo of this member that has been rated... So, if i take the same exemple, i will show the photo that rated 9 and below, in small thumbnail the 2 other pics that rated 8 and 7.. after i will continue to with the next result... maybe 8.9 ... or other.. I thought to every row, to query to get other photo of the actual user.... but it will query a lot of time the server.. so i dont think it's the best way.... Can you please give me a hint! Note: i have 1 table 'Photos' and every photo have his own row(id,path, rate.....) thanks for you help Pascal
  15. I am in need of some help with an existing website. The site was custom built about 4 years ago. It was coded without using any sort of framework. I have had some of these problems for a while and the hosting I was on made it difficult to get work done on it. I have recently migrated to Godaddy so I now have complete access to it. In the text below I have replaced the domain name with junk to avoid this page coming up on any searches. I am experiencing error messages in several areas: 1. When customer buys a product - the page that is output after a sucsessful authorize.net transaction contains the following: Thank you for signing up! You should receive an e-mail confirmation of your purchase soon. You may start right away by logging in here: http://www.^&%$#@.com/driving/. Table 'sfdsomni.configs' doesn't exist Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in/home/content/90/11644390/html/%$#@/includes/config.inc.php on line 296 Table 'sfdsomni.configs' doesn't existTable 'sfdsomni.configs' doesn't existTable 'sfdsomni.coupons' doesn't exist I don't see any table called configs in the sfdsomni database. I am unsure if this is the cause of the error or if it is an error with the parameter for mysql_fetch_array() or both. 2. When a customer signs up, an email is generated (welcome to our company - here is your login info kind of thing). The email that is being sent is blank and seems to have an unknown sender some of the time. There is an email text file that is editable by admins on the back end system - this seems to be fine and has not changed in years. This was a problem on the previous hosting company as well. 3. Some of the products include an online driver education course - I am receiving errors when I sign on to that as a new student: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/90/11644390/html/%$#@/driving/classes/config/courses.conf.php:155) in /home/content/90/11644390/html/%$#@/driving/classes/session.inc.php on line 70 4. As I mentioned in another post (http://forums.phpfreaks.com/topic/284998-how-do-i-keep-form-data-from-disappearing/) - I have a page used for purchases (buynow.php) - there is an "Apply Coupon" entry button on it. The coupon button currently links to another page which processes the coupon then take you back to a now blank (buynow.php). I'd like to add the coupon field to the buynow.php page and have the apply coupon button simply run through the coupon logic (this is already there and working) without leaving the buynow.php page. In other words - if a customer is buying something with a coupon - they fill out all there into (name, address etc.) add the coupon and hit "apply coupon" - when this button is pressed, if the coupon is valid - it adjusts the price. If it is not, it displays the error message without emptying the rest of the fields on the buynow.php page. 5. I would like to get the code documented so I have an idea of what file is calling what other file and where variables are being delcared. I have a feeling that there is a lot of superfluous junk lying around that is confusing me - I'd like to clean it up. Bid requirements: I need this to be a fixed cost bid for each of or a combination of the 5 problems listed, If you are confident that you can fix 1, 2 and 4 for $50 and you have no idea how much 3 will cost, please say so instead of guessing. As for the documentation - for each of the problems and mods I need to know exactly what you changed in what files and I need comments with your name and date in the code for future reference (ie /* changed by john doe on 1/12/2014 to fix apply coupon problem */) For the overall documentation mentioned in item 5 - I am looking for a document that will illustrate the relationship between the files - this can be graphical (I'd prefer it that way). Other work: I have plans to do some additional modifications to the structure of the site to increase usability. I also plan on a graphical face lift as well. I am hoping to find someone I can go back to for these jobs in the near future. I was hoping to take the time to figure these out on my own, but I have too much stuff going on and I don't want to expose my customers to these errors any longer than necessary. I am a novice at php - I feel like I could get a lot further if I could figure out how to turn on some sort of debug feature that would show me whats happening where and when. For right now, I need to get these problems fixed ASAP.
  16. the above image is already on the database and i want to display it just like the image below .... can any one give me a little idea on how to get this .... thank you so much ... from PHILIPPINES .. SALAMAT!
  17. Hey guys, I am trying to grab and loop data from my DB with a while loop and extract() function. right now i have something like this: echo '<div>'; // CONTAINER DIV echo '<h2>News about '. $db_name. '</h2>'; $query = 'SELECT * FROM `news_to_people` WHERE `people_db_id` = '.$db_id; $r_query = mysql_query($query); while($rows=mysql_fetch_assoc($r_query)){ extract($rows); $new_q = 'SELECT * FROM `news` WHERE `id` = '.$news_id; $run_q = mysql_query($new_q); $rows = mysql_fetch_assoc($run_q); extract($rows); echo '<ul>'; echo '<l1><a href="article?articleid='.$id.'&name='.$db_name.'">'.$title.'<br></l1>'; echo '</ul>'; } echo '</div>'; // END TO CONTAINER Now here i get the loop to fire correctly and execute. It then loops all 170+ links except in the middle of the loop , there is an error: so this means that i have a failed 2nd query somewhere in that it is skipping inside the while loop. i need to debug and find which query is bringing this error. my question is what is the best way i can write an if statement to see which query is failing or which query is not returning a proper array. also my if the query was failing wouldn't the error be asking for a proper resource ? this means the query is firing correctly and the extract() function is failing to receive all the rows. meaning that one of the rows must be returning empty or zero ? any help is much appreciated.
  18. I have been struggling with this progress bar for a while now I need to know whether it is possible to have a real time progress bar for MySQL insertions since database operations are relatively very fast. I have already browsed a few demonstrations but they all relate to data being sent to a form instead and they all seem to work perfectly. I actually have 4 files and this is implemented based on the tutorial with this link http://www.sitepoint.com/tracking-upload-progress-with-php-and-javascript/ **Form.php** <html> <head> <title>File Upload Progress Bar of MySQL Data</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <div id="bar_blank"> <div id="bar_color"></div> </div> <div id="status"></div> <?php $time_start = microtime(true); $mysqlserver = "localhost"; $user = "root"; $pass = ""; $db = "Profusion"; $link = mysql_connect( "$mysqlserver", $user, $pass ); if ( ! $link ) die( "Couldn't connect to MySQL" ); //print "Successfully connected to server<P>"; mysql_select_db( $db ) or die ( "Couldn't open $db: ".mysql_error() ); //print "Successfully selected database \"$db\"<P>"; $result3=mysql_query("INSERT INTO dest_table.create_info SELECT * from Profusion.source_cdr") or die(mysql_error()); $progress=mysql_affected_rows(); $time_end = microtime(true); $time = $time_end - $time_start; echo "Total time taken :"." ".round($time,6) . " s"; ?> 2nd file style.css #bar_blank { border: solid 1px #000; height: 20px; width: 300px; } #bar_color { background-color: #006666; height: 20px; width: 0px; } #bar_blank, #hidden_iframe { display: none; } 3rd file **script.js** function toggleBarVisibility() { var e = document.getElementById("bar_blank"); e.style.display = (e.style.display == "block") ? "none" : "block"; } function createRequestObject() { var http; if (navigator.appName == "Microsoft Internet Explorer") { http = new ActiveXObject("Microsoft.XMLHTTP"); } else { http = new XMLHttpRequest(); } return http; } function sendRequest() { var http = createRequestObject(); http.open("GET", "progress.php"); http.onreadystatechange = function () { handleResponse(http); }; http.send(null); } function handleResponse(http) { var response; if (http.readyState == 4) { response = http.responseText; document.getElementById("bar_color").style.width = response + "%"; document.getElementById("status").innerHTML = response + "%"; if (response < 100) { setTimeout("sendRequest()", 1000); } else { toggleBarVisibility(); document.getElementById("status").innerHTML = "Done."; } } } function startUpload() { toggleBarVisibility(); setTimeout("sendRequest()", 1000); } /* (function () { document.getElementById("myForm").onsubmit = startUpload; })();// i commented this out since this collects information from the form and the last file **progress.php** <?php session_start(); $key = ini_get("session.upload_progress.prefix") . $result3; if (!empty($_SESSION[$key])) { $current = $_SESSION[$key]["bytes_processed"]; $total = $_SESSION[$key]["content_length"]; echo $current < $total ? ceil($current / $total * 100) : 100; } else { echo 100; } I need to show a progress bar as data is inserted into mysql and the total time taken for the query to execute. there are currently 28 rows to be inserted so it's not that big. Everything else seems to work except that the progress bar won't get displayed.
  19. Hi, I'm looking for help with my sessions and table data So far I have 2 tables, one named: userlogin which contains log in information listed by 'user_id' my next table is called userinfo which at the moment just contains user name and address, again listed by 'user_id' Currently I have a log in page, and a home page. The log in page uses the information from the userlogin table to verify that the user has an account and they have entered the correct information. Now this is were it gets tricky, (for me at least) as on this homepage i'm trying to display the information from the userinfo table which relates to the user_id from the userlogin table, relating to their unique information. The purpose of this is to be able to display information for my clients, all without having hundreds of separate pages and having only one page, which displays the information based upon who has logged in. Here is my loginpage code // Use session variable on this page. This function must put on the top of page. session_start(); $_SESSION['userName'] = 'Root'; ////// Login Section. $Login=$_POST['Login']; if($Login){ // If clicked on Login button. $username=$_POST['username']; $password=$_POST['password']; // Encrypt password with md5() function. // Connect database. //connect $con = mysql_connect("*****","*****","*****"); if (!$con) { die('Could not connect: ' . mysql_error()); } //datebase mysql_select_db("*****, $con); // Check matching of username and password. $result=mysql_query("select * from userlogin where username='$username' and password='$password'"); if(mysql_num_rows($result)!='0'){ // If match. session_register("username"); // Craete session username. header("location:home.php"); // Re-direct to main.php exit; }else{ // If not match. $message="--- Incorrect Username or Password ---"; } } // End Login authorize check. ?> and here is my homepage code. <?php session_start(); if(isset($_SESSION['userName'])) ?> // Connect database. //connect $con = mysql_connect("****","*****","******"); if (!$con) { die('Could not connect: ' . mysql_error()); } //datebase mysql_select_db("*****", $con); //select $user_id = $_GET['user_id']; $result = mysql_query("SELECT userinfo.user_id, userlogin.user_id FROM userinfo INNER JOIN userlogin ON userinfo.user_id=userlogin=user_id"); while($row = mysql_fetch_array($result)) { echo $row['name'] . ' ' ; echo $row['address'] . ' '; } ?> Sorry if this seems confusing, as unfortunately my php skills aren't brilliant, but basically i'm just looking for help creating a log in feature, which then links the user the their profile, with their data present. Thanks in advance!
  20. Hey guys, I am currently facing an issue with my profile.php page for my website. i have a function that is grabbing information of a logged in user grabbing his ID and his data array combining the 2 and creating a variable that will let me echo out the info for the end user on their profile page. the function that is creating an error : function user_data($user_id){$data = array(); $user_id = (int)$user_id; $func_num_args = func_num_args(); $func_get_args = func_get_args(); if ($func_num_args > 1) { unset($func_get_args[0]); $fields = '`' . implode('`, `', $func_get_args) . '`' ; $query = ("SELECT $fields FROM `users` WHERE `user_id` = $user_id"); echo $query . '<br><br>' ; < ---- ADDED FOR DEBUGGING --------- NOT PART OF CODE $run = mysql_query($query); print_r($run); < ---- ADDED FOR DEBUGGING --------- NOT PART OF CODE echo '<br><br>'; < ---- ADDED FOR DEBUGGING --------- NOT PART OF CODE $data = mysql_fetch_assoc($run); print_r($data) . '<br><br>'; < ---- ADDED FOR DEBUGGING --------- NOT PART OF CODE return $data; die(); < ---- ADDED FOR DEBUGGING --------- NOT PART OF CODE } } The function seems to work properly when printing the array and the query , firing the query independently in sql and getting a TRUE; Results: Line 156 of this file is that Function above ^ I dont understand why i am getting this error : I understand that i need the $query to fire correctly and return a resource to the fetch_assoc() , but as it shows above the resource is being provided and is still returning as a string ???. any suggestions ?
  21. I need some help with a looping problem. In my example code below, I have two Mysql tables: tblDepRatesCats: ID | header | left_text | center_text | right_text | header_order tblRates_balance: id | depratecat | MinBalance | InterestRate | APY | suborder tblDepRatesCats.ID = tblRatesBalance.depratecat. For each row in tblDepRatesCats, there may be 0 or 1 or more rows in tblRates_balance. I'm trying to display the results of querying these tablesso that it shows each tblDepRatesCats data with the corresponding tblRates_balance data, but instead it is showing tblDepRatesCats so that if tblDepRatesCats row has 3 tblDepRatesCats rows associted with it, the tblDepRatesCats row is repeated 3 times with one row of tblDepRatesCats, It displays incorrectly like this: NOW Checking Accounts Minimum Daily Balance to Earn APY $1000 Super NOW Checking Account Minimum Daily Balance to Earn APY $2222 Super NOW Checking Account Minimum Daily Balance to Earn APY $2100 Super NOW Checking Account Minimum Daily Balance to Earn APY $2000 Below is my code. Extra echos included for clarity. I can't figure it out. Any help is appreciated. Thanks. <?php include ('connect.php'); error_reporting(E_ALL); $qry = mysql_query('SELECT DISTINCT tblDepRatesCats.*, tblRates_balance.* FROM tblDepRatesCats INNER JOIN tblRates_balance ON tblDepRatesCats.ID = tblRates_balance.depratecat ORDER BY tblDepRatesCats.header_order, tblRates_balance.suborder;'); $result = $qry or die ("Error:" . mysql_error()); while ($row = mysql_fetch_assoc($result)) { echo ("<table width=\"98%\" border=\"0\" bgcolor:\"#ffffff\"><tr><td>"); echo ("" . $row["header"] . " <br><br>"); echo ("" . $row["left_text"] . " <br><br>"); echo ("</tr></td>"); echo ("<tr><td>"); echo ("" . $row["MinBalance"] . " <br><br>"); echo (" </tr></td>"); } ?>
  22. Sir I Want to create Website which look like newspaper classified But I cant create Clasified <td> tag With Auto height which i atetched in below picture Help me to do that
  23. Hi, I'm working on a reset password for WordPress and I'm stumped on this query. What the query does is when a user requests a password reset, the query makes an update to the user's password and activation key. When I run this query, it's giving me int(0) which is saying there are no rows affected. I ran a var_dump on each POST variables to check if the values are correct and it is, so I'm not sure where the error is coming from this sql statement. $resetQuery = $wpdb -> query($wpdb -> prepare("UPDATE wp_users SET user_pass = %s, user_activation_key = '' WHERE user_login = %s AND user_activation_key = %s" , $hashedPwd , $usernameemail, $key)); If anyone can please assist me, that would be great! -Halben
  24. Hai guys, I'm programming something like a text-based game now, but I've a question.. I want to have a script running, that updates every hour (01:00, 02:00, etc.) the values of some MySQL tables. I've now something like this, but I don't know if this is the right way to do it. So do you guys have any tips to do something like this? Thanks in advance. Updater.php: if (date("i", time()) == "00") { while($x = mysql_fetch_object($dbres)) $update[$x->name] = $x->time; if(floor($update['hour']/3600) != floor(time()/3600)) { $dbres = mysql_query("SELECT GET_LOCK('hour_update',0)"); if(mysql_result($dbres,0) == 1) { $cron_pass = "secretcronpassword"; mysql_query("UPDATE `cron` SET `time`='".time()."' WHERE `name`='hour'"); include("_cron_hour.php"); mysql_query("SELECT RELEASE_LOCK('hour_update')"); } } } _cron_hour.php: if($cron_pass != "secretcronpassword") exit; $dbres = mysql_query("SELECT * FROM `aandelen`"); while($aandeel = mysql_fetch_object($dbres)) { $koersmin = rand(1,500); $koersplus = rand(1,500); mysql_query("UPDATE `aandelen` SET `koers`=`koers`+$koersplus WHERE `naam`='".$aandeel["naam"]."'"); mysql_query("UPDATE `aandelen` SET `koers`=`koers`-$koersmin WHERE `naam`='".$aandeel["naam"]."'"); } if($aandeel["koers"] < 2500) { mysql_query("UPDATE `aandelen` SET `koers`=10000 WHERE `naam`='".$aandeel["naam"]."'"); } $sql1 = mysql_query("SELECT * FROM users WHERE uurloon='1' AND familie <> 'Geen'"); if (mysql_num_rows($sql1)>0) { while($info2 = mysql_fetch_array($sql1)) { $row = mysql_fetch_assoc(mysql_query("SELECT * FROM families WHERE name='".$info2["familie"]."'")); mysql_query("UPDATE users SET cash='".($info2["cash"]+((($row["aandelen"]*200)/100)*25))."', bank='".($info2["bank"]+((($row["aandelen"]*200)/100)*75))."' WHERE login='".$info2["login"]."'"); } }
  25. Ok, so in a database table i have: name contact code type price quantity Name 1 xxxxxxxxx GHT3 Food £10.50 2 Name 1 xxxxxxxxx GHTd Food £10.30 2 Name 1 xxxxxxxxx GHTs Food £10.90 2 Name 2 xxxxxxxxx GHT3 Food £10.50 2 Name 3 xxxxxxxxx GHTs Food £10.50 2 Name 3 xxxxxxxxx GHTd Food £10.50 2 I want them to read on another page like this: Name Contact Code Type Quantity Name 1 xxxxxxxxxx GHT3 Food 2 GHTd Food 2 GHTs Food 2 Total Price: £xx.xx Name 2 xxxxxxxxxx GHT3 Food 2 Total Price: £xx.xx Name 3 xxxxxxxxxx GHTs Food 2 GHTd Food 2 Total Price: £xx.xx So it only reads the name and number once but puts in the whole of what they are after. Hope someone understands this and can lend some help. Don't need the table doing just need to know the sql i would need to use.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.