Re: SQL Statement

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thompson, Jimi wrote:
So then I try do this â

<?php
if ($fk_phone != NULL) {
	$sqlwrk = "SELECT `pk_phone_reports`, SUM(`calls`) AS `total_calls`,
 `date`, `calls` , `fk_ph_num` FROM `phone_reports`";
	$sqlwrk .= " WHERE `pk_phone_number` = " . $fk_phoneâ;
	$rswrk = mysql_query($sqlwrk);
	if ($rswrk && $rowwrk = mysql_fetch_array($rswrk)) {
		echo $rowwrk["number"];
	}
	@mysql_free_result($rswrk);
}
?>

Note that this shouldnât work since it isnât a valid SQL statement.
> I'm not sure why PHP doesn't return some kind of an error message.

PHP does return an error message, you're just not displaying it.

$rswrk = mysql_query($sqlwrk) or die(mysql_error());

$sqlwrk .= " WHERE (`pk_phone_number` = " . $fk_phoneâ) AND
> (`date` BETWEEN â'$my_startdate'â AND â'$my_enddate'â)â;

Which brings me to my lovely parse error "Parse error:

You're not concatinating your string correctly.


$sqlwrk .= " WHERE (`pk_phone_number` = " . $fk_phone . ") AND
(`date` BETWEEN '" . $my_startdate . "' AND '" . $my_enddate . "')";

or

$sqlwrk .= " WHERE (`pk_phone_number` = $fk_phone) AND
(`date` BETWEEN '$my_startdate' AND '$my_enddate')";

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals â www.phparch.com

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux