jazzman1
Staff Alumni-
Posts
2,713 -
Joined
-
Last visited
-
Days Won
12
Everything posted by jazzman1
-
Unfortunately, I'm not using phpmailer to provide an efficacious help. However, it leads me to believe that you haven't returned any rows from database. It's a bad practice also to send two different sql select statements using looping application's constructs to return data from 2 or more tables and columns. Use "JOIN" instead! Do "DESCRIBE" to provide information about those 2 tables and their columns.
-
Yea, it worked for me. Just create two arrays ( find and replace) as the example shown above for Greek alphabet ( capital and lowercase) and make sure that every gibberish chars matched to the correct greek one, or just create one array something below that returns keys and their all associative values of an array. $array_chr = array( '~Κ~'=>'Κ', '~α~'=>'α', '~λ~'=> 'λ' //ect.... );
-
Take a look at my testing script which I wrote for you, it might be useful somehow. For the test I'm using the Greek word - Καληπέσα. 1) Create a testing table thread into database named - test! CREATE TABLE `test`.`thread` ( `thread_id` INT UNSIGNED NOT NULL AUTO_INCREMENT , `thread_name` VARCHAR(45) NOT NULL , PRIMARY KEY (`thread_id`) ) DEFAULT CHARACTER SET = latin1; 2) Insert greek words/phrase - (Καληπέσα); (Καληπέσα , good evening 2); (Καληπέσα , good evening 3); INSERT INTO `test`.`thread` (`thread_name`) VALUES ('Καληπέσα'),('Καληπέσα , good evening 2'),('Καληπέσα , good evening 3')" // result of this gibberish data after the rows selecting Array ( [0] => ΚαληπÎσα [1] => ΚαληπÎσα , good evening 2 [2] => ΚαληπÎσα , good evening 3 ) 3) Change column thread_name to utf8 charset ALTER TABLE `test`.`thread` CHANGE COLUMN `thread_name` `thread_name` VARCHAR(45) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' NOT NULL; 3) Replace this gibberish content using php language and its preg_replace function // data before and after replacement: Array ( [0] => ΚαληπÎσα [1] => ΚαληπÎσα , good evening 2 [2] => ΚαληπÎσα , good evening 3 ) Array ( [0] => Καληέσπα [1] => Καληέσπα , good evening 2 [2] => Καληέσπα , good evening 3 ) 4) Do an update to these columns. UPDATE `test`.`thread` SET `thread_name`= CASE `thread_name` WHEN 'ΚαληπÎσα' THEN 'Καληέσπα' WHEN 'ΚαληπÎσα , good evening 2' THEN 'Καληέσπα , good evening 2' WHEN 'ΚαληπÎσα , good evening 3' THEN 'Καληέσπα , good evening 3' END WHERE thread_id IN (1,2,3) 5) Results from database after the final update: Array ( [0] => Καληέσπα [1] => Καληέσπα , good evening 2 [2] => Καληέσπα , good evening 3 ) 6) Application script: <?php $username = 'lxc'; $password = 'password'; $dbh = new PDO('mysql:dbname=test;host=::1;charset=utf8', $username, $password); // charset=latin1 when you're inserting values $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); //$stmt = $dbh->prepare("INSERT INTO `test`.`thread` (`thread_name`) VALUES ('Καληπέσα'),('Καληπέσα , good evening 2'),('Καληπέσα , good evening 3')"); //$stmt->execute(); $stmt = $dbh->prepare("SELECT thread.thread_name FROM test.thread"); $stmt->execute(); $data = array(); $arr_r = array(); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $data[] = $row['thread_name']; } //create arrays of substitutions $find = array('~Κ~', '~α~', '~λ~', '~η~', '~Î~', '~σ~', '~Ï€~', '~Î~', '~Ï~'); $replace = array('Κ', 'α', 'λ', 'η', 'σ', 'π', 'έ', 'ρ'); $count = count($data); for ($i = 0; $i < $count; $i++) { // replace gibberish characters with greek words $arr_r[] = preg_replace($find, $replace, $data[$i]); } // display the old data //echo '<pre>' . print_r($data, true) . '</pre>'; // display the replaced data //echo '<pre>'.print_r($arr_r,true).'</pre>'; // re-index array data $ids = array_combine(range(1, $count), array_values($data)); // update all columns containd gibberish chars $sql = "UPDATE `test`.`thread` SET `thread_name`=" . "CASE `thread_name`"; $j = 0; foreach ($arr_r as $val_r) { $sql .= sprintf(" WHEN '%s' THEN '%s'", $data[$j], $val_r); $j++; } $sql .= " END WHERE thread_id IN (" . implode(", ", array_map('intval', array_keys($ids))) . ")"; // display an UPDATE statement //echo '<pre>'.$sql.'</pre>'; // prepare a query $stmt = $dbh->prepare($sql); // execute it to DB server $stmt->execute(); $stmt = null;
-
Login to on one page and then get another page Help!
jazzman1 replied to drupalphp's topic in PHP Coding Help
Works for me. #!/bin/bash NAME='jazz' PASS='jazz' curl --cookie-jar cjar --output /dev/null 'http://www.supersaas.com' curl --cookie cjar --cookie-jar cjar --location \ "http://www.supersaas.com/api/users?account=${NAME}&password=${PASS}" Result: -
Sorry, if you were being confused with it. I'm working on improving my English by visiting phpfreaks every day Just because you're able to write something in your script doesn't mean it will work as expected and the programming cannot work in this way. Looking at your two scripts, I see ONLY one possible situation when this index could be defined in case, next else condition is gonna be "TRUE": else { $flag = "invalid"; header("location:Student_login.php?flag=$flag"); } Here, the word "flag" after a question mark it's an index of $_GET['flag'] variable and its value is equal to $flag (invalid). You can get into an url (string) that contains a parameter (index) but no value to it, like so: Student_login.php?flag In case like this you would use isset() or empty() functions to determine how "flag" is valued. if(isset($_GET['flag'])) echo 'flag is set'; if(!empty($_GET['flag'])) echo 'flag is not empty'; Or, like in the example provided by you. The following could go to true only if the index exist and its value is equal to "success" $flag="success"; Student_login.php?flag=$flag <?php if($_GET['flag'] == "success") { ?> <tr> <td class="stylegreen" colspan="4" align="center">Congratulations! You Are successfully registered. You can use your Login Id and Password to login to your account.</td> </tr> // or better option using empty() function if(!empty($_GET['flag']) && $_GET['flag'] == "success") { // do something }
-
You should defined this index first. Then you could use isset() or empty() functions ( see differences b/w them in the links above) to check 1)if the index is being set 2) what value is being set to it and finaly use if, if else, else constructs to check if the value is equal to value you're expecting to be. That's all and it's simple.
-
http://ca1.php.net/isset or http://ca2.php.net/empty - personaly prefer empty().
-
Login to on one page and then get another page Help!
jazzman1 replied to drupalphp's topic in PHP Coding Help
Post the source code of this html form of the second page. -
Login to on one page and then get another page Help!
jazzman1 replied to drupalphp's topic in PHP Coding Help
Double check the name and value attributes and their values. This works for me -> #!/bin/bash NAME='jazz' PASS='jazz' REMEMBER='R' curl --cookie-jar cjar --output /dev/null 'http://www.supersaas.com' curl --cookie cjar --cookie-jar cjar --data 'name='${NAME} --data 'password='${PASS} --data 'remember='${REMEMBER} --location \ 'http://www.supersaas.com/dashboard/login' -
Then do insert all greek alphabet under latin_swedish_ci's charset. See, how they are presenting in the colums using this charset and make some comparision using your application language (php). if (this broken word = some symbol ) { this broken symbol = some greek word, and so on, so, on } Find all substitutions and do update to this symbols.
-
You can't repair the broken content at least I don't know how. You need to re-create a new table under utf8 charset, or just alter the structure as shown in my examples above, truncate it and do a new insertion with normal greek words.
-
According mailer's docs the subject is a property as @mac said above. $mail->Subject = "PHPMailer Test Subject via mail(), basic"; $mail->Subject // property $mail->Subject () // method How many rows of data do you expect to retrieve, based on $_POST['Eno'] by using the following-> $sqlmail = "SELECT subtxt, message, attachment FROM mail_info WHERE EID= '".$_POST['Eno']."'"; while ($rowm = mysqli_fetch_array($mailresult)) { }
-
SET NAMES 'UTF8' indicates only what character set the client will use by sending sql statements to the DB server. If the collation of db/table/column isn't set to 'UTF8' in your database you cannot retrieve the correct data. To solve the problem (without creating any duplicate/mirror table) just change the collation only to this problematic table to 'utf8_general_ci'. Before doing anything with your database structure make sure you have a dump (backup). The command is: ALTER TABLE `db_name`.`thread` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; or for specific column in this "thread": ALTER TABLE `db_name`.`thread` CHANGE COLUMN `title` `title` VARCHAR(45) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' NOT NULL ;
-
Check, whether all variables are being defined. In your script I cannot see where "subject" field in your html form is.
-
Hire some programmer to do this job for you. A ton of issues I see in your php scripting and database design.
-
unzip file with extractTo results in owner problem
jazzman1 replied to flyingdutchman's topic in PHP Coding Help
Why don't you tell us the whole story? I like to read them before to get in my bed -
Don't escape the single quotes in you query. See the difference: <?php $getDelTimesQue = $this->query( "SELECT * FROM deltimes WHERE state=\'1\'"); //and $getDelTimesQue = $this->query( "SELECT * FROM deltimes WHERE state='1'"); To get "value = curdate()" working you must alter the column named "value" from varchar to date or datetime datatype. mysql> SHOW COLUMNS FROM deltimes; +--------+----------------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +--------+----------------------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | type | enum('returning','single') | NO | | single | | | state | enum('0','1') | NO | | 0 | | | days | varchar(13) | YES | | NULL | | | cotype | enum('c','o') | NO | | c | | | value | date | YES | | NULL | | | text | varchar(240) | YES | | NULL | | +--------+----------------------------+------+-----+---------+----------------+ 7 rows in set (0.00 sec) mysql> SELECT * FROM deltimes where value = curdate() and state = '1' Result: +----+-----------+-------+-----------+--------+------------+------+ | id | type | state | days | cotype | value | text | +----+-----------+-------+-----------+--------+------------+------+ | 52 | returning | 1 | 1,2,3,4,5 | c | 2014-02-19 | NULL | +----+-----------+-------+-----------+--------+------------+------+ 1 row in set (0.00 sec)
-
Does the length of the password filed is designed to be less than 64 chars? Amend: for sha512 should be 128 chars!
-
unzip file with extractTo results in owner problem
jazzman1 replied to flyingdutchman's topic in PHP Coding Help
The file's creator and owner is "www-data" , maybe you're on Debian or Debian based distro. By default the file's permission when the file being created is 0644 (-rw-r--r--), which means nobody unless the owner won't have permission to modify/delete the file. By setting chmod to 0775 (for groups) or 0777 (for others) will it give full rights to this file. @off: I was a keyboard player -
Interesting question Where are the values that you wanna be submited? Could you show us the output of $query_string?
- 3 replies
-
- php
- validation
-
(and 1 more)
Tagged with:
-
mysql> SHOW COLUMNS FROM deltimes; +--------+----------------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +--------+----------------------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | type | enum('returning','single') | NO | | single | | | state | enum('0','1') | NO | | 0 | | | days | varchar(13) | YES | | NULL | | | cotype | enum('c','o') | NO | | c | | | value | varchar(11) | NO | | NULL | | | text | varchar(240) | YES | | NULL | | +--------+----------------------------+------+-----+---------+----------------+ 7 rows in set (0.00 sec) Two problems I see here in your query on the line 669 and output shown above: $getDelTimesQue = $this->query( 'SELECT * FROM deltimes WHERE state=\'1\' AND ( value=CURDATE() ) ' ); // line 669 1) An ENUM is a string object. You're setting the values as a string type (which is correct) and even though you could set the values to numbers MySQL developers strongly recommend that you do not use numbers as enumeration values. Read up this. 2) The arithmetic of using MySQL Date/Time functions do NOT work on type of fields different from Date/Time and Timestamp. Read up and this.
-
Don't PM'ed me the next time! The purpose of this forum is to provide a help to others members with similar problems like you. Post the error logs and results you got only here.
-
It should work just fine, but I get to work to work right now. I'll check it a bit late. PS. Do some research on the web for examples, how to use phpmailer with looping constructs. I'm on SwiftMailer and not entirely sure if this sown above is correct.