Jump to content

Kidrandom

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Everything posted by Kidrandom

  1. Awesome! Just what the Doctor ordered. Thanks for your help!
  2. Hey all, I've made a page that reads a list of items from a database and I want it to automatically generate a new page when the amount of items pulled from the database reaches a certain number. Exactly the way the extra pages in this forum are generated once a certain amount of topics are posted on one page. I'm fairly new to PHP and MySQL so I'm finding it difficult to conceptualize how this will work. So my question is, how do I go about doing this? Here's the code I'm using to generate the items: while ($post = mysql_fetch_array($query)) { echo "<div id=\"result_item\">"; echo "<p class=\"result_blue\">"; echo "<a href=\"desc.php?sel_post=" . urlencode($post["id"]) . "\">"; echo $post["job"] . "</a></p>"; echo "<p class=\"dark_grey\">"; echo $post["employer"] . " | " . $post["location"] . " | £" . $post["salary"] . " per " . $post["salary_freq"]; echo "</p></div>"; } Thanks!
  3. Hi, I have just started learning php and mysql and have been doing a few exercises. I made a function to get all the information out of a table in a mysql database based on the id of a selected table item. I'm having a bizarre issue when trying to use the function within an if statement. It works fine when I use it and assign to a variable in my page. Like so: <?php $table = get_table_by_id ($_GET ["subj"]); echo $table ["menu_name"]; ?> This gives me the menu name out of the table. However when the same function is used within an if statement like so: if (isset($_GET ["subj"])) { $sel_table = get_table_by_id ($_GET ["subj"]); } else { $sel_table = NULL; } I get the following error: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in.... Which translates to: No database selected Here is the code used for the function: function get_table_by_id ($name) { $query = "SELECT * " ; $query .= "FROM pages "; $query .= "WHERE id=" . $name . " "; $query .= "LIMIT 1"; $result_set = mysql_query ($query); if (!$result_set) { die ("query failed " . mysql_error()); } $array = mysql_fetch_array($result_set); return $array; Why is this happening?
  4. I have just started learning PHP from a training Cd but I'm having trouble with a script not displaying properly. I'm Running mac os x 10.5.5 Personal web sharing activated apache running, I have edited httpd.conf and removed the # from LoadModule php5_module libexec/apache2/libphp5.so made a simple page in php <?php echo("hello world "); ?> saved the page /user/Sites/index.php and doesn't displays a blank page in the browser. Also when I view the source code the php lines are visible and highlighted pink. A PHPtest page with the PHP code: <?php phpinfo(); ?> works, and displays the Entropy version correctly. Can anyone point me in the correct direction Thanks for your answers guys.
×
×
  • 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.