TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 02-03-2008, 10:39 AM   #1 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default Poll System, page blank. :/

PHP Code:
<?php
session_start
();
require 
'config.php';
?>
<html>
<head>
<title>Poll System</title>
<style>
div.container {
 background:#eee;
 border:1px solid grey;
 padding:.20em;
 margin:auto;
 display:inline;
}

div.title {
  font-family:arial;
  font-weight:bold;
  color:red;
  padding:.10em;
  border:1px solid grey;
  font-size:15px;
  display:block;
}

div.amount {
  font-weight:bold;
  font-size:15px;
  font-family:Helvetica;
  color:black;
  padding:.10em;
  border-left:1px solid grey;
  border-bottom:1px solid grey;
  display:block;
}

div.option {
  font-weight:bolder;
  font-size:15px;
  font-family:helvetica;
  color:black;
  display:block;
}

div.bar {
 background: url('bar.png') repeat-x;
 display:inline;
 height:7px;
 width:<?php 
 number_format
(ceil($row['amount']));
 
?>;
}
</style>

</head>
<body>
<?php
$id 
$_GET['id'];
$img '';
if ( isset(
$id) && !isset($query) )
{
    
$query mysql_query("SELECT * FROM `polls` WHERE `id`='$id' LIMIT 5");
    while (
$row mysql_fetch_array($query) or die(mysql_error()))
    {
        if (
mysql_num_rows($id)!=0)
        {
            if (isset(
$row['options']) || !empty($row['options']))
            {
                if (
$row['title'])
                {
                    print 
'<div class="title">'.$row['title']."</div><br />";
                }

                if (
$row['options'])
                {
                    for (
$i=1;$i<=$row['options'];$i++)
                    {
                        
$o $row['options'];
                        echo 
'<div class="option">'.$o[$i].'</div>';
                    }
                }

                if (
strlen($row['amount'])>=1)
                {
                    echo 
'<div class="amount">'.number_format($row['amount']).'</div><br />';
                }
                elseif (
strlen($row['amount'])==0)
                {
                    echo 
'No one has voted yet!';
                }

                if (
$id)
                {
                    
$id $row['id'];
                }

            }
        }
    }
}



