Jump to content

Function Calling Understanding


Iconate

Recommended Posts

Hey everyone, I have been working on a project which requires me to use PHP/MySQL, and I have been teaching myself along the way, but I am currently having some function calling issues, and I am not sure if its just syntactical or what.

 

 

Essentially Im just trying to create a table, but some of the columns are dynamic, my solution to that is to have function calls, but first I need to figure out how to actually do them properly :P

 

<?php
function print()
{
echo "<table border='1'>";
echo "<tr>";
echo "<th>Time</th>";
echo "<th>Availablility</th>";
echo "</tr>";
echo "<tr><td>08:00</td></tr>";
echo "<tr><td>09:00</td></tr>";
echo "<tr><td>10:00</td></tr>";
echo "</tr>";
echo "</table>";
}

$q=$_GET["q"];

$con = mysql_connect('....');
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("....", $con);

$a = $q[0];    
$q = substr($q, 1, 11);

$sql="SELECT * FROM dates WHERE arena = '".$a."' AND date LIKE '%".$q."%'";

$result = mysql_query($sql);
$dbtime = "NULL";

print();


mysql_close($con);
?> 

 

When I run this along with my other files, the page does not display what is in the "print()" function, but if I just take what is in that function and hardcode it, it does get displayed.

 

Thanks, sorry if this is such a trivial error

Link to comment
https://forums.phpfreaks.com/topic/159526-function-calling-understanding/
Share on other sites

*facepalm* Well it works now heh, thanks, so much for my stupid arbitrary test names.....

 

Lol, next time you have problems and can't figure it out what's going on, you can enable heavy error reporting right after your opening <?php tag to rule out 'simple' mistakes.

 

ini_set ("display_errors", "1");
error_reporting(E_ALL);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.