Search found 53 matches

by MeroD
Sat Nov 17, 2012 10:28 pm
Forum: PHP coding => General
Topic: Date issues...
Replies: 3
Views: 1257

Re: Date issues...

You are correct. The old date() function and strtotime can be pretty stuck up at times, and are not considered good practice (according to stackoverflow anyway). It is recommended to use either the new DateTime functions, or using MySQL's UNIX_TIMESTAMP() function. SELECT UNIX_TIMESTAMP(timestamp) F...
by MeroD
Fri Nov 16, 2012 3:30 am
Forum: PHP coding => General
Topic: Date issues...
Replies: 3
Views: 1257

Re: Date issues...

Try:

Code: Select all

$sbd = date('Y-m-d', strtotime($row['Sell_By_Date']));
$notice = strtotime('-7 day', $sbd);

if (( $notice < time() ) && ( $sbd > time() )) {
  // About to expire...
}
elseif ( $sbd < time() ) {
 // Expired!               
} 
else {
  // Print SellbyDate...
}
 
by MeroD
Wed Nov 14, 2012 10:13 pm
Forum: PHP General
Topic: Revenue for the week
Replies: 2
Views: 1450

Re: Revenue for the week

Captain Jean-Luc Picard: Tea, Earl Grey, hot.
Enterprise Computer: That beverage has not been programmed into the replication system.
by MeroD
Mon Nov 12, 2012 10:46 pm
Forum: PHP coding => General
Topic: Textbox Changes Dynamically
Replies: 1
Views: 786

Re: Textbox Changes Dynamically

Have you tried:
document.getElementById("textboxelement").innerHTML = "Changed text!";
by MeroD
Mon Nov 12, 2012 10:13 pm
Forum: PHP coding => General
Topic: PDO or MYSQLi?
Replies: 3
Views: 884

Re: PDO or MYSQLi?

If you are taking the procedural route, definitely stick with mysqli. If you are learning to code using objects and classes, use PDO. Regardless, here's some articles on the issue: http://net.tutsplus.com/tutorials/php/pdo-vs-mysqli-which-should-you-use/ http://stackoverflow.com/questions/13569/mysq...
by MeroD
Sun Nov 11, 2012 10:27 pm
Forum: PHP coding => General
Topic: display username after logging in
Replies: 4
Views: 979

Re: display username after logging in

First:
session_start();
$_SESSION['user'] = $_POST['user'];

Other pages:
session_start();
echo $_SESSION['user'];
by MeroD
Sun Nov 11, 2012 10:05 pm
Forum: PHP coding => General
Topic: Notice: Undefined offset:
Replies: 0
Views: 546

Re: Notice: Undefined offset:

Have you tried printing out the array to see exactly how the data/keys is structured?

echo "<pre>" . print_r($detail,true) . "</pre>";
by MeroD
Fri Nov 09, 2012 11:50 pm
Forum: mySQL & php coding
Topic: GROUP BY MONTH() Error
Replies: 2
Views: 2241

Re: GROUP BY MONTH() Error

Try: GROUP BY YEAR(EXPDATE), MONTH(EXPDATE)

