Jump to content

velocite

Members
  • Posts

    16
  • Joined

  • Last visited

    Never

Everything posted by velocite

  1. Try this mysql_query = ("SELECT * FROM table ORDER BY dates DESC");
  2. So when i output i apply that function like this? <?php $text = nl2br($row[$id]['body']); ?>
  3. Ive been writing a CMS, for sometime, learning as I'm going. Main problem is this: When i submit a news article, for example i write this in the box: once i display the news article is displays This is my post script <?php //Setting variable for the input values $title_input = $_POST['title']; $body_input = $_POST['bodytext']; $date = date(Ymd); //Including neccessary files to connect to database require( '../connect.php'); require( '../config/config.php'); if (!isset($_POST['title'])) { header('location:../addnews.php'); } if (!isset($_POST['bodytext'])) { header('location:../addnews.php'); } //Selecting the Database mysql_select_db('test', $dbconnect); //Add the inputted content into the database mysql_query ( $addnews = "INSERT INTO news (news_title, news_body, news_author, news_date) VALUES ('$title_input', '$body_input', 'author', '$date')" ); //If statement about displaying error message if (!$addnews) { $_SESSION['texterror'] = die('Adding the news failed ' . mysql_error()); header('Location: ../addnews.php'); } else { $_SESSION['textsuccess'] = '<font color=green>Adding the news was successful</font><br /><br />'; header('Location: ../addnews.php'); } ?>
  4. Still doesnt work, it still displays a blank white page...
  5. 1. folder/script the bold is where the script is located and the location should be a page called 'test4.php' in the previous folder called 'folder' 2. the output is meant to be in the form of a session message. 3. As an additional question, how the heck do you stop a <?php echo $_SESSION['session_name']; ?> being display before its actually set.
  6. Hi again I have two problems: 1. How can i set the location so its a folder below 2. Once executed the page displays an empty screen <?php //Start session session_start(); //Setting variable for the input values $title_input = $_POST['title']; $body_input = $_POST['bodytext']; $id = $_POST['id']; $docroot = $_SERVER['DOCUMENT_ROOT']; //Including neccessary files to connect to database include( '../connect.php'); include( '../config/config.php'); if (!isset($_POST['title'])) { header('Location: ' . $docroot . '/test/test4.php'); $_SESSION['edit_msg'] = '<font color=red>Please fill in the fields</font>'; } if (!isset($_POST['bodytext'])) { header('Location: ' . $docroot . '/test/test4.php'); $_SESSION['edit_msg'] = '<font color=red>Please fill in the fields</font>'; } //Selecting the Database mysql_select_db('mycms', $dbconnect); //Add the inputted content into the database //"UPDATE example SET age='22' WHERE age='21'" mysql_query ( $edittitle = "UPDATE news SET news_title='$title_input' WHERE news_id='$id'" ) or die("MySQL Error:\nMySQL Returned: ".mysql_error()); mysql_query ( $editbody = "UPDATE news SET news_body='$body_input' WHERE news_id='$id'" )or die("MySQL Error:\nMySQL Returned: ".mysql_error()); //If statement about displaying error message if (!$edittitle || !$editbody) { //If unsuccessful, force cancel the operation and display error message $_SESSION['edit_msg'] = die('Adding the news failed ' . mysql_error()); header('Location: ' . $docroot . '/test/test4.php'); } else { $_SESSION['edit_msg'] = '<font color=green>Adding the news was successful</font><br /><br />'; header('Location: ' . $docroot . '/test/test4.php'); } ?> Please help
  7. so even if it doesn't, i can write it in yea?
  8. Ohh , thanks for the link So are you saying that I dont need all that php code?
  9. Hey everyone, I have been look this website, on how to clean urls, for example, instead of: "http://www.something.com/index.php?newsid=2" its, "http://www.something.com/news/2/" You guys can find the article here: http://www.alistapart.com/articles/succeed/ However my main problem is the code provided, I have no idea what to put in lines 21 and 29 the code is here: <?php //1. check to see if a "real" file exists.. if(file_exists($DOCUMENT_ROOT.$REQUEST_URI) and ($SCRIPT_FILENAME!=$DOCUMENT_ROOT.$REQUEST_URI) and ($REQUEST_URI!="/")){ $url=$REQUEST_URI; include($DOCUMENT_ROOT.$url); exit(); } //2. if not, go ahead and check for dynamic content. $url=strip_tags($REQUEST_URI); $url_array=explode("/",$url); array_shift($url_array); //the first one is empty anyway if(empty($url_array)){ //we got a request for the index include("includes/inc_index.php"); exit(); } //Look if anything in the Database matches the request //This is an empty prototype. Insert your solution here. if(check_db($url_array)==true()){ do_some_stuff(); output_some_content(); exit(); } //3. nothing in DB either Error 404! }else{ header("HTTP/1.1 404 Not Found"); exit(); }
  10. Hmm it seems i havent explained my question well enough.. In phpMyAdmin, there is a privileges section, where it lists out users who can create,change,delete databases etc. What i want to know is, is this: is there a php function that finds out THESE usernames.
  11. Hey there again, I have come across a minor hiccup in my adventure of learning php. What I am doing is setting up an 'if' statement that lets a user type in their mySQL database username, and i want to find out if there is a php function that lets me get the 'mySQL database username' e.g. 'root' Code so far: <?php if($_POST["mysql_user"] != FUNCTION TO FIND MYSQL USER) { echo " <br /> <br /> <b>MySQL Username does not exist</b> "; } ?>
  12. Ohh ok, so doing that tells me the problem, thanks DarkerAngel Valuable tip
  13. Hi everyone, I am kinda new to this PHP coding thing, I was wondering if you guys could help me with this: <?php include('connect.php'); include('config.php'); $query = mysql_query("SELECT * FROM news ORDER BY news_id DESC"); $totalnews = @mysql_num_rows($query); $i = "0"; if ($totalnews == '0') { echo "<div class='nonews'>"; echo "News has not been added."; echo "</div>"; } else { while($row = mysql_fetch_array($query)) { $news[$i]['news_id'] = $row[$i]['news_id']; $news[$i]['news_title'] = $row[$i]['news_title']; $news[$i]['news_body'] = $row[$i]['news_body']; echo " <div class='newshead'> ".$news[$i]['news_title']." </div> <div class='newsbody'> ".$news[$i]['news_body']." </div> </br> "; $i++; } } ?> what i am trying to do is basically connect to the database, then try using classes to get and display the news by its news_id. I have no idea what I am doing wrong, as it isn't displaying the news. Please help, thanks everyone
×
×
  • 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.