Jump to content

gaugeboson

Members
  • Posts

    39
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

gaugeboson's Achievements

Member

Member (2/5)

0

Reputation

  1. Well here is the code for the page: <?php session_start(); require("config.php"); require("functions.php"); if($_GET['subject']) { if(pf_check_number($_GET['subject']) == TRUE) { $validsub = $_GET['subject']; } else { header("Location: " . $config_basedir); } } require("header.php"); if($_GET['subject']) { $subsql = "SELECT users.username, subjects.* FROM subjects LEFT JOIN users ON subjects.owner_id = users.id WHERE subjects.id = " . $validsub . ";"; $subresult = mysql_query($subsql); $subrow = mysql_fetch_assoc($subresult); echo "<h1>" . $subrow['subject'] . " Summary</h1>"; if($subrow['owner_id'] == 0) { echo "This subject has no owner."; if($_SESSION['SESS_USERNAME']) { echo " If you would like to apply to own this subject, click <a href='applysubowner.php?subject=" . $subject . "'>here</a>."; } } else { echo "This subject is owned by <strong>". $subrow['username'] . "</strong>."; } echo "<p><i>" . $subrow['blurb'] . "</i></p>"; $topicsql = "SELECT count(distinct(topics.id)) AS numtopics, count(questions.id) AS numquestions FROM subjects LEFT JOIN topics ON subjects.id = topics.subject_id LEFT JOIN questions ON topics.id = questions.topic_id WHERE subjects.id = " . $validsub . " AND active = 1;"; $topresult = mysql_query($topsql); $toprow = mysql_fetch_assoc($topresult); echo "<table class='visible' cellspacing=0 cellpadding=5>"; echo "<tr><th class='visible' colspan=2>Statistics</th></tr>"; echo "<tr>"; echo "<td>Total Topics</td><td>" . $toprow['numtopics'] . "</td>"; echo "</tr>"; echo "<tr>"; echo "<td>Total Questions</td><td>" . $toprow[numquestions'] . "</td>"; echo "</tr>"; echo "</table>"; } else { $latqsql = "SELECT questions.id, question, subject FROM subjects, questions, topics WHERE questions.topic_id = topics.id AND topics.subject_id = subjects.id AND active = 1 ORDER BY questions.dateadded DESC;"; $latqresult = mysql_query($latqsql); $latqnumrows = mysql_num_rows($latqresult); echo "<h1>Latest Questions</h1>"; if($latqnumrows == 0) { echo "No questions!"; } else { echo "<ul>"; while($latqrow = mysql_fetch_assoc($latqresult)) { echo "<li><a href='answer.php?id=" . $latqrow['id'] . ## error here "'>" . $latqrow['question'] . "</a> (<i>" . $latqrow['subject'] . "</i>)</li>"; } echo "</ul>"; } } require("footer.php"); ?> Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ']' in /var/www/faq/index.php on line 81
  2. Oh, and the complete error message is this: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ']' in /var/www/faq/index.php on line 81 Thanks
  3. <?php else { $latqsql = "SELECT questions.id, question, subject FROM subjects, questions, topics WHERE questions.topic_id = topics.id AND topics.subject_id = subjects.id AND active = 1 ORDER BY questions.dateadded DESC;"; $latqresult = mysql_query($latqsql); $latqnumrows = mysql_num_rows($latqresult); echo "<h1>Latest Questions</h1>"; if($latqnumrows == 0) { echo "No questions!"; } else { echo "<ul>"; while($latqrow = mysql_fetch_assoc($latqresult)) { echo "<li><a href='answer.php?id=" . $latqrow['id'] . //error here "'>" . $latqrow['question'] . "</a> (<i>" . $latqrow['subject'] . "</i>)</li>"; } echo "</ul>"; } } ?> (edited by kenrbnsn to add tags)
  4. Well I selected the table just fine. But After I ran the query it gave me this error: ERROR 1005 (HY000): Can't create table './forum/#sql-149c_a.frm' (errno: 150)
  5. How do I select a particular database at the SQL command prompt? I am trying to run this: ALTER TABLE messages ADD FOREIGN KEY(topic_id) REFERENCES topics (id) ON DELETE CASCADE; What command do I type in to select a database? Say the database is called "X".
  6. The Zend folder is located here: C:\xampp\htdocs\phpweb20\include\Zend I started over again and got this error message: Warning: require_once(Zend/Loader.php) [function.require-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\phpweb20\htdocs\index.php on line 2 Fatal error: require_once() [function.require]: Failed opening required 'Zend/Loader.php' (include_path='.;C:\xampp\php\pear\') in C:\xampp\htdocs\phpweb20\htdocs\index.php on line 2 <?php require_once('Zend/Loader.php'); Zend_Loader::registerAutoload(); I change the file(don't know if it matters) to the full path: C:\xampp\htdocs\phpweb20\include\Zend\loader.php Doing that created this error then: Warning: Zend_Loader::include_once(Zend\Config\Ini.php) [function.Zend-Loader-include-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\phpweb20\include\Zend\Loader.php on line 83 Warning: Zend_Loader::include_once() [function.include]: Failed opening 'Zend\Config\Ini.php' for inclusion (include_path='.;C:\xampp\php\pear\') in C:\xampp\htdocs\phpweb20\include\Zend\Loader.php on line 83 Warning: Zend_Loader::require_once(Zend/Exception.php) [function.Zend-Loader-require-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\phpweb20\include\Zend\Loader.php on line 87 Fatal error: Zend_Loader::require_once() [function.require]: Failed opening required 'Zend/Exception.php' (include_path='.;C:\xampp\php\pear\') in C:\xampp\htdocs\phpweb20\include\Zend\Loader.php on line 87
  7. Warning: Zend_Loader::include_once(Zend\Config\Ini.php) [function.Zend-Loader-include-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\phpweb20\include\Zend\Loader.php on line 83 Warning: Zend_Loader::include_once() [function.include]: Failed opening 'Zend\Config\Ini.php' for inclusion (include_path='.;C:\xampp\php\pear\') in C:\xampp\htdocs\phpweb20\include\Zend\Loader.php on line 83 Warning: Zend_Loader::require_once(Zend/Exception.php) [function.Zend-Loader-require-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\phpweb20\include\Zend\Loader.php on line 87 Fatal error: Zend_Loader::require_once() [function.require]: Failed opening required 'Zend/Exception.php' (include_path='.;C:\xampp\php\pear\') in C:\xampp\htdocs\phpweb20\include\Zend\Loader.php on line 87 This is the output of my index page. I don't really know where to go from here!
  8. My .htaccess file: RewriteEngine on RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1
  9. Server error! The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script. I am not really sure where to go with this one. If I delete the .htaccess file inside of the htdocs folder I get this message: Warning: require_once(Zend/Loader.php) [function.require-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\phpweb20\htdocs\index.php on line 2 Fatal error: require_once() [function.require]: Failed opening required 'Zend/Loader.php' (include_path='.;C:\xampp\php\pear\') in C:\xampp\htdocs\phpweb20\htdocs\index.php on line 2
  10. The errors displayed in the above post are on the index page. The index file: <?php require("header.php"); $sql = "SELECT entries.*, categories.cat FROM entries, categories WHERE entries.cat_id = categories.id ORDER BY dateposted DESC LIMIT 1;"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); echo "<h2><a href='viewentry.php?id=" . $row['id'] . "'>" . $row['subject'] . "</a></h2><br />"; echo "<i>In <a href='viewcat.php?id=" . $row['cat_id'] ."'>" . $row['cat'] . "</a> - Posted on " . date("D jS F Y g.iA", strtotime($row['dateposted'])) . "</i>"; if(isset($_SESSION['USERNAME']) == TRUE) { echo " [<a href='updateentry.php?id=" . $row['id'] . "'>edit</a>]"; } echo nl2br($row['body']); echo "</p>"; echo "<p>"; $commsql = "SELECT name FROM comments WHERE blog_id = " . $row['id'] . " ORDER BY dateposted;"; $commresult = mysql_query($commsql); $numrows_comm = mysql_num_rows($commresult); if($numrows_comm == 0) { echo "<p>No Comments.</p>"; } else { echo "(<strong>" . $numrows_comm . "</strong>) comments : "; $i = 1; while($commrow = mysql_fetch_assoc($commresult)) { echo "<a href='viewentry.php?id=" . $row['id'] . "#comment" . $i . "'>" . $commrow['name'] . "</a> "; $i++; } } echo "</p>"; $prevsql = "SELECT entries.*, categories.cat FROM entries, categories WHERE entries.cat_id = categories.id ORDER BY dateposted DESC LIMIT 1, 5;"; $prevresult = mysql_query($prevsql); $numrows_prev = mysql_num_rows($prevresult); if($numrows_prev == 0) { echo "<p>No Previous entries.</p>"; } else { echo "<ul>"; while($prevrow = mysql_fetch_assoc($prevresult)) { echo "<li><a href='viewentry.php?id=" . $prevrow['id'] . "'>" . $prevrow ['subject'] . "</a></li>"; } } echo "</ul>"; require("footer.php"); ?> The header file: <?php session_start(); require("config.php"); $db = mysql_connect($dbhost, $dbuser, $dbpassword); mysql_select_db($dbdatabase, $db); ?> <html> <head> <title><?php echo $config_blogname; ?></title> <link rel="stylesheet" href="1stylesheet.css" type="text/css" /> </head> <body> <div id="header"> <h1><?php echo $config_blogname; ?></h1> [<a href="index.php">Home</a>] [<a href="viewcat.php">categories</a>] <?php if(isset($_SESSION['USERNAME']) == TRUE) { echo "[<a href='logout.php'>Logout</a>]"; } else { echo "[<a href='login.php'>Login</a>]"; } if(isset($_SESSION['USERNAME']) == TRUE) { echo " - "; echo "[<a href='addentry.php'>add entry</a>]"; echo "[<a href='addcat.php'>add category</a>]"; } ?> </div> <div id="main"> The config.php file : <?php $dbhost = "localhost"; $dbhuser = ""; $dbpassword = ""; $dbdatabase = ""; $config_blogname = ""; $config_author = ""; $config_basedir = "http://127.0.0.1"; ?>
  11. Well I can access the database through MySQL Administrator. The server is localhost, say the username is "X" and the password is "Y". I have my config.php file set to this: <?php $dbhost = "localhost"; $dbhuser = "X"; $dbpassword = "Y"; $dbdatabase = "forum"; $config_basedir = "http://127.0.0.1"; ?> Yet still it does not work.
  12. I am having some trouble pulling up the database through my PHP application. These are the error messages: Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'www-data'@'localhost' (using password: YES) in /var/www/header.php on line 4 Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /var/www/header.php on line 5 Warning: mysql_query() [function.mysql-query]: Access denied for user 'www-data'@'localhost' (using password: NO) in /var/www/index.php on line 30 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /var/www/index.php on line 30 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /var/www/index.php on line 31 I don't understand what it means by using password "yes" and "no".
  13. Parse error: syntax error, unexpected T_IS_EQUAL in C:\xampp\htdocs\newtopic.php on line 88 <?php session_start(); require("config.php"); require("functions.php"); $db = mysql_connect($dbhost, $dbuser, $dbpassword); mysql_select_db($dbdatabase, $db); $forchecksql = "SELECT * FROM forums;"; $forcheckresult = mysql_query($forchecksql); $forchecknumrows = mysql_num_rows($forcheckresult); if($forchecknumrows == 0) { header("Location: " . $config_basedir); } if(isset($_GET['id']) == TRUE) { if(is_numeric($_GET['id']) == FALSE) { $error = 1; } if($error == 1) { header("Location: " . $config_basedir); } else { $validforum = $_GET['id']; } } else { $validforum = 0; } if(isset($_SESSION['USERNAME']) == FALSE) { header("Location: " . $config_basedir . "/login.php?ref=newpost&id=" . $validforum); if($_POST['submit']) { if($validforum == 0) { $topicsql = "INSERT INTO topics(date, user_id, forum_id, subject) VALUES(NOW() , " . $_SESSION['USERID'] . ", " . $_POST['forum'] . ", '" . $_POST['subject'] . "');"; } else { $topicsql = "INSERT INTO topics(date, user_id, forum_id, subjet) VALUES(NOW() , " . $_SESSION['USERID'] . ", " . $validforum . ", '" . $_POST['subject'] . "');"; } mysql_query($topicsql); $topicid = mysql_insert_id(); $messages = "INSERT INTO messages(date, user_id, topic_id, subject, body) VALUES(NOW() , " . $_SESSION['USERID'] . ", " . mysql_insert_id() . ",'" . $_POST['subject'] . "', '" . $_POST['body'] . "');"; mysql_query($messagesql); header("Location: " . $config_basedir . "/viewmessages.php?id=" . $topicid); } else { require("header.php"); if($validforum !=0) { $namesql = "SELECT name FROM forums ORDER BY name;"; $nameresult = mysql_query($namesql); $namerow = mysql_fetch_assoc($nameresult); echo "<h2>Post a new message to the " . $namerow['name'] . " forum</h2>"; } else { echo "<h2>Post a new message</h2>"; } ?> <form action="<?php echo pf_script_with_get($SCRIPT_NAME); ?>" method="post"> <table> <?php if($validforum) == 0) { $forumsql = "SELECT * FROM forums ORDER BY name;"; $forumsresult = mysql_query($forumssql); ?> <tr> <td>forum</td> <td> <select name="forum"> <?php while($forumsrow = mysql_fetch_assoc($forumsresult)) { echo "<option value='" . $forumsrow['id'] . "'>" . $forumsrow['name'] . "</option>"; } ?> </select> </td> </tr> <?php } ?> <tr> <td>subject</td> <td><input type="text" name="subject"></td> </tr> <tr> <td>body</td> <td><textarea name="body" rows="10" cols="50"></textarea></td> </tr> <tr> <td></td> <td><input type="submit" name="submit" value="post!"></td> </tr> </table> </form>
×
×
  • 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.