How to Fix Top Five Common PHP Database Problems a Developer Faces

Let suppose that there is only one way to use database correctly… Then you will hire php developer india to create database design, database access and then write PHP business logic code that sits on top of it in any number of ways and finally you often end up getting it wrong.

In this article, we are going to describe five common problems in PHP database design and how to fix these problems when it appears.

Problem 1: Using MySQL directly in PHP code

There is one major common problem is older PHP code, it’s using the mysql functions to access the database directly. Following PHP program shows how to access the database directly.

Program 1. Access/get.php

<?php

functionget_user_id( $name )

{

  $db= mysql_connect( ‘localhost’, ‘root’, ‘password’ );

  mysql_select_db( ‘users’ );

  $res= mysql_query( “SELECT id FROM users WHERE login='”.$name.”‘” );

  while( $row= mysql_fetch_array( $res ) ) { $id = $row[0]; }

  return $id;

}

var_dump(get_user_id( ‘jack’ ) );

?>

Note:

  • The mysql_connect function has been used to access the database.
  • The query in which we use string concatenation to add the $name parameter to the query.

Above technique has two good alternatives:

1- PEAR DB module:

In it, the other value in using the abstraction layers of the PEAR DB module.

2- PHP Data Objects (PDO) classes:

PHP Data Objects is that you can use the "?" operator in your SQL statements. By doing this, you makes the SQL easier to maintain and secures your application from any type of SQL injection attacks.

Alternative code is given below by using PEAR DB.

Program 2. Access/get_good.php

<?php

require_once(“DB.php”);

functionget_user_id( $name )

{

  $dsn= ‘mysql://root:[email protected]/users’;

  $db =& DB::Connect( $dsn, array() );

  if (PEAR::isError($db)) { die($db->getMessage()); }

  $res = $db->query( ‘SELECT id FROM users WHERE login=?’,

  array( $name ) );

  $id = null;

  while( $res->fetchInto( $row ) ) { $id = $row[0]; }

  return $id;

}

var_dump(get_user_id( ‘jack’ ) );

?>

Problem 2: Not using auto-increment functionality in database

Similar to other modern databases, MYSQL database has ability to create auto-incrementing unique identifiers on a per-record basis. In the following code, we still see the code that first runs a SELECT statement to find the maximum id, after then it adds one to that id, as well as a new record.

Program 3 shows a sample bad schema code.

Program 3. Badid.sql

DROP TABLE IF EXISTS users;

CREATE TABLE users (

  id MEDIUMINT,

  login TEXT,

  password TEXT

);

INSERT INTO users VALUES ( 1, ‘jack’, ‘pass’ );

INSERT INTO users VALUES ( 2, ‘joan’, ‘pass’ );

INSERT INTO users VALUES ( 1, ‘jane’, ‘pass’ );

Here the id field is specified simply as an integer value and it should be unique value. We can add any value as we like as it’s shown in the INSERT statements of that follow the CREATE statement.

Following program shows the PHP code that adds users into this type of schema.

Program 4. Add_user.php

<?php

require_once(“DB.php”);

functionadd_user( $name, $pass )

{

  $rows= array();

  $dsn= ‘mysql://root:[email protected]/bad_badid’;

  $db =& DB::Connect( $dsn, array() );

  if (PEAR::isError($db)) { die($db->getMessage()); }

  $res = $db->query( “SELECT max(id) FROM users” );

  $id = null;

  while( $res->fetchInto( $row ) ) { $id = $row[0]; }

  $id += 1;

  $sth = $db->prepare( “INSERT INTO users VALUES(?,?,?)” );

  $db->execute( $sth, array( $id, $name, $pass ) );

  return $id;

}

$id = add_user( ‘jerry’, ‘pass’ );

var_dump( $id );

?>

Code written in add_user.php file will first performs a query to find the maximum value of the id. Then the file runs an INSERT statement with the id value plus one. But this above code could fail in race conditions.

So what’s the alternative?

 Now use the auto-increment feature in MySQL to create unique IDs for each insertion automatically.

Program 5. Goodid.php

DROP TABLE IF EXISTS users;

CREATE TABLE users (

  id MEDIUMINT NOT NULL AUTO_INCREMENT,

  login TEXT NOT NULL,

  password TEXT NOT NULL,

  PRIMARY KEY( id )

);

INSERT INTO users VALUES ( null, ‘jack’, ‘pass’ );

INSERT INTO users VALUES ( null, ‘joan’, ‘pass’ );

INSERT INTO users VALUES ( null, ‘jane’, ‘pass’ );

Here in above code we have added the NOT NULL flag to indicate that the fields must not be null and also added the AUTO_INCREMENT flag to indicate that the field is auto-incrementing.By doing these changes, we can speed things up a bit.

Following program shows the updated PHP code.

Program 6. Add_user_good.php

<?php

require_once(“DB.php”);

functionadd_user( $name, $pass )

{

  $dsn= ‘mysql://root:[email protected]/good_genid’;

  $db =& DB::Connect( $dsn, array() );

  if (PEAR::isError($db)) { die($db->getMessage()); }

  $sth = $db->prepare( “INSERT INTO users VALUES(null,?,?)” );

  $db->execute( $sth, array( $name, $pass ) );

  $res = $db->query( “SELECT last_insert_id()” );

  $id = null;

  while( $res->fetchInto( $row ) ) { $id = $row[0]; }

  return $id;

}

$id = add_user( ‘jerry’, ‘pass’ );

var_dump( $id );

?>

Now this above code is simpler andmore efficient than the original version (Program 4) and its related schema.

If you are struggling with any such type problem or any other PHP database related problems then hire php developer india. AResourcepool is a reputed PHP development company and we can help you to solve any type of PHP related Problems. We have 24×7 technical support team to assist you by providing quality services.

How to fix top 10 Magento issues that can destroy your web store

Magento is the most popular e-commerce platforms for e-commerce business. Magento is the very reliable platform which powering more than 29% of the ecommerce stores followed by wooCommerce 26% and shopify 11% in the Alexa’s top one million websites.

It is a powerful platform but it is still a software program and there are few particular problems. We’ve collected the top 10 Magento issues and providing their solutions.

Problem 1:

How to re-set or change password of Magento admin

Solution:

There are two way to reset or change password.

Method 1:  (Less Secure)

If you want to reset or change the password then you need to navigate to phpMyAdmin, then select the corresponding database and find admin_user table. Here in admin_user table, you can replace the old password with a new one. Here make sure your password should be in a MD5 function

Method 2:  (More Secure)

Second way to change the password is to insert the following MySQL query into SQL tab

For Existing user:

UPDATE admin_user SET password = CONCAT(MD5(‘xxNewPassword’), ‘:xx’) WHERE username = ‘UserName’;

xxNewPasswordyou new password (exp. [email protected])

UserName: user name of admin

For New and Existing user:

If you have a clean development/test environment and you want to add a new admin user from scratch, then please do the following MySQL queries. This Query is also useful for updating existing users.

#Creating new admin user or updating existing one by username

INSERT INTO admin_user

 (email, username, password, is_active)

VALUE

 (‘[email protected]’,’magento’, (SELECT MD5(‘password’)), 1)

ON DUPLICATE  KEY UPDATE

username = ‘magento’, password =(SELECT MD5(‘password’)),is_active=1;

# Creating default admin-user group if not existing. Necessary on clean installation – there’s no Administrators group, thus no permissions can be granted to admin user

INSERT IGNORE INTO admin_role

   (parent_id,tree_level,sort_order,role_type,user_id,   role_name)

VALUES (  0,    1,    1,   ‘G’,  0,  ‘Administrators’);

# Creating our account to access all things in admin panel

INSERT INTO admin_role(parent_id,tree_level,sort_order,role_type,user_id,role_name)

VALUES

( 1,  2,  0,  ‘U’,(SELECT admin_user.user_id FROM admin_user WHERE username = ‘magento’), ‘Super User’);

Problem 2:

How to solve ‘Access Denied’ issue of Magento

Solution:

If you want to solve an “Access Denied” issue, then you need to log out from Magento admin panel and then login back again.

Then go to:

System > Permissions > Roles > Administrators 

And then make sure that Resource Access is set to All.

Now click Save Role button and then this issues will be fixed.

Magento Development Company - AresourcePool

Problem 3:

How to change your Magento Admin URL

Solution:

If you want to change default Magento URL (/admin/), then navigate to app/etc/ and open local.xml file. Find the code:

<admin>     
<routers>         
<adminhtml>            
 <args>               
  <frontName><![CDATA[admin]]></frontName>             
</args>        
 </adminhtml>     
</routers>
</admin>

And change the “admin” value.

Now clear the cache of Magento, then test if new URL is working or not and make sure that an old one returns 404 code. 404 error represent that earlier or provided URL is no longer available.

Problem 4:

How to create SEO Friendly URLs in Magento

Solution:

As per google suggestion following are:

SEO friendly URL:         /product-catalog.html

Not SEO friendly URL:      mycatalog/productlist/view/id/342267

To get SEO friendly URL on your Magento, you should navigate to:

 System >>Configuration

Magento Development Company - AresourcePool

Now select “Web” from the left navigation menu,

Then select Search Engine Optimization

Now set Use Web Server Rewrites to Yes and click Save Config button… Now your Magento SEF URLs will be enabled.

Magento Development Company - AresourcePool

Problem 5:

How to disable the “Compare products” functionality

Solution:

If you want to disable compare functionality on Magento then go to your Magento root folder, find app/code/core/Mage/Catalog/Helper/Product/Compare.php

and replace following:

public function getAddUrl($product)

{

return $this->_getUrl(’catalog/product_compare/add’, $this->_getUrlParams($product));

}

Replace above code with following

public function getAddUrl($product)

{

//return $this->_getUrl(’catalog/product_compare/add’, $this->_getUrlParams($product)); return false;

}

Now you need to find /app/design/frontend/base/default/layout/catalog.xml

And editcatalog.xmlfile.

Don’t forget to use your theme name if you are not using a default one.

Find the below code in catalog.xml file

<block type=”catalog/product_compare_sidebar” before=”cart_sidebar” name=”catalog.compare.sidebar” template=”catalog/product/compare/sidebar.phtml”/>

And replace above with following code

<!–<block type=”catalog/product_compare_sidebar” before=”cart_sidebar” name=”catalog.compare.sidebar”

template=”catalog/product/compare/sidebar.phtml”/> –>

Once done with above modification in your file, then clear the Magento Cache from 

Admin area >> System >> Cache Management

Problem 6:

How to set-up your Magento site on a New Domain

Solution:

If you want to change your configured Magento website from:

www.abc.com => TO =>www.xyz.com

Then you need to do two things…

  1. Edit database settings

Now Open cPanel-phpMyAdmin and then select your Magento database from the left menu and find the table core_config_data.

In core_config_datatable, you can see two fields:

  1. web/unsecure/base_url
  2. web/secure/base_url.

Now Change your old domain name with your new domain name and click the Go button to save the all changes.

  • Clear cache

The cache folder is located in your Magento installation directory – /var/cache. To clear the cache, you just delete the folder and go to your Magento admin System > CacheManagement and clear all Cache.

Problem 7:

Magento categories are not showing on the frontend

Solution:

Sometimes categories are not showing, there may be several reasons for that. Then what to do?

Then First of all, make sure that all your created categories are placed inside the default category. And also, Is Active and Is Anchor (inside Display Settings tab) should be set to Yes.

Now after above changes, check if the Root Category is specified correctly.

And finally, you may need to do Refresh Cache (it’s inside System >>Cache Management)

Problem 8:

How to Add a Contact Us form in Magento

Solution:

Contact form functionality in Magento is included in by default. In Magento store, you can see the link of contact Page is usually shown in the footer of Magento store. If you want then you can add a contact form on any page as per your requirement.

Now follow the steps:

Login into your Magento admin and go to CMS > Pages and click on new page button.

Now use the following code in your new page content field as shown in right side in above image:

<!– CONTACT FORM CODE BEGIN–>                                                           

{{block type=’core/template’ name=’contactForm’ template=’contacts/form.phtml’}}

<!– CONTACT FORM CODE END–>

Now click on Save Page and then contact form will appear on that page.

Problem 9:

Redirect Magento to open through www

Solution:

If you want to make your Magento website open through WWW, then you need to access .htaccess file. This .htaccess file is located in the Magento root folder. Now search RewriteEngine and insert the following given code in .htaccess file.

RewriteCond %{HTTP_HOST} ^mydomain.com$ [NC] RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L]

