Ciao a tutti,
come prima domanda, ve ne faccio una facile. Sono ancora all'inizio con php e non riesco a far eseguire questo codice php:
I tried this query on phpmyadmin (with mysql) and it worked. If i use the values of the dates instead of the $date1 and $date2 this code works. Now i'm getting the error:
Notice: Undefined variable: output in C:\xampp\htdocs\filephp.php on line 25
null
P.S the number 25 is now not correct because i deleted something however the problem is in the query. can someone help me?
come prima domanda, ve ne faccio una facile. Sono ancora all'inizio con php e non riesco a far eseguire questo codice php:
PHP:
<?php
$date1=2014-10-07;
$date2=2014-10-08;
$con = mysql_connect("localhost","root","psw");
if(!$con)
{
die('Could not connect: '. mysql_error());
}
mysql_select_db("test-db_tirocinio",$con);
$result = mysql_query("SELECT * FROM elements WHERE (date=$date1 or date=$date2) and id_element=3");
while($row= mysql_fetch_assoc($result))
{
$output[]=$row;
}
print(json_encode($output));
mysql_close($con);
?>
I tried this query on phpmyadmin (with mysql) and it worked. If i use the values of the dates instead of the $date1 and $date2 this code works. Now i'm getting the error:
Notice: Undefined variable: output in C:\xampp\htdocs\filephp.php on line 25
null
P.S the number 25 is now not correct because i deleted something however the problem is in the query. can someone help me?
Ultima modifica di un moderatore: