Jump to content

rh91uk

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Posts posted by rh91uk

  1. Hi All!

    Firstly, sorry if I have posted this in the wrong forum!

    I'm kind of in a bit of a dilema. I dont want my users to see a url such as http://www.rhwebdesign.net/profile.php?id=1.

    How do I do a virtual directory in PHP that can interact with mysql, and hence, create a "virtual" directory relative to the ID or title. So, for instance, if the username of profile.php?id=1 was richard, I could have http://www.rhwebdesign.net/richard.

    Mod rewrite is not really an option, because I have no access to it whatsoever.

    Help would be appreciated =D

    Thankyooou!
  2. I want to upload an image to the sql database, but I havent a clue how too! Ive tried google, but most of them are quite out of my league, as in i dont know how to add one to the following code:

    [code]<?php
        session_start();
        if(!$_SESSION['username']){
                header("Location: login.php");
                exit();
            }
        include('../includes/config.inc.php');
        include('../includes/dbconnect.inc.php');
        
    if($_GET['delete']){
        $sql = "DELETE FROM `news` WHERE id='" . $_GET['delete'] . "'";
        $result = mysql_query($sql) or die ("<b>ERROR: </b>" . mysql_error() . "<b>SQL: </b>$sql");
        header("Location: pages.php");
        exit();
    }
    ?>
    <html>
    <head>
    <title>Edit/Add News Story</title>
    <meta http-equiv="Content-Type" content="text/html;">
    <link href="/includes/style.css" rel="stylesheet" type="text/css">
    <style type="text/css">
    <!--
    .style1 {font-size: 14px}
    -->
    </style>
    </head>
    <body>
    <h1>Richard Harris</h1>
    <p class="style1">EDIT NEWS STORY </p>
    <p><?php
                    if(!isset($_POST['Submit'])){
                        $id = $_GET['edit'];
                        $sql = "SELECT * FROM `news` WHERE id='$id'";
                        $result = mysql_query($sql) or die ("<b>ERROR: </b>" . mysql_error() . "<b>SQL: </b>$sql");
                        $rows = mysql_num_rows($result);
                        while ($news = mysql_fetch_array($result)) {
                            $news_title = $news["title"];
                            $news_content = $news["content"];
                            $news_img = $news["img"];
                            }        
                  ?>
    <form method="post" action="<?=$_SERVER['../../../../My%20Documents/admin/PHP_SELF'];?>">
                      
                  <table width="436" border="0" cellpadding="3" cellspacing="1">
                    <tr>
                      <td width="67"><strong>Title</strong></td>
                      <td width="354"><input name="title" type="text" class="txtboxlrg" value="<?=$news_title;?>" size="50"></td>
                    </tr>
                    <input name="id" type="hidden" value="<?=$id;?>">
                    <tr>
                      <td valign="top"><strong>Content</strong></td>
                      <td><textarea name="content" cols="50" rows="22" class="txtboxlrg" width="472"><?=$news_content;?></textarea></td>
                    </tr>
                    <tr>
                      <td></td>
                      <td align="center" class="header2"><input name="Submit" type="submit" onFocus="this.blur();" value="Update"></td>
                    </tr>
                  </table>
    </form>
                <?php
                    } else {
                            if((!$_POST['title']) || (!$_POST['content']) || (!$_POST['img'])){
                                echo "You are missing a required field, please <a href=\"javascript:history.back()\">go back</a> and correct before proceeding!";
                            } else {
                                if($_POST['id']){
                                    $sql = "UPDATE `news` SET title='" . $_POST['title'] . "', content='" . $_POST['content'] . "' , img='" . $_POST['img'] . "', author='" . $_SESSION['firstname'] . " " . $_SESSION['lastname'] . "', updated=NOW() WHERE id = '" . $_POST['id'] . "'";
                                    $result = mysql_query($sql) or die ("<b>ERROR: </b>" . mysql_error() . "<b>SQL: </b>$sql");
                                    echo "News Item \"" . $_POST['title'] . "\" updated successfully - return to <a href=\"pages.php\" onFocus=\"this.blur();\">pages</a>!";
                                } else {
                                    $sql = "INSERT INTO `news`  ( `id` , `title` , `content` , `img` , `author`,  `added` ) VALUES('', '" . $_POST['title'] . "', '" . $_POST['content'] . "', '" . $_POST['img'] . "', '" . $_SESSION['firstname'] . " " . $_SESSION['lastname'] . "', NOW())";
                                    $result = mysql_query($sql) or die ("<b>ERROR: </b>" . mysql_error() . "<b>SQL: </b>$sql");
                                    $id = mysql_insert_id();
                                    echo "News Item \"" . $_POST['title'] . "\" added successfully - return to <a href=\"pages.php\" onFocus=\"this.blur();\">pages</a>";
                                }
                            }
                        }
                    ?></p>
    </body>
    </html>
    [/code]

    If soemone here could help me, maybe write me an addition, i would be greateful!
  3. [!--quoteo(post=386811:date=Jun 22 2006, 07:41 AM:name=obsidian)--][div class=\'quotetop\']QUOTE(obsidian @ Jun 22 2006, 07:41 AM) [snapback]386811[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    this is where your WHERE clause comes in:
    [!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] title, id, type, description, [span style=\'color:blue;font-weight:bold\']update[/span]d [color=green]FROM[/color] [color=orange]portfolio[/color] [color=green]WHERE[/color] type [color=orange]=[/color] [color=red]'Web Design'[/color] [color=green]ORDER BY[/color] id [color=green]DESC[/color] [!--sql2--][/div][!--sql3--]

    good luck
    [/quote]

    Parse error: parse error, unexpected T_STRING in e:\domains\n\notonlybutalso.net\user\htdocs\richardcmstest\websites.php on line 162

    Line 162 is :

    [code]$result = @mysql_query('SELECT title, id, type, description, updated FROM portfolio WHERE type = 'Web Design' ORDER BY id DESC');
    [/code]
  4. Hiya

    I haveb a php script set up, but I want the folllowing query to display only records whos type fields are set up as, "Web Design"

    [code]SELECT title, id, type, description, updated FROM portfolio ORDER BY id DES[/code]

    Probably simple for some people, hehe

    thanx,


    Richard
  5. Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/richard/public_html/noba/index.php on line 167

    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/richard/public_html/noba/index.php on line 169

    Any ideas? All DB connects are in the headers.....
  6. [!--quoteo(post=386035:date=Jun 20 2006, 09:51 AM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Jun 20 2006, 09:51 AM) [snapback]386035[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    You can use this query which should select most recent 3 news posts:
    [!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] * [color=green]FROM[/color] [color=orange]news_table[/color] [color=green]ORDER BY[/color] news_id [color=green]DESC[/color] LIMIT 3 [!--sql2--][/div][!--sql3--]
    Obviously you'll need to change [b]news_table[/b] to the table that stores your news entries and [b]news_id[/b] to the news_id column name.
    [/quote]

    Got another question

    a) How do I convert the above statement in PHP, would:

    [code]<?php
    $query = "SELECT * FROM news_table ORDER BY news_id DESC LIMIT 3";
    mysql_query($query, $mysql_link);
    ?>
    [/code]

    work?

    b) How would I convert that query to display the Three Recent Titles, then linking it to the news story

    c) How could I implement that in PHP

    Sorry for my n00bness

    Ric
  7. [!--quoteo(post=386035:date=Jun 20 2006, 09:51 AM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Jun 20 2006, 09:51 AM) [snapback]386035[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    You can use this query which should select most recent 3 news posts:
    [!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] * [color=green]FROM[/color] [color=orange]news_table[/color] [color=green]ORDER BY[/color] news_id [color=green]DESC[/color] LIMIT 3 [!--sql2--][/div][!--sql3--]
    Obviously you'll need to change [b]news_table[/b] to the table that stores your news entries and [b]news_id[/b] to the news_id column name.
    [/quote]

    Thank you wildteen88 :)
  8. Sorry , should of been more clear.

    We are using MYSQL.

    Script wise - thats what I want to find out. I can pull the data from the database, but not thhe 3 most recent "ids". I dont know how to write the code to do it, as I am self taught, and hence never coming across this kind of situation...

    The script is simple text boxes submitting to a Database (mysql).
  9. Hiya

    I need a bit of advice ... or maybe if some code if your feeling nice :)

    I am writing a content management system, and in it, I have built a News System. But, the problem is, on the homepage I am adding a "Recent 3 News Posts", which will hopefully if I can get the concept together, pull the last 3 Added news stories.

    I havent a clue how to do it though :). Can someone maybe point me in the right direction, or even if your feeling nice, write me a bit of code.

    I would be greatful! :)

    Thanks for help in advance,

    Richard
×
×
  • 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.