<div dir="ltr">On Thu, Jan 31, 2013 at 10:44 AM, Chuck Payne <span dir="ltr"><<a href="mailto:terrorpup@gmail.com" target="_blank">terrorpup@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Guys,<br>
<br>
I need help from php guru.<br>
<br>
I have sql statement that works great in mysql, where I'm am using<br>
datediff. When I try to use it in php, I get an "mysql_fetch_arrary()<br>
expects parameter 1 to be a resource, boolean given in"<br>
<br>
This the statement is...<br>
<br>
$result = mysql_query("select hname, hsn, hmodel, hmake, htype, hwar,<br>
datediff(`hwar`, now()) from host where stype='physical';",$db);<br>
<br></blockquote><div><br></div><div style>The backticks within double quotes are being interpreted as the execution operator: <a href="http://php.net/manual/en/language.operators.execution.php">http://php.net/manual/en/language.operators.execution.php</a></div>
<div style><br></div><div style>Either remove them (fine since hwar is not a reserved word) or escape them.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
I know the statement works in mysql<br>
<br>
mysql> select hname, hsn, hmodel, hmake, htype, hwar, datediff(`hwar`,<br>
now()) from servers.host where stype='physical';<br>
+--------------+---------+--------+-----------+-------+------------+-------------------------+<br>
| hname | hsn | hmodel | hmake | htype | hwar |<br>
datediff(`hwar`, now()) |<br>
+--------------+---------+--------+-----------+-------+------------+-------------------------+<br>
| moscow | XXXXXXX | Dell | PowerEdge | R710 | 2013-09-13 |<br>
225 |<br>
| sydney | XXXXXXX | Dell | PowerEdge | R710 | 2013-09-15 |<br>
227 |<br>
<br>
<br>
When I remove datediff(`hwar`, now()), my page works. I wanted to use<br>
that as field<br>
<br>
$datediff=$row['datediff'];<br>
<br>
Any clues as to why it doesn't work?<br>
<br>
--<br>
Terror PUP a.k.a<br>
Chuck "PUP" Payne<br></blockquote></div><br clear="all"><div><br></div>-- <br>David Tomaschik<br>OpenPGP: 0x5DEA789B<br><a href="http://systemoverlord.com" target="_blank">http://systemoverlord.com</a><br><a href="mailto:david@systemoverlord.com" target="_blank">david@systemoverlord.com</a>
</div></div>