Now save the .htaccess file, then login into your Magento Admin and navigate to System > Configuration > Web. After that Unfold the Unsecure tab and change the base URL to http://www.mydomain.com instead of http://mydomain.com.

Click Save Config and your Magento store will start working through http://www.mydomain.com.

Problem 10:

How to set up a blog in Magento

Solution:

In Magento, It doesn’t have a blog functionality by default. But it can be done with the help of a custom extension. If you don’t want to spend time searching, just try Blog extension.

In Magento, Installing a blog extension is similar to the general extension.When blog extension will be installed then you will have an additional section in the top Menu of Magento admin panel that’s called Blog.

Why we Blog needed in Magento:

  1. Blogging Attracts Organic Traffic to your Magento Store
  2. It Achieve Higher Rankings
  3. Blog helps to Increases Engagement
  4. In blog you can Showcases Your Products
  5. Blog helps to gains Consumer Confidence
In this post we have covered some common but very important Magento problems. Many Magento users are suffering with these problems. We have tried to provide solutions of the most common problems in this post.

FULL STACK DEVELOPMENT COMPANY IN INDIA

Full Stack Development Services in AResourcePool

  • Full Stack Custom Web Services
  • Full Stack Consulting
  • Maintenance and Support
  • Full Stack Migration and Porting
  • Quality Assurance
  • API Development and Integration
  • DBMS AND RDBMS
  • GUI and Enhanced User Experience
  • ERP Development and CMS
  • Server and Hosting
  • Security and Networking

