jeudi 13 août 2015

Amazon Aurora RDS unable to use import file . Access denied for user in Mysql Workbench

I have created an amazon aurora rds database instance and successfully connected with Mysql Workbench with master user.Queries are also working fine, But i do not have all the privileges necessary to perform file import operations. I have read many documentations and threads related to this but am not able to GRANT privileges to Master user. Step by step guidance will be highly appreciated. Thank You.



via Chebli Mohamed

Real Time Notification

I want to show notification into admin panel if any user insert a new ticket. that means if a new row inserted into ticket table then on admin panel show a notification and ticket count will be increased.

I cant understand How to do it. if any example available of laravel or CI or PHP then please share.

I am using laravel 4.2



via Chebli Mohamed

Arduino to MySQL via phpmyadmin

I'm trying to record arduino readings to a MySQL DB on a NetSol hosted MySQL DB via a WiFi shield. I'm using phpmyadmin (NetSol's interface) to manage the DB.

I'm using a variation of this Sketch to make it all happen: http://ift.tt/1TyQ1Qx

Everything is great until it gets to the "void postData{" piece. I know the IP of the phpmyadmin MySQL DB but it is not connecting. How can I get the arduino to connect to the DB?

I've been working on this for weeks and I'm three seconds from throwing my computer against a wall! This is very frustrating! I'm at the end of my rope and I hope you appreciate that I've exhausted just about every other learning option...help!

I'm using modified PHP files that the Sketch author recommended as well. I can see the empty table on my site. I just can't get the data into the DB.



via Chebli Mohamed

Getting rows of a day by timestamp, Day/Minute of certain pattern

id   name     quantity    timestamp
1    item1     2         2015-06-01 20:00:00
2    item2     5         2015-06-01 22:30:00
3    item3     2         2015-06-02 20:00:00
4    item4     7         2015-06-02 20:30:00
5    item5     9         2015-06-02 21:30:00

This is an example database, 'timestamp' is in datetime format and contains varying values. Note that the table contains various date and time data. How do i get all the rows of one day and of certain minute(above eg: 30) only, eg how can i select all the rows with timestamp 2015-06-01 **:30:00, here ** = hour any help, thanks.



via Chebli Mohamed

How to install MySQL Http Plugin on Windows 7?

I have MySQL 5.7 installed on my Windows 7 system. Can anyone help me with the instructions to install the experimental Http Plugin?



via Chebli Mohamed

HttpURLConnection to use connect to php Error:Server returned HTTP response code: 500 for URL:

I'm using java to read from an excel file and put that data into variables, then send those variables to php where it will get processed and inserted into a mysql database. The database wont allow me to directly insert into the database, so I'm doing a work-around. I get this error when I run my program. "Server returned HTTP response code: 500 for URL:" This happens when it gets to the conn.getOutputStream(); If someone knows how i can fix this on the server side please let me know so that I can try to fix it

String link="http://website/directory/file.php";
            String data  = URLEncoder.encode("fName", "UTF-8")
                    + "=" + URLEncoder.encode(fName, "UTF-8");
            data += "&" + URLEncoder.encode("lName", "UTF-8")
                    + "=" + URLEncoder.encode(lName, "UTF-8");
            data += "&" + URLEncoder.encode("SID", "UTF-8")
                    + "=" + URLEncoder.encode(SID+"", "UTF-8");
            data += "&" + URLEncoder.encode("email", "UTF-8")
                    + "=" + URLEncoder.encode(email, "UTF-8");
            data += "&" + URLEncoder.encode("major", "UTF-8")
                    + "=" + URLEncoder.encode(major, "UTF-8");
            data += "&" + URLEncoder.encode("year", "UTF-8")
                    + "=" + URLEncoder.encode(year, "UTF-8");
            data += "&" + URLEncoder.encode("isPaid", "UTF-8")
                    + "=" + URLEncoder.encode(isPaid+"", "UTF-8");
            data += "&" + URLEncoder.encode("isNational", "UTF-8")
                    + "=" + URLEncoder.encode(isNational+"", "UTF-8");
            URL url = new URL(link);
            //Did the CookieHandler just in case the server wants them
            CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL));

            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setDoOutput(true);

            OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
            wr.write( data );
            System.out.println("data was passed");
            wr.flush();
            BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            StringBuilder sb = new StringBuilder();
            String line = null;

            // Read Server Response I'm using echo . ie: echo "yes";
            while((line = reader.readLine()) != null)
            {
                sb.append(line);
                break;
            }
            System.out.println(sb.toString());
        }
            if(sb.toString().equals("yes"))
            {
                ttlAffected++;
            }
            else if(sb.toString().equals("no"))
            {
                System.out.println("Student ID: "+array.get(rowOn).getSID()+" already exists");
                fail.add(array.get(rowOn).getSID());
            }
            else if(sb.toString().equals("error"))
            {
                System.out.println("An unknown error occured");
                fail.add(array.get(rowOn).getSID());
            }
            else
            {
                System.out.println("IDk what happened        "+  sb.toString());
            }

