php mysql statement hangs?

Pop your questions regarding Home automation software here.....
Post Reply
Kroonen
Member
Member
Posts: 302
Joined: Mon Oct 01, 2007 6:38 pm
Location: Netherlands

php mysql statement hangs?

Post by Kroonen »

Hi,

I'm trying to put the rfxmeter values into a mysql database with php
He puts it in but the script doesn't come to a prompt, what do I wrong?

#!/usr/bin/php

<?php
$link = mysql_connect('localhost', 'rfxcom', 'rfxcom')or die('Couldnot connect: ' . mysql_error());

mysql_select_db( "rfxcom") or die('Could not select database');

$sql = "SELECT power FROM rfxpower ORDER by time DESC";

$query = mysql_query($sql);

$result = mysql_result($query, 0);

$data = shell_exec('/usr/local/bin/heyu rfxpower l2');

$verbruik = $data - $result;

$query2 = "insert into rfxpower(power,verbruik) values
('$data','$verbruik')";

mysql_query($query2);

// Free resultset
mysql_free_result($query);

// Closing connection
mysql_close($link);

?>
Mdamen
Forum Moderator
Forum Moderator
Posts: 390
Joined: Sat Nov 22, 2008 6:58 pm
Location: Netherlands
Contact:

php mysql statement hangs?

Post by Mdamen »

Are you sure it's not hanging on some command?

Try adding some echo statements in between, like this:

Code: Select all

<?php
$link = mysql_connect('localhost', 'rfxcom', 'rfxcom')or die('Couldnot connect: ' . mysql_error());
echo "connected to mysql server";

mysql_select_db( "rfxcom") or die('Could not select database');
echo "database selected";
etc.

If that runs all the way to the last action, which is the mysql_close function in this case. Try adding the following, to make sure the script exits:

Code: Select all

exit();
for more info see: http://www.php.net/exit

Maarten Damen
www.maartendamen.com
Kroonen
Member
Member
Posts: 302
Joined: Mon Oct 01, 2007 6:38 pm
Location: Netherlands

php mysql statement hangs?

Post by Kroonen »

I got the problem, de php-cli form debian etch is a bug with exit.

Is it simple to get the script in perl. Any help

kind regards richard
Post Reply

Return to “Questions & Discussions Forum”