MySQL Server

47K

Solutions

23K

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

Hi

I want to create a detailed user log.

currently, I have created a table that stores the Id, date, userId, table name and table id.

if I run a query it works fine to display basic details. however, if I want to display the contents of the table name and Id I inserted I run into a crappy situation where I would need to create a procedure. the procedure would run the basic select and dynamically join the other table based on the table name and table id I inserted into the log database.

another problem is that not at tables are the same therefore this method would only partially work anyways.

the table names field is manually added when adding the log data set

how can I accomplish a nice log?
0
10 Tips to Protect Your Business from Ransomware
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

I would like to call a stored procedure in one database from another database using a variable for a name.

call dbone.stored_procedure_name works when I use the database name but I would like to call it by setting a variable for the database name.

set mydb='dbone';

call mydb.stored_procedure_name;


Is this possible and if so what is the syntax?
0
So I have been using MSSQL 2012 for a while now and I like it.  I am developing an aspx webform which requires that I host the page and database.  I found a good hoster but the database they utilize is MYSQL.

First of all are there any significant performance differences between the full SQL and MYSQL.  Would it be simple to convert my database to MYSQL?  Are there any size limitations to MYSQL?  Any other notable differences?
0
PHP - MySQL

I am attempting to create a page that uploads images and saves them for viewing for members who belong to a website.

The page is posting to itself but not putting anything into the database, not letting the viewer know it has been uploaded OR giving any kind of error message. I took out one of the fields – description – as it is not needed so I am wondering if there is anything in the code that still refers to this field and the rest of the data is just not going into the database to begin with. My database columns are – file_name, file_size, file_type.

<?php 

require ('./includes/config.inc.php');

require (MYSQL);

$counter = 3; // Number of files to allow for.

