MySQL Server

46K

Solutions

61

Articles & Videos

22K

Contributors

MySQL is an open source, relational database management system that runs as a server providing multi-user access to a number of databases. Acquired by Oracle in 2009, it is frequently used in combination with PHP installations, powering most of the WordPress installations.

Share tech news, updates, or what's on your mind.

Sign up to Post

I have a table that has a longtext column. Here is an example of the type of data that is stored in it:

a:2:{s:4:"name";s:9:"Anonymous";s:13:"email address";s:26:"xxxxx@networkxxxxxxxxx.net";}

If I break it down we have 4 pieces of information. It appears the s:?? format is the number of characters for that piece of information. I would like to strip out the forth piece of info that is the email address. I know it looks confusing because the 3 piece also says email address but that is not where the data is going. In the end I want the following assigned to a variable:

xxxxx@networkxxxxxxxxx.net

Thanks in advance for your help.
0
Webinar: Security & Encryption in the MySQL world
LVL 2
Webinar: Security & Encryption in the MySQL world

Join Percona’s Solutions Engineer, Dimitri Vanoverbeke as he presents “Security and Encryption in the MySQL world” on Thursday, July 6, 2017 at 7:00 am PDT / 10:00 am EDT (UTC-7).

<?php

$EmployeeID = "";
if(isset($_POST['EmployeeID'])){
    $EmployeeID = $_POST['EmployeeID'];
 }

$FirstName = "";
if(isset($_POST['FirstName'])){
    $FirstName = $_POST['FirstName'];
 }

$MiddleName = "";
if(isset($_POST['MiddleName'])){
    $MiddleName = $_POST['MiddleName'];
 }

$LastName = "";
if(isset($_POST['LastName'])){
    $LastName = $_POST['LastName'];
 }

$FatherName = "";
if(isset($_POST['FatherName'])){
    $FatherName = $_POST['FatherName'];
 }

$SpouseName = "";
if(isset($_POST['SpouseName'])){
    $SpouseName = $_POST['SpouseName'];
 }

$MotherName = "";
if(isset($_POST['MotherName'])){
    $MotherName = $_POST['MotherName'];
 }
 
 $DOBMonth = "";
if(isset($_POST['DOBMonth'])){
    $DOBMonth = $_POST['DOBMonth'];
 }

$DOBDay = "";
if(isset($_POST['DOBDay'])){
    $DOBDay = $_POST['DOBDay'];
 }

$DOBYear = "";
if(isset($_POST['DOBYear'])){
    $DOBYear = $_POST['DOBYear'];
 }

$DateOfBirth="{$DOBMonth}-{$DOBDay}-{$DOBYear}";


$Age = "";
if(isset($_POST['Age'])){
    $Age = $_POST['Age'];
 }

$BloodGroup = "";
if(isset($_POST['BloodGroup'])){
    $BloodGroup = $_POST['BloodGroup'];
 }

$MaritalStatus = "";
if(isset($_POST['MaritalStatus'])){
    $MaritalStatus = $_POST['MaritalStatus'];
 }

$Gender = "";
if(isset($_POST['Gender'])){
    $Gender = $_POST['Gender'];
 }
 
 $EducationDetails = "";