Full Stack Development Company

Are you in constant search for full stack Development Company in India? Your quest for achieving your research end here as we provide best services in the industry globally. AResourcePool was born on 2011 in the USA and provide excellent web development related software services across the world. We design the products which are built using cutting-edge front-end and back-end technologies which includes Angular JS, Ruby on Rails, React, Express JS, PHP, Android, Java, Magento, HTML5 etc…

We at AResourcePool are renowned for providing excellent quality services across the UK and the USA with a great option in Full Stack Development by utilizing our extensive technical knowledge. We provide our clients with specialized teams which provide consultation and dedicated attention to the development of the front-end options. We assure you that you have not to look anywhere for availing these services.

Our Offers

  • Committed Team to efficiently handle your assignment
  • Provision of clear communication
  • Contextual Websites with feature-rich Applications
  • Flexible models of Engagement
  • The standard process of delivering products and services
  • ISO 9001 Processes
  • Support to the customers with Quality Check
full stack development company india

Hire Full Stack Developer India

You have chosen the correct destination to avail full stack development services to fulfill your software related needs in India. India has become a major software hub globally in such a manner that companies from the UK and USA outsource their services to these companies. So, we provide our clients with some easy steps to hire full stack developer India such as:

  • Post Your Inquiry: You could post your inquiry either on our website or call us. After assessing your inquiry, our team member would immediately contact you.
  • Analyst Discussion: We would evaluate your requirements and would analyze which full stack developer would be suitable to satisfy your needs and aspirations.
  • Engagement Terms and Conditions: After identifying which of our experienced full stack developer would be suitable for your services, we would discuss our terms and conditions with you regarding our package and time-period.
  • Get Started: After a successful negotiation, you are ready to hire our experts and avail our services to fulfill your needs and requirements in a successful manner.

