Jump to content

beaux1

Members
  • Posts

    55
  • Joined

  • Last visited

    Never

Posts posted by beaux1

  1. Ehm, hmm, well, I was thinking, having a table called comments, which stores the comments, but how would I go about linking or making them relevent to the blog post itself?

     

    I was thinking of making a column called blogid, and when a user submits a comment, it inserts the blogid into that, so therefore I can call all comments WHERE blogid = 2, for example.

     

    I'm sure that would work fine, but is it a messy workaround to do what I'm trying to achieve?

  2. Yeah, I know I have a box, the user can enter comments, and the database will retrieve the information and display all the comments, but how do I go about splitting the comments up?

    Let's say I have:

    ID  name  date  subject  msg          comments

    1        test              1/1/1          cereal          test       

    How would I go about splitting the comments up and knowing which is which etc?

  3. Hey guys.

     

    I'm working on my own blog/news script, and I'm about to work on the comments system.

     

    My MySQL database is plotted out like so:

    ID  name  date  subject  msg

     

    Alright, simple enough.

     

    But, what would the best way going about the comments in my script?

    I'm just not sure about how to go about this, I understand inserting data (in this case the comments) into the database, but how would I go about doing it in general?

     

    I'm not making much sense, I know, I know, but could someone please guide me in the right direction?

     

    Thanks.

  4. Well a table for each story would be rather unnecessary. I mean, if you have 100 stories then 100 SQL tables it isn't going to be efficient.

     

    If I was you I'd have 1 table for all 100 stories, and then sort them on the page you're displaying them on by using a ORDER statement such as:

    ORDER BY title;

     

    'Title' is the title of the story, so your stories will be listed alphabetically on the page.

     

  5. Okay, I decided to use file_get_contents :

    	$sql = file_get_contents("sql.sql");
    // End Retrieve SQL Query 
    if (mysql_query($sql)) {
    

     

    Now, my sql.sql file works if I import it into phpMyAdmin, or if I only have one of the two SQL Queries in here.

     

    Anyway I can somehow format them so it will read the both of them and work?

     

    CREATE TABLE admin (
      ID int(7) NOT NULL auto_increment,
      username varchar(15) default NULL,
      password varchar(32) default NULL,
      PRIMARY KEY  (ID),
      UNIQUE KEY id (ID)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
    CREATE TABLE posts (
      ID int(7) NOT NULL auto_increment,
      name varchar(15) default NULL,
      date varchar(100) default NULL,
      subject varchar(100) default NULL,
      PRIMARY KEY  (ID),
      UNIQUE KEY id (ID)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

     

  6. I'm not precisely sure which section this is belong to, but I'll put it in MySQL.

     

    Basically, I want to be able to run my .SQL file from the PHP script. I know it's possible, as I've seen it been done before, examining other code except I can't exactly work out how it's done. I've googled it, but there's just so many damn ways I've seen of it being done, it confuses the hell out of me.

     

    Can anyone share their wisdom with me here?

     

    Thans ;)

  7. I'm having an MD5 problem when logging in with my PHP code.

     

    Basically, the registration form encrypts the users password in MD5. That's all fine.

    Then we have the login form, the password entered is then converted to MD5 so the SQL DB can validate it. I debugged it and the entered password is successfully being encrypted by echoing $password. My problem is that it doesn't validate with the SQL database and instead goes back to login.php (because it failed).

     

    Any help would be greatly appreciated, thanks.

     

    http://pastebin.ca/433142

  8. Okay, this is the portion of my code relevant.

     

    	<div id="menu">
    <ul class="ul">
    	<li class="menu.li"><a href="http://www.beau.ws">
    	<div class="home">
    		<br />
    		<span class="menufont">home</span></div>
    	</a></li>
    	<li class="menu.li"><a href="http://www.beau.ws/portfolio">
    	<div class="portfolio">
    		<br />
    		<span class="menufont">portfolio</span></div>
    	</a></li>
    	<li class="menu.li"><a href="http://www.beau.ws/downloads">
    	<div class="downloads">
    		<br />
    		<span class="menufont">downloads</span></div>
    	</a></li>
    	<li class="menu.li"><a href="http://www.beau.ws/about">
    	<div class="about">
    		<br />
    		<span class="menufont">about</span></div>
    	</a></li>
    	<li class="menu.li"><a href="http://www.beau.ws/contact">
    	<div class="contact">
    		<br />
    		<span class="menufont">contact</span></div>
    	</a></li></ul>
    </div>
    

     

    And this is the XHTML Validator:

    # Error  Line 24 column 19: document type does not allow element "div" here; missing one of "object", "applet", "map", "iframe", "button", "ins", "del" start-tag.

     

    <div class="home">

     

    The mentioned element is not allowed to appear in the context in which you've placed it; the other mentioned elements are the only ones that are both allowed there and can contain the element mentioned. This might mean that you need a containing element, or possibly that you've forgotten to close a previous element.

     

    One possible cause for this message is that you have attempted to put a block-level element (such as "<p>" or "<table>") inside an inline element (such as "<a>", "<span>", or "<font>").

     

    Now, I'm not sure what I'm doing wrong here, I'm using the <a> to link the bg image of the div by the way, so I can't remove that/change that around without it messing up.

     

    Anyone shed any light on this?

     

    Thanks.

  9. My CSS:

    <style type="text/css">

    body { font-family: tahoma; font-size: 75%; color: #ffffff; background: #454242 }

    a { text-decoration: none; color: #eebb99 }

    h1,h2 { margin: 0px; background: #6c5f59 }

    h1 { font-size: 150% }

    h2 { font-size: 100%; margin-top: 1em }

    .hl { font-style: italic }

    .plus { float: right; font-size: 8px; font-weight: normal; padding: 1px 4px 2px 4px; margin: 0px 0px; background: #eb9; color: #000; border: 1px solid #da8; cursor: hand; cursor: pointer }

    .plus:hover { background: #da8; border: 1px solid #c97 }

    ul { list-style: none; padding-left: 0px; margin: 0px }

    li { margin: 0px }

    li:hover { background: #2e2a2a; }

    li a { display: block; width: 100%; }

    </style>

     

    It works, but it doesn't show the body (background color). It's called by PHP like so:

    echo '<link rel="stylesheet" href="/navcss/' . $_COOKIE['menucss'] . '.css" />';

    I know it's working, because it displays some of the css so I'm pretty sure it isn't a PHP problem, it just doesn't display  the body.

    If I were to put it in a normal document though by itself, it would work.

    Anyone know why/what the solution is?

  10. Alright, here's my code now:

    <?php
    include 'config.php';
    include 'opendb.php';
    $query = "SELECT `number`, `first`, `section`, `district`, SUM(leathersuit + leathersuit2 + leathersuit3 + leathersuit4 + leathersuit5 + leathersuit6 + leathersuit7 +leathersuit8 + leathersuit9 + leathersuit10) AS leathersuit_count, SUM(helmet + helmet2 + helmet3 + helmet4 + helmet5 + helmet6 + helmet7 + helmet8 + helmet9 + helmet10) AS helmet_count, SUM(rainsuit + rainsuit2 + rainsuit3 + rainsuit4 + rainsuit5 + rainsuit6 + rainsuit7 + rainsuit8 + rainsuit9 + rainsuit10) 
    AS rainsuit_count, SUM(polotop + polotop2 + polotop3 + polotop4 + polotop5 + polotop6 + polotop7 + polotop8 + polotop9 + polotop10) AS polotop_count, SUM(poloneck + poloneck2 +  poloneck3 + poloneck4 + poloneck5 + poloneck6 + poloneck7 + poloneck8 + poloneck9 + poloneck10) AS poloneck_count, SUM(gloves + gloves2 + gloves3 + gloves4 + gloves5 + gloves6 + gloves7 + gloves8 + gloves9 + gloves10) 
    AS gloves_count, SUM(boots + boots2 + boots3 + boots4 + boots5 + boots6 + boots7 + boots8 + boots9 + boots10) AS boots_count, 
    SUM(underwear + underwear2 + underwear3 + underwear4 + underwear5 + underwear6 + underwear7 + underwear8 + underwear9 + underwear10) AS underwear_count, SUM(eyewear + eyewear2 + eyewear3 + eyewear4 + eyewear5 + eyewear6 + eyewear7 + eyewear8 + eyewear9 + eyewear10) AS eyewear_count, SUM(earplugs + earplugs2 + earplugs3 + earplugs4 + earplugs5 + earplugs6 + earplugs7 + earplugs8 + earplugs9 + earplugs10) AS earplugs_count, 
    SUM(belt + belt2 + belt3 + belt4 + belt5 + belt6 + belt7 + belt8 + belt9 + belt10) AS belt_count, SUM(pinlock + pinlock2 + pinlock3 + pinlock4 + pinlock5 + pinlock6 + pinlock7 + pinlock8 + pinlock9 + pinlock10) AS pinlock_count FROM `information`";
    $result = mysql_query($query) or die(mysql_error()); 
    while($row = mysql_fetch_array($result, MYSQL_ASSOC))
    {
    echo $row['pinlock_count'];
    }
    
    
    include 'closedb.php';
    ?>

     

    And I get:

    Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause

     

    What's that mean?

  11. See, I think I'm doing something wrong with the SQL.

    I keep getting:

    Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\wamp\www\display2.php on line 31
    
    Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\wamp\www\display2.php on line 32
    
    Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\wamp\www\display2.php on line 33
    
    Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\wamp\www\display2.php on line 34
    
    Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\wamp\www\display2.php on line 35
    
    Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\wamp\www\display2.php on line 36
    
    Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\wamp\www\display2.php on line 37
    
    Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\wamp\www\display2.php on line 38
    
    Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\wamp\www\display2.php on line 39
    
    Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\wamp\www\display2.php on line 40
    
    Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\wamp\www\display2.php on line 41
    Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause

     

    Here's my code:

    <?php
    include 'config.php';
    include 'opendb.php';
    
    $query = "SELECT `number`, `first`, `section`, `district`, SUM(leathersuit + leathersuit2 + leathersuit3 + leathersuit4 + leathersuit5 + leathersuit6 + leathersuit7 +leathersuit8 + leathersuit9 + leathersuit10) AS leathersuit_count, SUM(helmet + helmet2 + helmet3 + helmet4 + helmet5 + helmet6 + helmet7 + helmet8 + helmet9 + helmet10) AS helmet_count, SUM(rainsuit + rainsuit2 + rainsuit3 + rainsuit4 + rainsuit5 + rainsuit6 + rainsuit7 + rainsuit8 + rainsuit9 + rainsuit10) 
    AS rainsuit_count, SUM(polotop + polotop2 + polotop3 + polotop4 + polotop5 + polotop6 + polotop7 + polotop8 + polotop9 + polotop10) AS polotop_count, SUM(poloneck + poloneck2 +  poloneck3 + poloneck4 + poloneck5 + poloneck6 + poloneck7 + poloneck8 + poloneck9 + poloneck10) AS poloneck_count, SUM(gloves + gloves2 + gloves3 + gloves4 + gloves5 + gloves6 + gloves7 + gloves8 + gloves9 + gloves10) 
    AS gloves_count, SUM(boots + boots2 + boots3 + boots4 + boots5 + boots6 + boots7 + boots8 + boots9 + boots10) AS boots_count, 
    SUM(underwear + underwear2 + underwear3 + underwear4 + underwear5 + underwear6 + underwear7 + underwear8 + underwear9 + underwear10) AS underwear_count, SUM(eyewear + eyewear2 + eyewear3 + eyewear4 + eyewear5 + eyewear6 + eyewear7 + eyewear8 + eyewear9 + eyewear10) AS eyewear_count, SUM(earplugs + earplugs2 + earplugs3 + earplugs4 + earplugs5 + earplugs6 + earplugs7 + earplugs8 + earplugs9 + earplugs10) AS earplugs_count, 
    SUM(belt + belt2 + belt3 + belt4 + belt5 + belt6 + belt7 + belt8 + belt9 + belt10) AS belt_count, SUM(pinlock + pinlock2 + pinlock3 + pinlock4 + pinlock5 + pinlock6 + pinlock7 + pinlock8 + pinlock9 + pinlock10) AS pinlock_count FROM `information`";
    $leathersuit_count = mysql_result($result, 0, "leathersuit_count");
    $helmet_count = mysql_result($result, 0, "helmet_count");
    $rainsuit_count = mysql_result($result, 0, "rainsuit_count");
    $polotop_count = mysql_result($result, 0, "polotop_count");
    $poloneck_count = mysql_result($result, 0, "poloneck_count");
    $gloves_count = mysql_result($result, 0, "gloves_count");
    $underwear_count = mysql_result($result, 0, "underwear_count");
    $eyewear_count = mysql_result($result, 0, "eyewear_count");
    $earplugs_count = mysql_result($result, 0, "earplugs_count");
    $belt_count = mysql_result($result, 0, "belt_count");
    $pinlock_count = mysql_result($result, 0, "pinlock_count");
    $result = mysql_query($query) or die(mysql_error()); 
    while($row = mysql_fetch_array($result, MYSQL_ASSOC))
    {
    echo "stuff echoing values will go here";
    }
    
    
    include 'closedb.php';
    ?>

  12. Ok, I played around with it, fixed some stuff, I added print $query, and this is my outcome:

    UPDATE `information` SET `number`='9999',`first`='John',`last`='Murphy',`year`='2007',`section`='Station',`district`='District',`region`='Region',`leathersuit`='1',`helmet`='1',`rainsuit`='1',`polotop`='1',`poloneck`='1',`gloves`='1',`boots`='2',`underwear`='2',`eyewear`='2',`earplugs`=3',`belt`='3',`pinlock`='3' WHERE `id`='21'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 '',`belt`='3',`pinlock`='3' WHERE `id`='21'' at line 1

     

    Is there actually anything wrong with my query?

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