Jump to content

132591

Members
  • Posts

    19
  • Joined

  • Last visited

Posts posted by 132591

  1. 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.

  2. 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);	}

  3. 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>

  4. 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>

  5. <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?

  6. would if work if I did something like this?

    <?php[code]<?php $tag = <tag>this is a tag</tag>$fp = fopen("foo.xml", "w");fwrite($tag, $fp);

    would this actually add "<tag>this is a tag</tag>" to the file? I know I ask noobish questions

×
×
  • Create New...