Why Select Full Stack App Development from Aresourcepool?

Before targeting our audience globally, we prefer to understand the local market and then provide our services based on its given outcomes. We engage with our customers from starting of the project to the project accomplishment. We not only provide timely delivery of the services but also support them even after completion of the project. This, in turn, would enhance our faith and make us a worthy partner in the investment done by our clients.

We provide our clients with Full Stack JavaScript framework so as to make their online application easy and also simplifies web applications to make them a quicker approach. We also support MYC architecture so as to make the process a relaxed one. We constantly keep you inform about the possible outcome and thus provide you faster results in this competitive business environment. As there are thousands of software companies across India which requires a good and qualified full stack developer to fulfill their needs; we are one step ahead from our competitors and make sure that our services are provided to our clients in an effective manner.

Advantages of Full Stack Developer Company

There are various advantages associated for availing our services which are as follows:

  • High Possibility of Code Re-use
  • Delivery of User-Friendly Applications
  • Expertise in Full Stack Framework
  • Have experienced and talented Full Stack Developer Team
  • Timely Delivery of the project
  • Adherence to Quality Process
  • User-Friendly Applications

Why Aresourcepool

  • Have a talented pool of experts
  • Expertise in Full Stack Development
  • Customer Centric Engagement Models
  • Flexible payment plans
  • Timely and quality deliverables
  • Past Successful Projects

Full Stack Development Company

  • Assurance of 100% Confidentiality
  • Technical Support for 24/7 Hours
  • Satisfaction to the Clients
  • Quality Services

Thus the clients from the software companies across India are one step away in availing our services. The reason behind this is that we have firmly established ourselves as a web and full stack development company not only India but also in the UK and other countries. We are now in the process to help the software companies in their process to hire full stack developer India and help them to enhance their growth and development in an appropriate manner.

Everything You Need To Know About Hiring PHP Developer India

PHP developer India, USA, UK, Globally:

