Jump to content

john010117

Members
  • Posts

    492
  • Joined

  • Last visited

    Never

Posts posted by john010117

  1. Even though it didn't say if it worked or not, it didn't show any errors, either (using your code).

    Here's my form code:
    [code]
    <form action="test10.php">
    <input name="news" size="30">
    <input type="submit" value="submit">
    </form>
    [/code]

    ...and here's my test10.php code:
    [code]
    <?php
    $db_host = "&*<?php
    $db_host = "****";
    $db_user = "****";
    $db_pass = "****";
    $db_name = "****";
    $dbac = mysql_connect($db_host,$db_user,$db_pass);
    mysql_select_db ($db_name) or die ("Cannot connect to database");

    $date = date("m.d.Y")." at ".date("h:i:s a");
    mysql_query("INSERT INTO news (text, date) VALUES ('{$_POST['text']}', $date)");
    ?>
    <?php
    $db_host = "****";
    $db_user = "****";
    $db_pass = "****";
    $db_name = "****";
    $dbac = mysql_connect($db_host,$db_user,$db_pass);
    mysql_select_db ($db_name) or die ("Cannot connect to database");

    $date = date("m.d.Y")." at ".date("h:i:s a");
    mysql_query("INSERT INTO news (text, date) VALUES ('{$_POST['text']}', $date)");
    ?>
    ";
    $db_user = "allaoorg_admin1";
    $db_pass = "9055084308";
    $db_name = "****";
    $dbac = mysql_connect($db_host,$db_user,$db_pass);
    mysql_select_db ($db_name) or die ("Cannot connect to database");

    $date = date("m.d.Y")." at ".date("h:i:s a");
    mysql_query("INSERT INTO news (text, date) VALUES ('{$_POST['text']}', $date)");
    ?>
    [/code]

    Am I doing it right so far?
  2. I have read the stickies/announcements, and they [i]did[/i] say how to do this. But they didn't explain it further, and the link they've posted for further reading doesn't work. So, here's my problem.

    On my index page, I have a news section. No php needed for that. But I want the website to automatically archive old news when the next day comes. So, if I type in index.php, it should automatically get the news for today (but I'm typing up the news). Sorry if this doesn't make sense. I want to have something [url=http://halo.bungie.org]like this[/url] (see the date at the top and the arrows?). How do you do that?
  3. Ok, I've gotten rid of [i]that[/i] error. Now, it's saying something like this:
    [quote]
    [b]Warning[/b]: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /****/****/****.awardspace.com/test5.php on line [b]47[/b]
    No results where found sorry :(
    [/quote]

    [color=red]Note[/color] That last line is supposed to be there when no results are found.

    I've searched the [url=http://us3.php.net/manual/en/function.mysql-num-rows.php]MySQL manual for that code[/url], but it said that it should be used this way... anyone care to help please?  ???
  4. [b]ProjectFear[/b], I've used your code, but when I load the page, it says the following message:
    [quote]
    [b]Parse error[/b]: parse error, unexpected '}' in [b]/****/****/****.awardspace.com/test5.php[/b] on line [b]56[/b]
    [/quote]

    Ok, so then I removed the "}"s in front of the "//End While" and "// End Else" tags. Now, it says this:
    [quote]
    [b]Parse error[/b]: parse error, unexpected $ in [b]/****/****/****.awardspace.com/test5.php[/b] on line [b]58[/b]
    [/quote]

    The problem is... there is no "$" tag in line 58 (or anywhere near that). Please help.

    PS: [b]wattsup88[/b], if you look on top of this page, and the near bottom of the previous page, you'll see that I've posted both of the codes.
  5. Ok then.

    [code]
    <?php
    // Search Tutorial Code
    // Arutha.co.uk

    // Standard Connection Data.
    $db_host = "****.awardspace.com";
    $db_user = "****_db1";
    $db_pass = "********";
    $db_name = "****_db1";
    $dbac = mysql_connect($db_host,$db_user,$db_pass);
    mysql_select_db ($db_name) or die ("Cannot connect to database");

    if (!$_POST['search']){
    // Breaking out of php to display the form.
    ?>
    <form name="Search Tutorial" method="post" action="">
      Search Words:<br>
      <label>
      <input name="swords" type="text" size="30" maxlength="30">
      </label> 
      <br>
      <label>
      <input name="search" type="submit" id="search" value="Search">
      </label>
    </form>
    <?php
    }else{
    // Adding slashes and changing tags so that people trying to take advantage of the system can't
    $searchwords = addslashes(htmlspecialchars($_POST['swords']));
    // Checking the length of string to make sure its more than 3 characters long
    if (strlen($searchwords) < 3){
    echo "The word you have inputted is too short, please enter another one.";
    }else{
    $words = explode(' ',$searchwords);
    $totalwords = count($words);
    $i = 0;
    $searchstring = "";
    // Now we are looping to get the search string, however we could use a for loop.
    // But i think while loops are much easier to teach with/edit
    while ($i != $totalwords){
    if ($i != 0 and $i != $wordcount){
    $searchstring .= " and ";;
    }
    $searchstring .= "description LIKE '%$words[$i]%' or name LIKE '%$words[$i]%'";
    // Incrementing the value
    $i = $i + 1;
    }
    // Now we are gong to execute the query with the search string we have just created.
    $query = mysql_query("SELECT DISTINCT * FROM Search where $searchstring");
    // Want to check that we got something 
    if (mysql_unbuffered_query($query) == 0){
    echo "No results where found sorry :(";
    }else{
    while ($fet = mysql_fetch_array($query)){
    echo "<p>Name: {$fet['name']}<br />
          Description: {$fet['description']}</p>";
    }// End While
    }// End Else
    }// End Else
    }// End Else
    ?>
    [/code]

    [color=red]Note:[/color] I've double checked to see that the MySQL entries are correct (I put those stars to prevent anyone from seeing sensitive information).

    Can you please figure out what's wrong? I always get the same result: "No results were found sorry :(".
  6. [color=red]Edit:[/color] I've just gotten this code from the website. I've sucessfully installed it, and no error messages appear. But something seems to be wrong. Let me show you the code first.

    This goes into the db.
    [code]
    CREATE TABLE `search` (
    `id` int(5) NOT NULL auto_increment,
    `name` varchar(50) NOT NULL default '',
    `description` varchar(255) NOT NULL default '',
    PRIMARY KEY (`id`)
    ) TYPE=MyISAM AUTO_INCREMENT=6 ;

    --
    -- Dumping data for table `search`
    --

    INSERT INTO `search` VALUES (1, 'Arutha', 'Arutha is a talented coder and designer who runs http://arutha.co.uk');
    INSERT INTO `search` VALUES (2, 'Psycho_Phrog', 'A freind off arutha writes the occasional ps tutorial');
    INSERT INTO `search` VALUES (3, 'Djc123', 'another freind of arutha, he''s currently doing the photography side of photoshop with promising results');
    INSERT INTO `search` VALUES (4, 'Stu', 'Moderator at p2l, provides critisim and advice on arutha.co.uk to arutha');
    INSERT INTO `search` VALUES (5, 'you', 'are reading this tutorial and hopefully finding it usefull');
    [/code]

    I'll show you the other part of the code later (but I seriously think the above code has something wrong in it).

    So, when I search the word "Arutha", it has to give me results, right? But it doesn't. What seems to be the problem with this?
  7. It only showed an error...

    [quote][b]SQL Query:[/b]
    $result = @mysql_query (

    "SELECT * FROM `phpbb` WHERE `word`='$word'", $cn
    ) OR die(
    mysql_error(
    )
    )

    [b]MySQL said:[/b]
    #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '$result=@mysql_query("SELECT * FROM `words` WHERE `word`='$word'[/quote]

    Is there something I have to change in that code? (Yes, I know. I know NOTHING  about MySQL.
×
×
  • 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.