if (isset($_POST['submitted'])) { // Handle the form.

	//require_once ('mysql_connect.php'); // Connect to the database.
	
	for ($i = 0; $i < $counter; $i++) { // Handle each uploaded file.
	
		// Create index names to refer to the proper upload and description.
		$filename = 'upload';
	
		// Check for a file.
		if (isset($_FILES[$filename]) && ($_FILES[$filename]['error'] != 4)) {

			
			// Add the record to the database.
			$query = "INSERT INTO notices (file_name, file_size, file_type) VALUES ('{$_FILES[$filename]['name']}', {$_FILES[$filename]['size']}, '{$_FILES[$filename]['type']}')";
			$result = mysql_query ($query);
		
			if ($result) {
				
				// Return the upload_id from the database.
				$upload_id = mysql_insert_id();
				
				// Move the file over.
				if 

Open in new window

0
Dear Experts

it is observed the  crm application running on LAMP stack often crashes, users unable to use the application webserver is on one server and database mysql 5.5 is on another server did perform the mysql tuner and attached is report, the system has 64G RAM as per the recommendations from mysql tuner can I set my.cnf as per the following, please suggest
total physcial ram capacity is 64G
based on the mysql tuner recommendations should I have to to set as per the below
innodb_buffer_pool_size = 55.2G
innodb_log_file_size= 25% of above i,e 55.2 which is 13.75G
please suggest can I change in my.cnf as above.
mysql-tunerlog.txt
0
Dear Experts

application server web-based of LAMP stack becomes extremely slow and makes application unable to use, web-server(application file system) is having 16GB Ram and database server is separate with 64GB ram and did run mysql tuner attached for your reference below posted recommendation section, when try to set values as recommended mysql fails to start  withe following error log, please help on what values to set so that below error is fixed, thank youmysqltuner12.txt
Plugin 'InnoDB' init function returned error.
180911 14:18:19 Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
180911 14:18:19 Unknown/unsupported storage engine: InnoDB
180911 14:18:19 Aborting

Below -extract of recommendations section from the attached

-- Recommendations ---------------------------------------------------------------------------
General recommendations:
    Control warning line(s) into /var/log/mysqld.log file
    Control error line(s) into /var/log/mysqld.log file
    Set up a Password for user with the following SQL statement ( SET PASSWORD FOR 'user'@'SpecificDNSorIp' = PASSWORD('secure_password'); )
    Restrict Host for user@% to user@SpecificDNSorIp
    MySQL was started within the last 24 hours - recommendations may be inaccurate
    Reduce your overall MySQL memory footprint for system stability
    Dedicate this server to your database for highest performance.
    Adjust your join queries to always utilize …
0
I want to get the past 3 months sales data and display it something like:

August 2018 - $.....
July 2018 - $....
June 2018 - $.....

I have tried something like this:

        $this->db->query("SELECT SUM(`order_total`) as `totalSales`
        FROM `order_summary`
        WHERE `order_date` >= LAST_DAY(NOW()) + INTERVAL 1 DAY - INTERVAL 3 MONTH
        ");
        $results = $this->db->resultSet();
        return $results;

Open in new window


And I tried to put `order_total` in a foreach loop but it just spits out one figure. I am guessing there is something wrong with the SQL query?
0
Hi, i am runing program on Node-Red. The data format in JASON. I am trying to pull out "payload": "Open" and insert into mysql. No errors but the data in sql state as [object OBJECT] . Did attached the database field.

test2 : msg : Object
object
topic: "test2"
payload: "Open"
qos: 0
retain: false
_topic: "test2"
_msgid: "2356ede6.954ba2"

Open in new window


var temp;

temp ={"payload":msg.payload};
msg.topic = "insert into ctesting (data1) values ('"+temp+"')";


return msg;

Open in new window

db.png
0
I wrote an Access database about 18 years ago for the data entry of client data. Now I want to develop a web data entry system, so the clients can enter their own data. I have 45 years of traditional programming and Access experience. But I find developing for the web, very different. Can anyone suggest how I can go about learning how the web pieces work together, preferably with examples and how a framework is used. At some point, I'd be happy to pay for teaching, mentoring and support, but in the end I want to be able to support it myself. The application is very simple. There are over 100 clients to support; a few thousand records a month in total; monthly invoicing. It was suggested that I develop with PHP, MySQL and Javascript. I saw a course with Expert Exchange for using CakePHP, so I thought that I would start with that and see where to go after that.
0
Dear experts!

I am just wondering if there is a way for me to convert information from relational database such as MSSQL, MySQL etc... into a NO SQL or simply something like memcache in a key -value pair? This is what I want to achieve:

1. instead of having user hitting the SQL DB with requests when they want to get product information etc....
2. store the information into NO SQL or memcache (for a faster and dynamic data retrieval)
3. block the user from hacking SQL DB with sql injection
4. allow a faster update with the data by updating product information in NO SQL or memcache from the SQL DB. ****(I wish to know some good suggestions if I can have a real time update) **** before I have 2 SQL DB and using bash script to do the product information sync like every 30mins or so

Any good idea is appreciated. Thanks!
0
Newly released Acronis True Image 2019
Newly released Acronis True Image 2019

In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.

Hello Experts!

I need help on the following:

Assuming myTable has the following data:
id         Name        Class          Subject        Marks
1          Stu1           SS1A          Eng               40
2          Stu2           SS1A          Eng               50
3          Stu3           SS1B          Eng               60
4          Stu1           SS1A          Maths          45
5          Stu2           SS1A          Maths          55

How can I achieve the following in report using either WHILE LOOP or FOREACH or mysqli_fetch_fields or whatever (Note: number of Subject above (that will form columns) is unknown)?

Class_Name: SS1A
SN       Name         Eng           Maths         No_of_Subjects
1          Stu1            40             45                2
2          Stu2            50             55                2

Thank you so much in advance.
0
When using pymysql, is there a way to connect to MySQL database using a login-path created with mysql_config_editor?
0
Can you create a pdf file & then "save" it as a blob type in a MySQL database?

I use FPDF; one output option is a string, which I could then save as the blob.

But then (later) when a user clicks a button (now it's a submit, could be ahref=), how can I read the blob & open it in a new window where the blob is just the pdf)
0
I have a mark as favorite resource section in my application that needs to add the resource ID, and user ID to the database so that it will show under the users favorite resources list. The problem that I am having is that no matter which resource the user selects it always adds the first resource listed to the database. I am not getting the proper ID for the resource and need help with this. Here is the code for the favorite resource selection portion.
<aside class="course-details__resources">
						<h3>Resources</h3>
						<p class="instruction">Mark resources as favorites with the heart icon: <img src="images/learncom/resources/favorite-resource--off.png" alt="Favorite resources icon" />.&ensp;Favorite resources appear on the home page for quick access.</p>
						<ul class="resource-list">
						<?php $result_resources= mysqli_query($database_link, ("SELECT * FROM course_resources WHERE CourseID = '$course_id' ORDER BY Filename"));
							while ($rowresources = mysqli_fetch_assoc($result_resources)) {?>	
								
								<li class="resource--pdf"><a href="resources/<?php echo $rowresources['LinkURL']; ?>" target="_blank"><?php echo $rowresources["Filename"] ?></a><input class="favorite-resource-checkbox" id="favorite-resource-checkbox-<?php echo $rowresources["ID"] ?>" type="checkbox" value="<?php echo $rowresources["ID"] ?>" name ="<?php echo $rowresources["Filename"] ?>">
            <label for="favorite-resource-checkbox-<?php echo $rowresources["ID"] 

Open in new window

0
Need help configuring email to work with Mantis Bug Tracker. I have configured it according to the instructions provided by the vendor. I have attached a screenshot of the config_inc.php. All login info defined is correct. The issue is nothing happens. Nothing is triggering an email.
Any help will be greatly appreciated.
Capture.JPG
0
Hello,

 My site  work on drupal and mysql. Suddenly, it start to give me

"PDOException: SQLSTATE[HY000]: General error: 1364 Field 'item_id' doesn't have a default value: INSERT INTO {queue}........ "

"PDOException: SQLSTATE[HY000]: General error: 1364 Field 'vid' doesn't have a default value: INSERT INTO {node_revision}....."

 

The same sentence appears with different table name and variables whenever I do any action on the website.

 

The database is not in “Strict mode”. I added this

sql_mode = ""

to my.ini

 

but still not working

 

Please help


Thank you.
0
Hi,

i wane create a database driven text box ,
what i mean whit that,when I or someone ells type a word  ( whit scripting ).
the textbox look-up into the database to find relevant word.
<FORM action="index.php" method = "post">
<CENTER><p> <input tipe="text" name="find" > <button tipe="button">Zoek !</button><br></CENTER>
</FORM>

Open in new window

0
Hi, i am trying to rearrange data in new table upon INSERT active in "BREAK_TBL"

Current application do have the following options which written in c# to determine working hours.

                            Start Time                                      End Time                                     CheckBox
Working Hrs      2018-09-05 08:15                          2018-09-05 19:50                      True      (if unchecked then default working hrs are from 08:15 ~ 17:15)
Break 1              2018-09-05 10:10                          2018-09-05 10:35                       True
Break 2              2018-09-05 12:00                          2018-09-05 12:35                       True
Break 3              2018-09-05 15:45                          2018-09-05 16:00                       True
Break 4              2018-09-05 17:20                          2018-09-05 17:50                       True
Break 5              2018-09-05 10:10                          2018-09-05 10:10                       False

The above data area successfully updates in MariaDB in "BREAK_TBL". Upon Insert into BREAK_TBL , I have to trigger another table for my further analysis. Its suppose to arrange in the following format to determine my working our period for every interval.

                            Start Time                                      End Time                              CheckBox
Set 1              2018-09-05 08:15                          2018-09-05 10:10          …
0
<?php
session_start();
echo $_SESSION['comp'];

 $company = $_SESSION['comp'];
//set random name for the image, used time() for uniqueness
require_once('db.php'); 
$filename =  time() . '.jpg';
$filepath = 'uploads/';
if(!is_dir($filepath))
	mkdir($filepath);
if(isset($_FILES['webcam'])){	
	move_uploaded_file($_FILES['webcam']['tmp_name'], $filepath.$filename);
	$sql="Insert into webcam_images(companyName, imgpath) values('$company','$filename')";
	$result=mysqli_query($con,$sql);
	echo $filepath.$filename;
}
?>

Open in new window


The above code works if I substitute the '$company' variable with, for example 'testname'
Both values are entered into the database
It looks as if the '$company' variable is not being recognised even though it is set (I have tested this with an echo command)

Any ideas ?
0
Exploring SharePoint 2016
LVL 12
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

Insert php page:
<?php require_once('incMultiDBConnection.php'); ?>
<?php 


$insert = $db->prepare("INSERT INTO inventasequipment (equip_companyname, equip_name, equip_type, equip_sn, equip_productno, equip_website, equip_support, equip_use, equip_purchasedate, equip_warrenty, equip_performance, equip_comments, equip_cost, equip_datevisited, equip_timefrom, equip_timeto) VALUES (:company, :name, :type, :sn, :pn, :web, :support, :use, :purchase, :warrenty, :perf, :comments, :cost, :visitdate, :timefrom, :timeto)");

foreach ($_POST['equip'] as $equipment):
    $insert->execute([
        'company' => $equipment['companyname'],
        'name' => $equipment['equipname'],
        'type' => $equipment['equiptype'],
        'sn' => $equipment['equipsn'],
        'pn' => $equipment['equippn'],
        'web' => $equipment['equipweb'],
        'support' => $equipment['equipsupport'],
        'use' => $equipment['equipuse'],
        'purchase' => $equipment['equippurchase'],
        'warrenty' => $equipment['equipwarrenty'],
        'perf' => $equipment['equipperf'],
        'comments' => $equipment['equipcomments'],
        'cost' => $equipment['equipcost'],
        'visitdate' => $equipment['equipvisit'],
        'timefrom' => $equipment['equiptimefrom'],
        'timeto' => $equipment['equiptimeto'],
    ]);
endforeach;



?>

Open in new window


The above code works in that the first set of data is passed to the database correctly but the second set is only passed to the database with the first character of the text string from each text input box from the input form:

Input form:

Open in new window

0
I need to update all the rows in a MySql table like this:

START TRANSACTION;
update product set  t1="t1" where p_id=40717;
update product set  t1="3" where p_id=40713;
.....
commit;

Open in new window


The problem is that there can be thousands of rows and it is very slow.
Is there a better way to do it?

Thank you!
0
I'm trying to write to two mySQL tables at the same time.  I have been able to write a test field, but I am trying to write a var to the table.  I want to write the record number ($theRN)  of the first table into the second table.  This is my code:

===================================================
if ((isset($_POST["InsertProducts"])) && ($_POST["InsertProducts"] == "form1")) {
  $insertSQL2 = sprintf("INSERT INTO Products (Name, Display_Name, Brief_Description, Part_no, Short_name, Change_Date, Base_Price, Bullet1, Bullet2, Bullet3, Bullet4, Model_No, Large_Image, Tax_Item, Handling_Fee, Weight, Ship_Using_Old, Postage_Is) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s,   %s, %s, %s, %s, %s, %s, %s, %s )",
                                      GetSQLValueString($_POST['name'], "text"),
                                 GetSQLValueString($_POST['title'], "text"),
                                 GetSQLValueString($_POST['description'], "text"),                                 
                                 GetSQLValueString($_POST['Product_no'], "text"),
                                 GetSQLValueString($_POST['Product_no'], "text"),                                 
                                          GetSQLValueString($_POST['today'], "date"),
                                 GetSQLValueString($_POST['SubTotal_pri'], "double"),         
                                  GetSQLValueString($_POST['title'], "text"),
                                 GetSQLValueString($_POST['project'], "text"),
                                          GetSQLValueString($_POST['HUsername'], "text"),                                                
                                          GetSQLValueString($_POST['quote_no'], …
0
Hi Experts!

Could you point a good (didactic) material preferencialy that you know about AWS web service creation by using PHP?

Thanks in advance
0
My title is that it's complicated. Complicated for me that is :-P

When a product is purchased it goes into a product summary and product detail table. The product detail table holds info like the order id and then each item that was ordered as well as the qty.

Here is the basic structure

order_detail_id (primary key)
order_id
product_id
product_qty
product_price (this is the price of the item at the time of purchase)

Then at the same time, data is inserted into a coupon/voucher table but that table holds no item price.

I am trying to join the 2 tables but having difficulty in getting the product price.

The voucher/coupon table:

voucher_id
product_id
serial (serial number of the voucher/coupon)
rep (sales rep)
purchased (date of purchase)
order_id
customer_id

I want to show each voucher serial number with the price it was sold for. But I can't seem to get it right. The prices don't match up with the serial or it shows duplicate serials.

        $this->db->query("SELECT `serial`, `purchased`, `vcs_code`, `prod_name` FROM `vouchers` AS `v`
        INNER JOIN `order_summary` AS `os` ON os.`order_id` = v.`order_id`
        INNER JOIN `bb_products` AS `bbp` ON bbp.`prod_id` = v.`product_id`
        INNER JOIN `order_detail` AS `od` ON od.`order_id` = v.`order_id`
        WHERE `rep` = :rep
        ORDER BY `purchased` DESC
        LIMIT 10
        ");
        $this->db->bind("rep", $_SESSION['rep_id']);
        $results = 

Open in new window

0
I have a php while loop that I need to increment through a MySQL multi query. The first time around, it writes to the database as intended. But as soon as it loops around once, I get the following Query Error:

Commands out of sync; you can't run this command now

Here's the loop containing the query:

$i = 285;
while ( $i <= 286 ) {
	$sql = "
		CREATE TEMPORARY TABLE links_temp SELECT * FROM links WHERE 
			schoolid = 0 
			AND planid >= 8000
			AND planid <= 8005;	
		UPDATE links_temp SET linkid = NULL, schoolid = {$i} WHERE 
			schoolid = 0;
		INSERT INTO links SELECT * FROM links_temp;
		DROP TEMPORARY TABLE IF EXISTS links_temp;
	";
	$result = mysqli_multi_query( $conn, $sql ) or die( "Query Error: " . mysqli_error( $conn ) );
	$i++;
}

Open in new window


What do I need to do to enable this query to loop successfully?
0

MySQL Server

47K

Solutions

23K

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.