Jump to content

132591

Members
  • Posts

    19
  • Joined

  • Last visited

132591's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. A java tutorial would be really awesome! And it is not completely not web-related.
  2. 132591

    php forum

    yeah, that would make sense.
  3. 132591

    php forum

    Never mind I found the problem. The function "mysql_fetch_assoc()" will return false if now rows exist in the $result variable, and so my code was dying.
  4. 132591

    php forum

    It dies at the point where it does: $sql = "SELECT * FROM topic WHERE name = 'Rants'"; if(!($result = mysql_query($sql, $con))) die("<br />" . mysql_error($con) . "<br />"); if (!($row = mysql_fetch_assoc($result))) die("<br />" . mysql_error($con) . "<br />"); if($row['name'] != "Rants"){ $sql = "INSERT INTO topic(parent_forum, name, description) VALUES(1, 'Rants', 'Things you don't like about our site.')"; mysql_query($sql, $con); }
  5. 132591

    php forum

    Why is this code not working? It should display the forums and their topics, but instead one of the "die()" functions executes, and I do not know why. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><style type="text/css"> body{ background: #3399FF; font-family: Arial; } td.center{ text-align: center; } a{ text-decoration: none; color: black; font-family: Arial; } a:hover{ color: white; text-decoration: underline; } a:visited{ color: purple; }</style><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /><title>REDEYEGAMEZ</title></head><body><table width="100%"> <td width="33%"></td> <td width="33%" class="center"><h1>FORUM</h1> <p>This is the redeyegamez forum. Here you can discuss different games in more detail, or just the website in general.</p></td> <td width="33%"></td></table><?php function displaytopics($forum_id, $link_target){ echo "\n<!-- In function displaytopics( '$forum_id', '$link_target' ); -->\n"; if ( ! ( $con = mysql_connect("connect""username","password") )) die( "<br>Oy vey! Failed mysql_connect( ) call in function displaytopics( ) with: " . mysql_error( ) . "<br>" ); if (!mysql_select_db("redeyegamezforum", $con)) die("<br>Failed to select database: " . mysql_error( ) . "<br>"); $sql = "SELECT * FROM topic WHERE parent_forum = '$forum_id'"; if(!$result = mysql_query($sql, $con)){ die( "<br>Error querying mySQL database.<br>"); } if ( mysql_num_rows( $result ) == 0 ) die( "<br />Query returned no results in function displaytopics( ). Goodbye!<br />" ); while($topic = mysql_fetch_assoc($result)){ echo "<tr>"; echo "<td class='topicfiller' colspan='2'>$nbsp;</td>"; echo "<td class='topiclink'>"; echo '<a href="' . $link_target . '?topicid =' . $topic['id'] . '">'; echo $topic['name'] . "</a></td>"; echo "<td class='topicdesc'>" . $topic['description'] . "</td></tr><br />"; } // end while( mysql_fetch_assoc( ) ) } // end function displaytopics( ) $con = mysql_connect("connect","username","password"); if(!$con){ die("error connnecting to forums database."); } if ( ! mysql_select_db("redeyegamezforum", $con) ) die( mysql_error( ) ); $sql = "CREATE TABLE forums( id INTEGER UNSIGNED NOT NULL auto_increment, name VARCHAR(100) NOT NULL, description TEXT NOT NULL, PRIMARY KEY(id) )"; mysql_query($sql, $con); $sql = "CREATE TABLE topic( parent_forum INTEGER UNSIGNED NOT NULL, id INTEGER UNSIGNED NOT NULL auto_increment, name VARCHAR(100), description TEXT NOT NULL, PRIMARY KEY(id) )"; mysql_query($sql, $con); $sql = "CREATE TABLE thread( parent_topic INTEGER UNSIGNED NOT NULL, id INTEGER UNSIGNED NOT NULL auto_increment, subject TEXT NOT NULL, replies INTEGER UNSIGNED, last_post TIMESTAMP, PRIMARY KEY(id) )"; mysql_query($sql, $con); $sql = "CREATE TABLE post( parent_topic INTEGER UNSIGNED NOT NULL, id INTEGER UNSIGNED NOT NULL auto_increment, author VARCHAR(100) NOT NULL, body TEXT, in_reply_to INTEGER UNSIGNED, date TIMESTAMP, PRIMARY KEY(id) )"; mysql_query($sql, $con); $sql = "SELECT * FROM forums WHERE name = 'REDEYEGAMEZ'"; if ( ! ( $result = mysql_query($sql, $con) ) ) die( "<br>" . mysql_error( ) . "<br> "); if ( ! ( $row = mysql_fetch_assoc($result) ) ) die( "<br>" . mysql_error( ) . "<br> "); if($row['name'] != "REDEYEGAMEZ"){ $sql = "INSERT INTO forums(name, description) VALUES('REDEYEGAMEZ','General talk about redeyegamez')"; mysql_query($sql, $con); } $sql = "SELECT * FROM topic WHERE name = 'Rants'"; if(!($result = mysql_query($sql, $con))) die("<br />" . mysql_error($con) . "<br />"); if (!($row = mysql_fetch_assoc($result))) die("<br />" . mysql_error($con) . "<br />"); if($row['name'] != "Rants"){ $sql = "INSERT INTO topic(parent_forum, name, description) VALUES(1, 'Rants', 'Things you don't like about our site.')"; mysql_query($sql, $con); } $sql = "SELECT * FROM forums"; if ( ! ( $result = mysql_query($sql, $con) ) ) die( "<br>" . mysql_error( ) . "<br> "); if ( mysql_num_rows( $result ) == 0 ) die( "<br>Query '" . $sql . "' returned zero rows.<br>" ); echo "<table width='100%' class='forumline' cellpadding='4' cellspacing='2' border='0' align='center'>\n"; echo "<tbody>"; while($forum = mysql_fetch_assoc($result)) { echo "\n<!-- in the while( ) loop! -->\n"; echo "\n<tr>"; echo "<td class='forumtitle' colspan='5'>"; echo $forum['name']; if ( ! isset( $forum[ 'id' ] ) ) die( "\n<!-- couldn't find ID for this forum -->\n" ); displaytopics($forum['id'], "topic.php"); }?></body></html>
  6. 132591

    PHP vs. ASP.NET

    ASP.NET is microsoft, and that should be enough for you not to learn it.
  7. It would be really cool if you were to give tutorials on things like C++!
  8. 132591

    pointers

    Are there pointers in php? and if so, how do I use them?
  9. Thanks, I would not have thought of that!
  10. Is it possible to use a php form to edit xml? I was thinking something like this. <html><head><title>xml editor</title></head><body><form method="post"><input type="text" name="xml_code" /><input type="submit" value="change xml file" /></form><?php$fp = fopen("edited.xml", "w");fwrite($fp, $_POST['xml_code']);?></body></html>
  11. a bit too much blue, that is all. Other than that I like it very mcuuh
  12. you can just do it by embedding it in html <embed src="foo.mp3" />
  13. I also got Javascript for Dummies, and Javascript - the difinitive guide. They are each great.
  14. I have Javascript-The difinitive Guide, and I htink it is great. I would go with that.
  15. <form name="myform" id="myform"><input type="text" name="mytext" id="mytext" /><input type="submit" value="enter text" /></form><script type="text/javascript"><!--var text = document.myform.mytext.value;document.write(text);--></script> Why does this not work?
×
×
  • Create New...