Nowadays,having a website for business is must. You can make your online presence stronger by the website. There are many companies in the world that are giving good PHP development services. But, you need to choose the best company as any mistake in choosing the right firm can waste your money and time both.Aresourcepool is a company that is very popular for their work in the field.The company is giving services in the best countries such as India, USA, UK, Globally. Businessmen from around the world contact them because their service is very affordable as well as it has lots of quality aspects.

A sneak peeks into our work:

Aresourcepool is a digital service providing company that works on multiple services such as brand design, web design, app design, Php development, cms and e-commerce and many more. The developers available on this firm have the capability to change the look of your website and make it fantastic. 24*7 technical support, 100%confidentiality assured as well as customer satisfaction is what on which we work. Apart from that, we only give quality service as we know our customer will not ready to compromises on quality. Till today, we have worked with numbers of the client. In PHP we work on PHP application development, PHP mobile application, PHP template design & development, PHP and flash/flex integration, PHP mobile application, PHP e-commerce app development, PHP custom solutions, and PHP enterprise app development. The wide range of services of each and every category makes us best in the field. So, it would be great to have PHP developer India for your next project.

hire php developer india

Steps to hiring PHP developer for India, USA, UK, Globally:

Do you search for the company that can give you an easy way to talk and the simple procedure then, Aresourcepool is the best again? Like, everything the steps to reach to the company are very clear. So, here have a look at the ways to contact them:

Quick Inquiry:  You will see an option of quick inquiry on the official website of the company. All you need is to fill the right entries with you doubt so that you can get PHP developer easily and sooner. You will get five options in this such as:

  • Name: Enter your name.
  • Email: Give the email address that you can able to log in.
  • Contact Number: Give contact number on which you can receive
  • Budget: Select the amount of your budget.
  • Lead Source: What source lead you to this website.
  • Message: Write what you want to know.

Our PHP Developer’s Technical Expertise:

A good PHP developer and the company will be recognized as the best when they can give some extraordinary services. And, at this platform, our PHP developers have technical expertise like:

  • PHP Shopping Cart development
  • PHP CMS development
  • PHP customization
  • PHP e-commerce & B2B websites solutions
  • PHP API & Web Services Development
  • PHP Development & Design
  • Custom PHP programming
  • PHP Maintenance and Support

What benefits you can get from Aresourcepool:

There are many wonderful benefits you can get if; you will hire PHP Developer India. These are the best services that any company can give to their customers. So, here have a look:

  • Dynamic & Responsive Pages: The skilled employee or developers of the company always work to give the dynamic and responsive pages for your website.
  • Follow e-commerce Industry Standards: The work provided by us always matches the standard of thee-commerce industry. We follow all new trends of the industry standard.
  • Extensive knowledge of PHP:Our skilled developers are highly knowledgeable and experienced. They have an instant solution for every minor as well as major detail.
  • Transparent business process: You will get complete transparency for your work. We would love to give you the access to check our work.
  • Multifaceted development centre: The PHP development centre of our company is incorporated with the latest trend and technology.
  • On-time delivery: We are very strict about the deadlines and, all our developers have trained accordingly so, you can get the work on time. Delivery is the biggest commitment we can make to you.
  • Cost effective: The rate of our service is very affordable as you can get the best and quality work at the best possible price. We do not charge extra for our work and service because we do not have money-making relation with our customers.

Why Choose AResourcepool for PHP Development?

We have a good involvement in conveying adaptable and high performing PHP developers. We have the great degree qualified groups that are talented in PHP.With overtime of involvement in re-appropriating and offshoring improvement administrations, we have turned into the favored decision for some.

We pursue a careful procedure all through the undertaking and give unparalleled PHP advancement administrations which can be incorporated with different arrangements flawlessly for business development. Our customer-driven methodology keeps us centered and in accordance with our customers require.Regardless of whether you are searching for E-Commerce shopping baskets with Community devices, Web Calendars, CMS, CRM Solutions or Discussion gatherings,we have you secured.

Those who are searching for an exceptional and imaginative website for your business,PHP is the correct decision for you. It is the most favored decision for vigorous sites for the vast majority of our clients as it clings to various stages. We have a committed group of originators and engineers who have noteworthy involvement in creating PHP sites, which are highlight rich and easy to use.

With intuitive highlights and unmatched client encounter, AResourcepool brings the best administrations for its clients utilizing PHP improvement rehearses. We offer some benefit included PHP improvement administrations and answers for our customers that assistance them upgrade the business abilities and increment their online reach. We give them the affirmation of nonstop help for any issue they look after the organization.