?>
</body>
</html>
Heres the sql:
sql Code:
CREATE TABLE `polls` (
   `id` int(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
   `title` varchar(20) NOT NULL,
   `options` varchar(2000) NOT NULL,
   `amount` varchar(36665) NOT NULL,
   )ENGINE=INNODB

None of it outputs anything. -_- I suck at making MySQL Applications. BAH!
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 02-03-2008, 11:06 AM   #2 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Orc.. it's fine that you're looking for support for your codes, but you don't have to PM me everytime you create a new thread.. I'm sure people will find their way to the thread anyways
Tanax is offline  
Reply With Quote
Old 02-03-2008, 12:10 PM   #3 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by Tanax View Post
Orc.. it's fine that you're looking for support for your codes, but you don't have to PM me everytime you create a new thread.. I'm sure people will find their way to the thread anyways
You really gave me hope when looking. v_v
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 02-03-2008, 01:00 PM   #4 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default

sql Code:
CREATE TABLE `polls` (
   `id` int(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
   `title` varchar(20) NOT NULL,
   `options` varchar(2000) NOT NULL,
   `amount` varchar(36665) NOT NULL,
   )ENGINE=INNODB

First off, this is honestly no way to make a poll. Your title should be varchar(255), options should be a longtext and as for amount, I seriously don't know what you want with this one.

Do not be scared of making more tables. A poll can easily take up 2 or more database tables. First the cats, then the poll itself, the options and the votes and so on. Maybe even a configurationtable for the options.

I would first have to know what is in your database and how it is composed. I do not think this is the right approach. You keep checking if there is data but the poll can't exist without data, so the checks are useless. Make sure you do not use the $_GET['id']. Or only when it's directly linked to. That'll be OK.

I think your first step it to take it from the ground up again and make sure every time you echo something making sure the script is working.
Quote:
Originally Posted by Tanax View Post
Orc.. it's fine that you're looking for support for your codes, but you don't have to PM me everytime you create a new thread.. I'm sure people will find their way to the thread anyways
When you make a post like that, you could've easily helped him out.
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
The Following User Says Thank You to ReSpawN For This Useful Post:
Orc (02-03-2008)
Old 02-03-2008, 01:04 PM   #5 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by ReSpawN View Post
sql Code:
CREATE TABLE `polls` (
   `id` int(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
   `title` varchar(20) NOT NULL,
   `options` varchar(2000) NOT NULL,
   `amount` varchar(36665) NOT NULL,
   )ENGINE=INNODB

First off, this is honestly no way to make a poll. Your title should be varchar(255), options should be a longtext and as for amount, I seriously don't know what you want with this one.

Do not be scared of making more tables. A poll can easily take up 2 or more database tables. First the cats, then the poll itself, the options and the votes and so on. Maybe even a configurationtable for the options.

I would first have to know what is in your database and how it is composed. I do not think this is the right approach. You keep checking if there is data but the poll can't exist without data, so the checks are useless. Make sure you do not use the $_GET['id']. Or only when it's directly linked to. That'll be OK.

I think your first step it to take it from the ground up again and make sure every time you echo something making sure the script is working.

When you make a post like that, you could've easily helped him out.
Thanks a lot! :D I will remake it.. :] And remember what you said. I'm just a newbie at MySQL, when I'm making these applications, it really just messed with me and my code. You know. :D
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 02-03-2008, 03:42 PM   #6 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Quote:
Originally Posted by ReSpawN View Post
When you make a post like that, you could've easily helped him out.
No, because firstly, I've never made a poll before so I have no clue.

And secondly, I think it's the wrong way to go to PM everyone on the forum to get attention to their thread. It's a forum, so everyone will read it eventually anyways!

Lastly, I was really in a hurry to my tap lesson, so even if I could help him, I didn't have the time!

Tanax is offline  
Reply With Quote
Old 02-03-2008, 03:58 PM   #7 (permalink)
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

I've built a poll system some time ago. Perhaps it could help you in some way... I've attached it if you need to document.
Attached Files
File Type: zip poll.zip (8.2 KB, 9 views)
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
The Following User Says Thank You to xenon For This Useful Post:
Orc (02-03-2008)
Old 02-03-2008, 05:40 PM   #8 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default

Quote:
Originally Posted by Tanax View Post
No, because firstly, I've never made a poll before so I have no clue.

And secondly, I think it's the wrong way to go to PM everyone on the forum to get attention to their thread. It's a forum, so everyone will read it eventually anyways!

Lastly, I was really in a hurry to my tap lesson, so even if I could help him, I didn't have the time!

I meant no harm! Tap on mate.

Orc, if it doesn't work out and IF you have MSN, you can add or email me on markernstproductions@gmaill.com or info@markernst.com.

Hopefully you'll work it out on your own, since that provides the best insight and experience. Feel free to contact me non the less.
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Old 02-03-2008, 07:03 PM   #9 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by ReSpawN View Post
I meant no harm! Tap on mate.

Orc, if it doesn't work out and IF you have MSN, you can add or email me on markernstproductions@gmaill.com or info@markernst.com.

Hopefully you'll work it out on your own, since that provides the best insight and experience. Feel free to contact me non the less.
I probably will figure it out on my own, when I'm faced with a challenge ( speciously in programming ), I work hard and try so many ways to beat it, if all else fails, and my mind goes blank, I ask for support. So far it happened in this thread considering, I didn't know what the crap was going on. :P
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 02-03-2008, 07:49 PM   #10 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default

That's the spirit! Hopefully you'll post the result? If you're still kinda new to the mySQL scene, you could try expanding the poll script to learn new techniques.
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Old 02-03-2008, 08:02 PM   #11 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by ReSpawN View Post
That's the spirit! Hopefully you'll post the result? If you're still kinda new to the mySQL scene, you could try expanding the poll script to learn new techniques.
Well I've been looking at the MySQL reference manuel non stop. :P
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 02-04-2008, 03:48 PM   #12 (permalink)
The Acquainted
 
Gareth's Avatar
 
Join Date: Jan 2008
Posts: 136
Thanks: 4
Gareth is on a distinguished road
Default

I would try to expand this script by including an admin panel: allows you to use DELETE * FROM etc :)
Gareth is offline  
Reply With Quote
Old 02-04-2008, 04:38 PM   #13 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default

Quote:
Originally Posted by Gareth View Post
I would try to expand this script by including an admin panel: allows you to use DELETE * FROM etc :)
A shorter version of what I already was suggesting mate.
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Old 02-04-2008, 04:47 PM   #14 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Not yet please, allow me to make what I need first.
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 02-04-2008, 05:56 PM   #15 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Just a note on varchar, the max length if 255 so don't put any values above it. For larger text, use the text type.
__________________

Village Idiot is offline  
Reply With Quote
The Following User Says Thank You to Village Idiot For This Useful Post:
Orc (02-04-2008)
Old 02-04-2008, 06:31 PM   #16 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by Village Idiot View Post
Just a note on varchar, the max length if 255 so don't put any values above it. For larger text, use the text type.
don't you mean longtext?
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 02-04-2008, 07:15 PM   #17 (permalink)
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

No, he meant text. Check out the differences between MySQL data types here:

MySQL Field Types
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
Old 02-05-2008, 06:59 AM   #18 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by Village Idiot View Post
Just a note on varchar, the max length if 255 so don't put any values above it. For larger text, use the text type.
Quote:
Originally Posted by xenon View Post
No, he meant text. Check out the differences between MySQL data types here:

MySQL Field Types

And LongText is suppose to be longer some how than Text :P
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 03:44 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design