-envious Posted September 11, 2015 Share Posted September 11, 2015 (edited) Wonder if someone can give me a hand. My select statement is working on command line, but not in PHP. SELECT id,DAY(date),MONTH(date),title,location,address,timestart,timeend,ticketprice,buynowaddress FROM Events WHERE active = true ORDER BY date DESC But when I put it into PHP, I get an error: Notice: Undefined index: date in /var/www/html/site.com/evets.php on line 9 Here is the PHP: <?php include("dbconnect.php"); $result = mysql_query("SELECT id,DAY(date),MONTH(date),title,location,address,timestart,timeend,ticketprice,buynowaddress FROM Events WHERE active = true OR$ while ($row = mysql_fetch_array($result)) { echo "<p>ID: " .$row['id'] ."<br>"; echo "Title: " .$row['title'] ."<br>"; echo "Date: " .$row['date'] ."<br>"; echo "Location: " .$row['location'] ."<br>"; echo "Address: " .$row['address'] ."<br>"; echo "Time Start: " .$row['timestart'] ."<br>"; echo "Time End: " .$row['timeend'] ."<br>"; echo "Ticket Price: " .$row['ticketprice'] ."<br>"; echo 'Buy Ticket Link: <a href="' .$row['buynowaddress'] .'">address</a><br></p>'; echo "<hr>"; } ?> Thank you all in advance Edited September 11, 2015 by -envious Quote Link to comment Share on other sites More sharing options...
MutantJohn Posted September 11, 2015 Share Posted September 11, 2015 (edited) Are you sure your PHP matches you command-line SQL? Also, I recommend using PHP's PDO instead of the mysql stuff. Edited September 11, 2015 by MutantJohn Quote Link to comment Share on other sites More sharing options...
-envious Posted September 11, 2015 Author Share Posted September 11, 2015 I'll check out PDO, thanks! Quote Link to comment Share on other sites More sharing options...
Solution ginerjm Posted September 11, 2015 Solution Share Posted September 11, 2015 How about "DAY(date) as date_dd" and "MONTH(date) as date_mm" and then use date_dd and date_mm as your indices into $row? AND definitely change your code to stop using MySQL_* functions. They are going out of PHP soon. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.