jazzman1
Staff Alumni-
Posts
2,713 -
Joined
-
Last visited
-
Days Won
12
Everything posted by jazzman1
-
Post out the lines from 160 to 163. What your text/code editor is?
-
Some good php IDEs can help with this syntax error(s).
-
I think, it would be better off if you post the script using code "<>" tags rather than a file attachment.
-
3 different ways come in my mind: 1. Using cURL 2.Using stdin passing variables into a terminal 3. Using iframe with hidden content The easiest way is curl. Example: form.php <?php session_start(); if(isset($_GET['submit'])){ // create a new cURL resource $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://192.168.122.159/pdo/index.php?action=".$_GET['name']); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0"); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // grab URL and pass it to the output variable $output = curl_exec($ch); // close cURL resource, and free up system resources curl_close($ch); $_SESSION['output'] = $output; // save output in session // redirect the output from our variable to the browser header('Location: display.php'); exit; } ?> <form action="form.php" method="get"> Name: <input type="text" name="name" /> <input type="submit" name="submit" value="Send!!" /> </form> index.php (second page, it shouldn't be visible) <?php $name = $_GET['action']; // $inQuery = implode(',', array_fill(0, count($names), '?')); $sql = "SELECT * FROM sakila.actor WHERE first_name IN(:name)"; $username = 'lxc'; $password = 'password'; $dbh = new PDO('mysql:dbname=sakila;host=::1;charset=utf8', $username, $password); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // insert some data using a prepared statement $stmt = $dbh->prepare($sql); // bind php variables to the named placeholders in the query // they are both strings that will not be more than 64 chars long $stmt->bindParam(':name', $name, PDO::PARAM_STR, 64); $stmt->execute(); $row = $stmt->fetchAll(PDO::FETCH_ASSOC); echo "<pre>".print_r($row, true)."</pre>"; $stmt = null; display.php <?php session_start(); echo "<h2>Output of display page</h2>"; echo "<p>Hello freaks</p>"; echo "<h2>Output of index page</h2>".$_SESSION['output']; Result: PS: If your site requires cookies, you should include CURLOPT_COOKIEFILE and CURLOPT_COOKIEJAR to cURL script.
-
Compare outputs of select SQL command! SELECT YEAR(2014-01-12) TO SELECT YEAR(CURDATE()).
-
I moved your thread to the Ajax section. What have you tried so far? Show us the code.
-
http://www.xul.fr/en-xml-ajax.html ops....this is with php - http://www.xul.fr/ajax/ajax-php.php
-
Get the data from mysql and fill up the options/values to the first drop-down list, then use Ajax and javascript onselect event to populate the data to the second one based on your query to database. Do you know what Ajax does?
-
This is only an example how to enable/disable the second dropdown list based on selected options of first one.
-
In addition, why are using utf8_bin? You're comparing a string by the binary data(value) or what?
-
Unzip tar.Z file and check fianlename date by Shell Script
jazzman1 replied to PriteshP23's topic in Linux
Hey @PriteshP23, in my example I'm checking the current date with DAY=`/bin/date +%u` and returns the current day from 1-7 (Monday-Sunday). If the current day is 1 (Monday) then I'm checking the string of the file which contains the date 3 days ago in a format (20140103) for instance - my_file_20140103_1540.tar.Z then unzip the file. If the current day is 6 or 7 (Saturday or Sunday) it doesn't do anything with the file of Friday. However, for others days (Tuesday - Friday) it makes changes to the file with a date of yesterday. Or... am I missing something in my script? Did you test it? -
Why not? Show us the tables structure.
-
Yeap, I agree with cyber using JS here. Take a look at my example. It's a little ugly but it would help to understand the logic. <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type="text/javascript"> // <![CDATA[ function changeFunc() { var count; var list1 = document.form1.Dept.options var list2 = document.form1.students for (count = 0; count < list1.length; count++) { if (list1[count].selected) { if (list1[count].value == '') { list2.disabled = true } else { list2.disabled = false } } } } // ]]> </script> <title>Drop-down list</title> </head> <body> <form action="" method="post" name="form1"> Dept: <select name="Dept" onchange="changeFunc();"> <option value="" selected>Select Dept....</option> <option value="1">Option #1</option> <option value="2">Option #2</option> <option value="2">Option #3</option> </select> Students: <select name="students" disabled="disabled"> <option value="1">Option #1</option> <option value="2">Option #2</option> <option value="2">Option #3</option> </select> </form> </body> </html>
-
GET and POST variables are associative arrays of variables passed to the current script via the URL and HTTP POST method. Maybe you want to create an array contains key/value of these vars and then to compare their keys/values? Could you be more specific, please?
-
Since I don't know the values of status field, I'm going to use the default 1,2,3 in a CASE. Try, SELECT t_u.*, t_a.access_lvl, t_a.biz_name, CASE status WHEN 'open' THEN 1 WHEN 'rejected' THEN 2 WHEN 'closed' THEN 3 END AS s_type FROM uploads_rf AS t_u, user_accts AS t_a WHERE t_u.project_id = '8' AND t_u.pipeline_item = 'rf' AND t_a.email = t_u.author ORDER BY FIELD(status, 'open', 'rejected', 'closed')
-
-
Very good The path was the problem.
-
Hey folks, does anybody have an idea why the LOAD_FILE() doesn't work for me? I'm trying to store a binary data(picture) in the table named - picture. As you can see the type of IMAGE field is set to "LONGBLOB" According docs, the uploaded image is located on the same file server where the MySQL is deployed and the user named "lxc" has the FILE privilege to this DB table. The max_allowed_packet bytes is set to 500M inside mysql conf file and there is no issue with secure_file_priv. The command that I'm running into linux terminal is simple: [lxc@lxc1 pdo]$ echo "INSERT INTO picture VALUES(NULL,LOAD_FILE ('images/Tree_2.jpg'))" | /usr/bin/mysql test -h ::1 -u lxc -ppassword The file is there and the user "lxc" is the owner of that file with r/w priv. So, when I run the mysql command line, LOAD_FILE() function returns NULL, but the ID is stored correctly. There is no such kind of issue when I'm uploading a binary data with php using file_get_contents() (without LOAD_FILE()), what I usualy do. <?php $username = 'lxc'; $password = 'password'; $img = file_get_contents('images/Tree_2.jpg'); $sql = "INSERT INTO picture VALUES(NULL, ':binary')"; //$sql = "select * from picture where ID=13"; $dbh = new PDO('mysql:dbname=test;host=::1;charset=utf8', $username, $password); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stmt = $dbh->prepare($sql); $stmt->bindParam(':binary', $img, PDO::PARAM_STR); $stmt->execute(); $stmt = null; PS: Server version: 5.5.35 MySQL CentOS 6.4/GNU/Linux machine
-
Unzip tar.Z file and check fianlename date by Shell Script
jazzman1 replied to PriteshP23's topic in Linux
Check the possibilities first. Try this: #!/bin/bash DIR=$(dirname $0) YESTARDAY=`/bin/date +%Y%m%d -d "yesterday"` DAY3AGO=`/bin/date +%Y%m%d -d "3 day ago"` DAY=`/bin/date +%u` case ${DAY} in 1) dateQ=${DAY3AGO} ;; 6|7) dateQ='WEEKEND' ;; *) dateQ=${YESTARDAY} esac if [ ${dateQ} -ne 'WEEKEND' ]; then zcat ${DIR}/my_file_${dateQ}*.tar.Z | tar xvf - else echo "It's a weekend time" exit 0 fi PS: The code of your bash script was very hard for everyone to understand what do you want to accomplish, so take mine and ask me if you don't understand something. I think it's clear enough, but.... -
And your contact form is.....?
-
If you had you can easily check if the content exists in mysql without running any GUI database tools. echo "SELECT COUNT(*) FROM db_name.tbl_name WHERE 1" | /usr/bin/mysql db_name What about the mysql command line tool? Are you able to use it? Try next: echo "SELECT COUNT(*) FROM db_name.tbl_name WHERE 1" | /usr/bin/mysql db_name -u userName -ppassword -h hostaddress
-
Do you have a root access to the file server where the DB is deployed?
-
The properties such a name, method, target, value and so forth in form are used with next syntax: document.formname.controlname.property. Formname is the name of the form of the document, controlname is the name of the control and the property is the name of the property you wish to use. So, using the patern below you can return the value of the value property very easy. document.myForm.DeptNo.value Instead of formname you could use forms[x] where "x" represents the number of the form in the document, numbering starts with 0 index for the first form in the document such as document.forms[0]. So, to achieve the same result you can use next: document.forms[0].DeptNo.value or document.forms[0][0].value where the second array with index 0 is the controlname of the form or references by name such as document.forms['myForm']['DeptNo'].value.
-
You shouldn't use a set (series) of nested loops to select data from the tables in the way you done. We still need to know, what the structure of those given tables is? http://dev.mysql.com/doc/refman/5.0/en/getting-information.html
-
GMail restricts using random addresses from your personal account. To change that, open up your gmail account and add another mail address you own. Settings -> Accounts -> Add another email address you own