Also, here is the php side

    <?php
    $con=mysqli_connect("host","username","password","database");
    if (mysqli_connect_errno($con))
{
   echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$_SESSION['fName']=$_POST['fName'];
$_SESSION['lName']=$_POST['lName'];
$_SESSION['SID']=$_POST['SID'];
$SID=$_SESSION['SID']
$_SESSION['email']=$_POST['email'];
$_SESSION['major']=$_POST['major'];
$_SESSION['year']=$_POST['year'];
$_SESSION['isNational']=$_POST['isNational'];
$_SESSION['isPaid']=$_POST['isPaid'];


$sql ="SELECT * FROM Registered_Members15 WHERE SID='$SID'";
$result = mysqli_query($com,$sql);
if(mysqli_num_rows($result)==0)
{
                                        $query_member = "INSERT INTO Events15(id,SID) VALUES (?, ?)";
                                        $stmt_member = mysqli_prepare($con,$query_member);
                                        mysqli_stmt_bind_param($stmt_member, "si" , $_SESSION['email'], $_SESSION['SID']);
                                        mysqli_stmt_execute($stmt_member);
                                        $affected_rows_mem = mysqli_stmt_affected_rows($stmt_member);
                                        mysqli_stmt_close($stmt_member);

                                        $query = "INSERT INTO Registered_Members15(ID,first_name,last_name,SID,email,paid_chapter,paid_national,major,year)  VALUES (NULL,?, ?, ?, ?, ?, ?, ?, ?)";
                                        $stmt = mysqli_prepare($con, $query);
                                        mysqli_stmt_bind_param($stmt, "ssisiiss", $_SESSION['fName'], $_SESSION['lName'], $_SESSION['SID'], $_SESSION['email'], $_SESSION['isPaid'], $_SESSION['isNational'], $_SESSION['major'], $_SESSION['year']);
                                        mysqli_stmt_execute($stmt);

                                         $affected_rows = mysqli_stmt_affected_rows($stmt);
                                        if($affected_rows == 1 && $affected_rows_mem == 1)
                                        {
                                                echo "yes";
                                        }
                                        else
                                        {
                                            echo "error";
                                        }
}else{
    echo "no";
}

mysqli_close($con);

?>

I believe this is all right but I do want to ask if someone could check if i did something wrong.



via Chebli Mohamed

My sql , join tables with dynamic fields

i want to use @mm as global scope var and use it value in second and 3rd tables.(even dummy field to join ) anyone has idea? thanks

select a.totalL,b.totalR, @mm:=c.plac from users as c inner join (SELECT SUM(amnt) as totalL ,type,@mm as MN FROM gb WHERE amnt> 0 AND plac_id LIKE concat(@mm,'1%')

AND (DATE(date1) BETWEEN DATE('2015-06-23 00:00:00') AND DATE('2015-08-13 23:59:59') ) AND type=10 ) as a on c.plac = a.MN inner join (SELECT SUM(amnt) as totalR ,type,@mm as MN FROM gb WHERE amnt> 0 AND plac_id LIKE concat(@mm,'2%') AND (DATE(date1) BETWEEN DATE('2015-06-23 00:00:00') AND DATE('2015-08-13 23:59:59') ) AND type=10 )as b on a.type = b.type



via Chebli Mohamed