Or: DATE_FORMAT('EXPDATE`, '%M')
by MeroD
Fri Nov 09, 2012 9:54 pm
Forum: mySQL & php coding
Topic: expected ALL but reads only first
Replies: 1
Views: 942

Re: expected ALL but reads only first

if($result = $mysqli->query($query)){
while($row = $mysqli->fetch_object($result)){
echo $row->column;
}
}
by MeroD
Thu Nov 08, 2012 11:56 pm
Forum: PHP coding => General
Topic: PHP Array to email
Replies: 1
Views: 745

Re: PHP Array to email

You can also use the implode() function to join them in a comma separated string:

$checked = trim(stripslashes(implode(",", $_POST['i_have'])));
by MeroD
Thu Nov 08, 2012 11:22 pm
Forum: PHP coding => General
Topic: How to create log file?
Replies: 2
Views: 805

Re: How to create log file?

The easiest way to get started is to create ON INSERT, ON UPDATE triggers that write details of all changes to an audit (activity) table.

http://www.sitepoint.com/how-to-create-mysql-triggers/
http://dev.mysql.com/doc/refman/5.5/en/ ... yntax.html
by MeroD
Wed Nov 07, 2012 10:51 pm
Forum: PHP coding => General
Topic: PHP returns incorrect total
Replies: 1
Views: 811

Re: PHP returns incorrect total

Floating-point data types like DOUBLE are approximate and do not represent exact numbers.

number_format($...total) may give you better results.
by MeroD
Wed Nov 07, 2012 10:32 pm
Forum: PHP coding => General
Topic: similar_text() function
Replies: 1
Views: 856

Re: similar_text() function

As an alternative you can try Levenshtein Distance: http://php.net/manual/en/function.levenshtein.php

It's apparently faster than similar_text, and you can control the different parts of the algorithm...
by MeroD
Wed Nov 07, 2012 4:57 am
Forum: mySQL & php coding
Topic: output string literals
Replies: 0
Views: 756

Re: output string literals

Try:
$output = htmlspecialchars($input, ENT_QUOTES);

http://www.php.net/manual/en/function.h ... lchars.php
by MeroD
Wed Nov 07, 2012 3:49 am
Forum: mySQL & php coding
Topic: after boolean becomes tinyint(1)
Replies: 1
Views: 1015

Re: after boolean becomes tinyint(1)

BOOLEAN is an alias to TINYINT(1)

Zero is false, anything else is true. Your function will return 0 or 1, which will get transformed into a string--so in PHP you have the strings '0' and '1'... If you need to compare with a zero use ===
by MeroD
Wed Nov 07, 2012 2:17 am
Forum: PHP coding => General
Topic: new to PHP cicle and array problem
Replies: 1
Views: 654

Re: new to PHP cicle and array problem

<?php
foreach ($produtos as $plist) {
  if ( in_array($plist, $produto) ) {
    echo $plist . " Found!<br />";
  }
  else {
    echo "Product not found!<br />";
  }
}
?>

http://www.w3schools.com/php/func_array_in_array.asp
http://www.php.net/manual/en/function.in-array.php
by MeroD
Wed Nov 07, 2012 12:31 am
Forum: PHP coding => General
Topic: can't get file path from file
Replies: 3
Views: 998

Re: can't get file path from file

Maybe looking through this tutorial may help:
http://www.dreamincode.net/forums/topic ... -with-php/
by MeroD
Tue Nov 06, 2012 11:59 pm
Forum: mySQL & php coding
Topic: GROUP BY MONTH() Error
Replies: 2
Views: 2241

Re: GROUP BY MONTH() Error

$query = "SELECT MONTH(EXPDATE),SUM(ORDTOTAL) ";
$query .= "FROM OEORDH ";
$query .= "WHERE TYPE='1' AND ORDTOTAL>'0' ";
$query .= "GROUP BY MONTH(EXPDATE)";
by MeroD
Mon Nov 05, 2012 1:53 am
Forum: mySQL & php coding
Topic: join three tables
Replies: 5
Views: 1662

Re: join three tables

Your orders table should not contain product_id since one order may have multiple products (which you already have in order_products anyway.) The order table usually carries order_date and client_id for example... If you are only dealing with a single manufacturer_id in your query, why are you conce...
by MeroD
Sun Nov 04, 2012 12:17 pm
Forum: PHP coding => General
Topic: problems with updating database
Replies: 6
Views: 1297

Re: problems with updating database

quantity_on_hand=$quantity_on_hand',

Missing '

quantity_on_hand='$quantity_on_hand',
by MeroD
Sun Nov 04, 2012 1:46 am
Forum: PHP General
Topic: 403 Forbidden Error
Replies: 1
Views: 902

Re: 403 Forbidden Error

Oh, and try to avoid using PHP short tags ( <?= )

They aren't supported on all servers...
by MeroD
Sun Nov 04, 2012 1:35 am
Forum: PHP General
Topic: 403 Forbidden Error
Replies: 1
Views: 902

Re: 403 Forbidden Error

<a href="<?php echo $_SERVER['PHP_SELF'] . '?action=on' ?>">ON</a>

OR:

<a href="<?php printf( '%s?action=on', $_SERVER['PHP_SELF'] ); ?>">ON</a>
by MeroD
Sun Nov 04, 2012 12:26 am
Forum: PHP coding => General
Topic: calendar
Replies: 4
Views: 908

Re: calendar

by MeroD
Sat Nov 03, 2012 12:20 am
Forum: PHP coding => General
Topic: File Upload Progress Bar in PHP using jQuery
Replies: 1
Views: 1120

Re: File Upload Progress Bar in PHP using jQuery

CSS3 Transition and HTML5 may give you better results as well:

.progress{ ..., transition:0.25s; }
.progress.done { width:100% !important; }

http://www.w3schools.com/css3/css3_transitions.asp
by MeroD
Thu Nov 01, 2012 9:06 pm
Forum: PHP coding => General
Topic: php error
Replies: 4
Views: 1127

Re: php error

Use var_dump($_POST) to examine the variables/array sent to your script...