
jeff5656
Members-
Posts
744 -
Joined
-
Last visited
Everything posted by jeff5656
-
Ok I fiugured out how to have leading zeros, but then it cuts off the zeros to the right of the decimal point. if I have 1.1 I want it to become 001.100 so: $x = 1.1 $y = sprintf("%03d",$x); echo $y answer: 001 if I do this: $x = 1.1 $y = sprintf("%.3f",$x); echo $y I get 1.100 How do I combine this so that I get the leading and the following zeros, i.e. 001.100?
-
How do I add leading zeros if the variable does not contain them? I have a list of numbers stored in a VARCHAR field. I want the number to always have 3 places, so if a number is 1.25 I want to change it to 001.25 if the number is 12.5 I want to change it to 012.5. If the number is 123.5 I want to leave it alone. I want to put all the records in a while loop and then check each variable and then update that record if it needs it. What is the best way to do this? Thanks!
-
I am trying to select records with today's date but am getting zero hits: $currdate= date("y-m-d"); $query = "select id from table1 where some_date = '$currdate' the problem is that the date is stored as a datetime so there is a time after it. How do I modify the above query to select for today's date and ignore the time part?
-
Ok I feel really stupid about this especially with everyone chiming in to help. That update statement was up at top of the page under an if (isset(_post). right below that was another IF line that was true, containing a query to update completed to n!! So it WAS updating to "rejected" and then a second query 4 lines down was updating it to "n"! Sorry to waste everyone's time LOL!
-
The other interesting thing is the other field DOES get updated correctly (rejectreason).
-
When i try to update a record, it does not get updated. $qq = "update dos set completed = 'rejected', rejectreason='$rejectreason' where dos_id = '$dosid' LIMIT 1"; mysql_query($qq) or die(mysql_error()); the field that is called "completed" is an enum: CREATE TABLE IF NOT EXISTS `dos` ( `dos_id` int(254) NOT NULL AUTO_INCREMENT, [...] `completed` enum('n','y','rejected') NOT NULL, etc. So when I try to change the "completed" field to "rejected" it does not update but when i update it to either an "n" or a "y" it works. Does anyone see any problems? It's weird. I can also manually change it to "rejected" within phpmyadmin. Also when I echo $qq, the dos_id (and $dosid) is correct, but that record is not being updated. That record still has a "n" instead of "rejected".
-
oops. got it thanks. It threw me off because the error message was referring to a ) when the error was triggered by a missing ].
-
if (isset($_POST['ptsearch'])|| isset($_GET['searchname')){ I get this error: Parse error: syntax error, unexpected ')', expecting ']' in /home/etc... Maybe i am having a stroke, but I can't see where the parentheses are not all closed.
-
both tables have rec_no - this identifies the person. table1 is active people and table2 is inactive so the rec_no is the same (and the field is called rec_no in both tables).
-
Not sure if i need a join or not: i want to pull all the records from table1 and table2 where the field rec_no matches $_post['rec_no'] Can someone help me with the syntax? $query = select * from table1, table2 where rec_no = $post['rec_no"; Thank you!
-
Yes I'm using the php tags and the script runs when I run it manually. I will contact host to see what the path to php is. I'll bet that's what the problem is. Thanks!
-
Not sure if this is the right category but it's the closest I could find. I am trying to run a cron job and I get a permission denied when the cron job is run. But in that script I have this at the top: $dbhost = "localhost"; $dbname = "mydb_name"; $dbuser = "mehere"; $dbpass = "mypassword"; mysql_connect ( $dbhost, $dbuser, $dbpass) or die("Could not connect: ".mysql_error()); mysql_select_db($dbname) or die(mysql_error()); $curr_date=date("Y-m-d"); //delete table here $query = "select this from that where thois = that" $result=mysql_query($query) or die(mysql_error()); But when it says "permission denied" it looks like I am not even running the script? To administrator: if this belongs in another forum that is seldom-used, could you keep this here for a short while until I get an answer and then move it? :-) I am pointing to the correct directory int he cron job: /home/myname/cronjobs/runthis.php
-
I figured it out - no need for distinct, I used group by.
-
searching keywords in the forum
jeff5656 replied to John Davy Olmedo's topic in PHPFreaks.com Website Feedback
I got this when I tried to search: An Error Has Occurred! You are not allowed to search for posts in this forum. -
I have this query: $query = "select tasks.*, users.email, users.lname from tasks inner join users on users.id = tasks.user_id where due_date<='$curr_date'"; How do I retrieve records so that if there are multiple records with the same email, just select 1 of those records. I want to generate a list containing all unique emails, not the same email listed more than once.
-
In cpanel I have this command in a cron job: mysqldump --user=myusername --password=mypassword--databases mydatabase > /home/mydirectory/sql_backups/DUMPFILE.SQL The file is zero bytes. Is the above command wrong? Unfortunately with a cron job, you don't get an error when it's run so I don't get any feedback about what I may have done wrong.
-
Well, I am constantly typing if ($row['name'])!=''){ echo "the name is ". $row['name']; so I figured I would make a function to save keystrokes. so all I would have to do would type echo_if_exist($row['name']) . But also, sometimes I want to precede the variable with "the name is" and sometimes I want to simply surround it in a parenthesis. I guess my experiment on trying to use a function failed. Oh I just saw that new post - I will look into empty()...
-
I have this function: function echo_exist($pre1,$ee,$post1) { if ($ee!='') { return $pre1; return $ee; return $post1; } else { //do nothing } } But when I try to echo it echo_exist("(","$row['payment_type']",")"); I get syntax error, unexpected T_ENCAPSED_AND_WHITESPACE If $row['payment_type'] exists, I want it to be displayed in parentheses like: (AUTO) I suspect it has to do with my ' characters for the associative array, but I am new with functions so perhaps it is the multiple arguments that are wrong?
-
Changing to timestamp worked - the previous dates were not erased (but their times remain 00:00:00 of course, until they get updated)
-
I like option 3. If i change to timestamp, wiill that overwrite all the previous dates in the database records (because it was originally set as datetime)?
-
I have a form that has this: <input type="text" name="notes_date" size="10" value="<?php echo date("m/d/Y");?>" /> I enter into the database after processing the variable like this: $notes_date=date ("Y-m-d H:i:s", strtotime($_POST['notes_date'])); However, it gets stored at 2012-03-15 00:00:00 How do I fix this so that the current time gets stored instead of 00:00:00?
-
I figured it out. I had to use stripslashes after I retrieved it from the database. And the class called for it to be used like this: $mail->IsHTML(true);
-
I think it might be a different class, because here's how they want me to handle the body of the text: $mail->Body = "Dear Dr. $pd_lname, \n $body ";
-
I am using the mail command in php. I'm using a class call phpmailer.php. I want to mail something that contains a link. The wording of the email is stored in the database under a text field and I declare it as: $body. If I put inside the body: Dear john, here is the link: test.com then the email contains a hyperlink called test.com. But it does not work if I put this in the text: <a href='test.com'>CLICK ME</a> In the email, you can see the <a href tag and click me is just text. How do I get the email to show it like this: tes.com