Jump to content

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);

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.