if(isset($_POST['EducationDetails'])){
    $EducationDetails = …
0
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER,INDEX on JIRADB.* TO 'test'@'jiratest>' IDENTIFIED BY 'test';

return

Query OK, 0 rows affected (0,00 sec)
0
I did tutorial located here:, what i would like to do is add edit functionality, i would like to have an edit button and be able to edit record, the tutorial did no cover this, i have researched but i just cant wrap my head around it, i am new to codeigniter as you can tell.

here is my controller:
<?php

class Site extends CI_Controller
{

	function index()
	{

		$data = array();
		
		if($query = $this->site_model->get_records())
		{
			$data['records'] = $query;
		} 
		//$this->load->library('table');
		$this->load->view('options_view',$data);
	}

	function create()
	{
		$data = array(
			'title' => $this->input->post('title'),
			'content' => $this->input->post('content')
			);

		$this->site_model->add_record($data);		
		$this->index();
	}

	function update()
	{
		$data = array (
			'title' => 'My NEW UPDATED title',
			'content' => 'NEW UPDATED content; UPDATED'
			);
		$this->site_model->update_record($data);
	}

	

	 function delete()
	 {
	 	$this->site_model->delete_row();
	 	$this->index();
	 }

}

?>

Open in new window


Here is my model:
<?php

class Site_model extends CI_Model {

	function get_records()
	{
		 $query = $this->db->get('assets');
		 return $query->result();
		// $query = $this->db->query('SELECT * FROM assets');
	    //echo $this->table->generate($query);

	}


	function add_record($data)
	{
		$this->db->insert('assets', $data);
		return;
	}

	function update_record($data)
	{
		$this->db->where('id', 3);
		$this->db->update('assets', $data);
	}


	 function delete_row()
       {
	  	$this->db->where('id', $this->uri->segment(3));
	  	$this->db->delete('assets');

	   }


}

Open in new window


Here is my view:

Open in new window

0
Using PHP/Mysqli (InnoDB):
How can one user who legitimately deletes a MySqli record from a table not create an issue with the other users who are also using the same record from the same table and who may try to update that record?
0
Hi,

I'm using an update query via a form to adjust stock due to discrepancies & breakages etc. I've just noticed that the update query fails when a single 0 is used in any part of the update, but not when this is done directly using terminal and mysql.

So for example if I use the following mysql in terminal to revised a dummy codes stock level from -7,684 back to 0 it works as anticipated.

INSERT INTO manualAdj (partID, partDescription, adjustmentCode, revisedQty, qtyPreRevision) VALUES (2710, 'DUMMYCODE_BM_FIRELIGHTERS','DUMMY CODE TIDY',0,-7684);

Open in new window


However, when I process the same data via the following:
if ((isset($_POST['submit']))
			&& (!empty($_POST['partID']))
            && (!empty($_POST['catID']))
            && (!empty($_POST['reason']))
			&& (!empty($_POST['revisedQty']))
			&& (!empty($_POST['originalQty']))
				

            ) 

            {
        
            // YES, THE DATA HAS BEEN POSTED, NOW ESCAPE IT FOR USE IN A QUERY
			$partID 			= $mysqli->real_escape_string($_POST['partID']);
            $catID 				= $mysqli->real_escape_string($_POST['catID']);
            $reason 			= $mysqli->real_escape_string($_POST['reason']);
			$revisedQty 		= $mysqli->real_escape_string($_POST['revisedQty']);
			$originalQty 		= $mysqli->real_escape_string($_POST['originalQty']);
				
        
            $sql = "INSERT INTO manualAdj (partID, partDescription, adjustmentCode, revisedQty, qtyPreRevision) VALUES ('$partID', '$catID', '$reason', '$revisedQty', '$originalQty')";
            if (!$res = $mysqli->query($sql)) trigger_error( $mysqli->error, E_USER_ERROR );

            }

Open in new window


The query fails to update anything at all but only fails when a single zero(0) is included, otherwise it works as anticipated - any idea why this would happen?

J
0
Hi Experts

Could you point how to configure MySQL to workaround the 'max_connections_per_hour'  error?

mysqli::real_connect(): (42000/1226): user 'root' has exceeded the 'max_connections_per_hour' resource (current value: 50)

Open in new window


Thanks in advance!
0
please i'm trying to access phpmyadmin in my web browser but the page can't open
h.png please how do i solve this problem
0
Hello
I am using a php script that handles the backup & restore of my databases. There are several problems with it but I shall post 1 error at a time. When I click restore backup button I am getting the error in the title. I am not experienced enough to troubleshoot this error and would appreciate some help from the experts. I have posted my code where the error occurs, but if you need to see anything else please let know. The error occurs at line 109.

I will add that this is not my script but it does all all I need it to do including showing th progress of the backup, which visually is better than just a white page.

I would if possible like to sort these errors out and have a working script. Many thanks.

PHP V5.3.13
MYSQL V5.5.24
APACHE V2.2.22

<?php

/* 
* function - restoredata
* This function restore a database from the backup.
* It does'nt write all data at once. Writing has a defined limit. 
* Writing step by step controlled by/from Javascript
* This prevents PHP from going beyond Maximum Execution Time.
* uploadedfile - backup file
* ustartindex - offset, keeps row index of a table 
* uti - table index of databse
* ulen - number of tables in database	 
* ucount - number of rows in table
* name - table name	
* limit -self explanatory
* restoremethod -if '0' restore only data , if '1' recreate databse,drop and recreate tables and restore data
* */
function restoredata($uploadedfile, &$ustartindex, &$uti, &$ulen, &$ucount, &$name, &$limit, 

Open in new window

0
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
1
On Demand Webinar - Networking for the Cloud Era
LVL 8
On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

I need to document a a MySQL database.  Is there a tool that can scan the DB and detail out tables, etc.?
0
Have few queries related to MYSQL had google but did not got proper answer for the same.
1> There are three tables say A,B,C inter linked with each other .i.e A.id =B.a_id , B.id=c.b_id
Now if There sequential is insertion in A with ID "100" and then B but while inserting in C there is some issue and there is rollback so Does all record or A and B are revoked. If No then how does it follows Rollback facility. If yes then if there is insertion A then what would be its auto incremented value will it be 101 or 100 as previous 100 records is rollback.

2> These three table has huge data (2,000,000 + records in each table ) with paid and unpaid(how did just window shopping + who put the products in wish list ) user based on order no . I would say similar to AMAZON and i have to provide daily report of Paid user and unpaid user to mgmt. what method i have to use will it be plain mysql or some thing like hadoop or some other method has to be used.
Please guide as its taking huge time to fetch data all tables are normalized.
0
If I have names in a database that are found when users go to a page to search for names in my database - how can I get Google to also search the database for the same names - so they can show up in a Google search?

Pages re in PHP and data is in MySQL.

Or is it not possible?
0
DELIMITER $

CREATE PROCEDURE EXCEPTIONHANDLER (IN P_STUDENT_ID INT)

BEGIN
    DECLARE NOTEXISTS INT;

    BEGIN
    SELECT STUDENT_ID INTO NOTEXISTS
    FROM STUDENT
    WHERE P_STUDENT_ID = STUDENT_ID;
    IF NOTEXISTS != 15
    THEN SIGNAL SQLSTATE '45000'
    SET MESSAGE_TEXT = 'NO STUDENT_ID FOUND';
    END IF;
    END;

END$

DELIMITER ;


Hi. I want to create a stored procedure that shows a message when I put an ID which does not exist in student table. With the code above, when I call the procedure with the ID 15, as I put in the code, I do not get the message because I have ID 15. But when I call the code for the IDs that already exist in the student table, I still get the message. It shows that the code only works for the ID that I entered in the code (like 15). So, how can I make it work for all IDs?
0
See my below code.

$query_rs_media_new_group = "SELECT supplier_code, title, url, description, description_item, brand, type, weight, category, section, width, label_artwork, min(id) as id 
							 FROM media_new 
							 WHERE media_binder = '1'
							 GROUP BY title 
							 ORDER BY brand";
$rs_media_new_group = mysql_query($query_rs_media_new_group, $conn_cmyuk) or die(mysql_error());
$row_rs_media_new_group = mysql_fetch_assoc($rs_media_new_group);
$totalRows_rs_media_new_group = mysql_num_rows($rs_media_new_group);

Open in new window


The order by brand is not coming out in the correct order. Could this be something to do with the alias or group by?
0
The user provides my vb.net code with a SQL query that would look like this  for example:

select DISTINCT *from employees a INNER JOIN orders b on b.[Employee ID] = a.ID

I want to find a way to populate the datatable I create in code with the query columns and information but not actually get data. Is there a way to do this? The code also accepts queries from MySQL, MS Access, CSV as well as SQL.
0
I plan on purchasing a custom app that will utilize MySQL.  Does anyone know of some good training resources for training?  I'm open to in-person or web based.
0
I have seen some of the examples we have for pivot and unpivot in mysql,where the rows and columns are changes accordingly, but i have a table like below

 table1

Month    Current            30 Days       30 - 60 Days
Apr-13   1375159316       34511076         6423821
May-13   71398540         5674629          4775687
Jun-13   1314130060       27364660         9328588

and want it to create a new table like below

table2

Month            Apr-13               May-13              Jun-13
Current         1375159316      71398540     1314130060
30 Days         34511076        5674629          27364660
30 - 60 Days     6423821       4775687         9328588

How can i achieve the above.
0
Hi

I have a datatable and want that datatable to upload in a table in mysql. I have used bulkupload in sql, need to know how we can do the same using MySqlBulkLoader.

I dont want to give each and every column name of the table while upload and neither want to convert the datatable to cvs format.

Is there a way i can directly bulk upload using mysql from datatable directly?
0
What is SQL Server and how does it work?
LVL 1
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Hi,

I need little help with the query.
i.e I've following  table with products data:
id, store_id, title, price, is_store_own_product

Followng is the scenerio:

Stores can have their own products as well as other products. With each product we have boolean field "is_store_own_product" which shows its store own product also there can be 1 store selected all the time:

Now, I need to show all products for selected store i.e where (store_id = current_store_id AND is_store_own_product=0 or is_store_own_product=1) but also want to show other store products that are not their own i.e where (store_id <> current_store_id AND is_store_own_product=0).

I tried with "NOT IN" but its taking lot of time.

I hope this make sense.

Thanks a lot.
0
Hi experts.

I am coding a login system, However when I submit a registration form it just won't save the data into the database. im sure all my code is valid and can't seem to find the reason why??

no error messages are displayed and I have tested connection to the database and it connects fine.

I have set some code to echo "USER REGISTERED" if the data was submitted and stored in the database successfully but I can't get that message to show so there must be something im missing.

Please see code below, If you have any suggestions or spot any errors please let me know. Thanks.

login.php

<?php

// includes original html for login page
include('includes/header.php');
include('includes/login_form.php');
include('includes/footer.php');

/*
$sql = "select * from users"; // Pull user info from Database.
$result = query($sql);
confirm($result);
$row = fetch_array($result);

echo $row['username']; // Get username from database.
*/

?>

Open in new window


register.php

<?php

// includes original html for Create Account page
include('includes/header.php');
include('includes/create_account_form.php');
include('includes/footer.php');

?>

Open in new window


header.php

<?php include("functions/init.php"); // includes all code for login  
?>

<!DOCTYPE html>
<!------------------------------------------------------------------------------------------
WARNING!
Copyright (C) Mike Z Moore - All Rights Reserved
Unauthorized copying of this file, via any medium is 

Open in new window

0
Deploying MySQL in production
Join Percona’s Senior Operations Engineer, Daniel Kowalewski as he presents Deploying MySQL in production on Thursday, June 22, 2017 at 11:00 am PDT / 2:00 pm EDT (UTC-7). Register Here: http://hubs.ly/H07QN1h0
0
I want to create a stored procedure. When I search on student_id and if it does not exist, I need to set an “out_msg” parameter as “No Student ID Found”.
Secondly, I want to create an insert statement to insert student information ( INSERT INTO STUDENT (STUDENT_ID, NAME, GENDER) values (5,'x','M'); )   into student table. If the student_id already exists, I need to handle exception “1062” Duplicate entry found and set “out_msg” OUT parameter with a meaningful message.
Input and Output parameters are
 IN        STUDENT_ID INT
,OUT    OUT_MSG VARCHAR(100)
Any help, please?
0
Percona XtraDB Cluster, Galera Cluster, MySQL Group Replication
Join Percona’s MySQL Practice Manager Kenny Gryp and QA Engineer, Ramesh Sivaraman as they present Percona XtraDB Cluster, Galera Cluster, MySQL Group Replication on Wednesday, June 21, 2017 at 10:00 am PDT / 1:00 pm EDT (UTC-7). Register here: http://hubs.ly/H07QMYT0
0
My sample site URL : My working Site URL

I am trying to find a solution that will allow me to plot the GPS coordinates of many moving objects "live" on a Google Map.

The GPS coordinates of each object will constantly be updating into a MySQL database, and I'd like to know whether it is possible to read each updated coordinate, maybe once every couple of seconds, and re-plot the marker coordinates on the Google Map, without the user having to refresh the page.  Can this be done,?

would it also be possible to make each marker different, and each marker clickable to get more information on the particular object?

My map based on Jack Dougherty's FusionTable-Map-2-layers Template and running nicely on my hostgater server.

I have Traccar Open Source GPS Tracking Platform hosted with Amazone AWS and able to get tracker data to the mysql database, this database update every 30 second with live tracker data

# my db name “newTraccar” & all tracker data update for table `positions`

// -------------- Table structure for table `positions` ---------------------//

CREATE TABLE IF NOT EXISTS `positions` (
  `id` bigint(20) NOT NULL,
  `address` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `altitude` double DEFAULT NULL,
  `course` double DEFAULT NULL,
  `latitude` double DEFAULT NULL,
  `longitude` double DEFAULT NULL,
  `other` 

Open in new window

0

MySQL Server

46K

Solutions

61

Articles & Videos

22K

Contributors

MySQL is an open source, relational database management system that runs as a server providing multi-user access to a number of databases. Acquired by Oracle in 2009, it is frequently used in combination with PHP installations, powering most of the WordPress installations.