Jump to content

denno020

Members
  • Posts

    761
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by denno020

  1. I feel like a douche bag! The mixing of the mysqli and mysql is exactly what the problem was! I was having troubles with trying to run mysql queries before because I was using mysqli to connect to the database. Problem is now fixed, and it works like a charm. Thanks heaps!
  2. Ohhhhkk. So because I use mysqli_query(), the mysql_num_rows doesn't work? I have tried to connect to my database using mysql before, however it didn't work. But I shall try again right now and see how I go, using the code provided by OOP. Will post back with a result. Thanks
  3. yeah mate, that's what I want. That functionality, however it just refuses to work. I've got that listed in my code as (1). Also, be aware that I don't have all 3 of those options in there at the time of testing, I've only put them in to illustrate the different combinations I've used. Thanks
  4. I wish to have a page that will display a form if there aren't already enough registrations in the database. The following it an outline of how it will be: <?php require_once "../scripts/connect_to_mysql.php"; //this works fine // Count how many records in the database (1) $sqlCommand = "SELECT * FROM teams"; (2) $sqlCommand = "SELECT COUNT (*) FROM teams"; (3) $sqlCommand = "SELECT COUNT (id) FROM teams"; $query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error()); (1) $numRegistrations = mysql_num_rows($query); //Count how many rows are returned from the query above (2) $numRegistrations = $query (3) $numRegistrations = mysql_num_rows($query); mysqli_free_result($query); ?> (Some HTML code, like DOCTYPE, head, start of body tags) <?php if($numRegistrations > 35){ echo "Sorry, registrations for this event is at it's maximum."; }else{ ?> <form blah blah blah> </form> <?php } ?> (end of body and html tag) You'll see above there is (1), (2), (3). These are the main 3 that I've been trying, and they match up the $sqlCommand to the $numRegistrations. What would be the problem with this code? I use wamp server to test, have been using it for ages. Chrome browser to test in. If I remove the database query, the rest of the page will load. With the query in there, only the HTML code up until the database query is parsed, so therefore nothing is display on the page. Please help. Thanks Denno
×
×
  • 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.