Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Images

Errors with my poll script (bar chart images)

images php coding issues or problems here.

Moderators: macek, egami, gesf

Errors with my poll script (bar chart images)

Postby crazyfox » Sun Jun 13, 2004 1:10 am

First the platform:
--------------------
Windows XP Professional
PHP 4.3.7
Apache 2.0.49
MySQLadmin 1.4 - (run as a service)

Objective:
-----------
To create a poll with three radio buttons 1....2....3
As the users vote 1, 2 or 3 the results are displayed by percentages along with a representation of their respective bar charts.

Problem:
----------
I keep getting this in my browser and cannot figure out why.
[quote]Warning: mysql_data_seek(): Offset 0 is invalid for MySQL result index 3 (or the query data is unbuffered) in C:\etc... etc...\etc...\mypoll.php on line 43

Warning: Cannot modify header information - headers already sent by (output started at C:\etc..\etc..\etc..\mypoll.php:43) in C:\etc...\etc...\etc...\mypoll.php on line 153
‰PNG  IHDRô2X>4¤!PLTEÿÿÿ@€ÿNó___ßßß???ŸŸŸ¿¿¿åÜPIDATxœíšA‹£0Çÿ”¶Ö~Š!ÄÖöS„°³eoE†]ö&sØaoR:8s+Þö&=íQzÙ¯¹O«`Ñ‹RßÈ$ÿB!Ï<óÿó’ƒÆ 0T‹n ,º‰²è&Ê¢›(‹n¢,º‰²è&Ê¢›(ô‰â1,’~eL~oé« ï¨‰}ÇɪlTè{’a³¯Z08*FbAW€ã•
User avatar
crazyfox
New php-forum User
New php-forum User
 
Posts: 19
Joined: Wed Jun 02, 2004 7:59 am

Postby ruturajv » Sun Jun 13, 2004 7:52 pm

the problem is not an image problem,
see your first err. ITs an Mysql err.
post that part of your code, ! :D
User avatar
ruturajv
php-forum Super User
php-forum Super User
 
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India

Postby crazyfox » Mon Jun 14, 2004 12:27 am

OK here's the code fragments you asked for. First the error:
Warning: mysql_data_seek(): Offset 0 is invalid for MySQL result index 3 (or the query data is unbuffered) in C:\etc... etc...\etc...\mypoll.php on line 43

The fragment code for your reference:
if (!$conn = @mysql_connect("localhost", "username", "password"))
{
echo "Could not connect to db<br>";
exit;
};
@mysql_select_db("database", $conn);

if (!empty($radio_button)) // if they filled the form out, add their vote
{
$radio_button = addslashes($radio_button);
$query = "update table
set num_votes = num_votes + 1
where voters = '$radio_button'";
if(!($result = @mysql_query($query, $conn)))
{
echo "Could not update the table<br>";
exit;
}
};

It continues...the real problem start with the code fragment below:
/ get current results of poll, regardless of whether they voted
$query = "select * from table";
if(!($result = @ mysql_query($query, $conn)))
{
echo "Could not fetch results from table<br>";
exit;
}
$num_candidates = mysql_num_rows($result);

// calculate total number of votes so far
$total_polls=0;
while ($row = mysql_fetch_object ($result))
{
$total_polls += $row->num_votes;
}
mysql_data_seek($result, 0); // reset result pointer


The very last line is line 43, the line where PHP begins to complaining:
mysql_data_seek($result, 0); // reset result pointer


What do you make of it?
User avatar
crazyfox
New php-forum User
New php-forum User
 
Posts: 19
Joined: Wed Jun 02, 2004 7:59 am

Postby crazyfox » Mon Jun 14, 2004 1:14 pm

Hmmm

Now the browser screen is coming up blank ????

Searched my system for PHP or MySQL error files and found none ???

The PHP info() function works fine...dispalying the zend image and all. GD2 etc. are enable Globals on etc. etc.

[/quote]
User avatar
crazyfox
New php-forum User
New php-forum User
 
Posts: 19
Joined: Wed Jun 02, 2004 7:59 am

Postby ruturajv » Mon Jun 14, 2004 8:11 pm

your mysql data seek arguments are wrong, you seem to access an index which is not present.

try avoiding mysql_fetch_object and basic for, while loops, see if that solves the problem..

anyways., the index that you seem to access is a wrong one
User avatar
ruturajv
php-forum Super User
php-forum Super User
 
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India

Postby WiZARD » Mon Jun 14, 2004 11:09 pm

crazyfox how view youre DB, To me interesting how you create a DB?
User avatar
WiZARD
Moderator
Moderator
 
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol

Postby crazyfox » Wed Jun 16, 2004 1:37 am

Guys

Please be patient with me.... I have just bought myself a laptop and just finished doing all the windows updates etc.

I have decided to download all the "latest" stable releases on my laptop including PHP5. I am in the middle of the ordeal at the moment, u know installing and configuring so give a minute to reply back to u thanks.

For being such helpful mates here's two of my favourit website for those who don't know of them.


I recommend the following to get from the link below:
1. Spybot - Search and Destroy
2. Spyware Blaster
3. Sygate Firewall
The link : http://www.spychecker.com


For the other link below do the following:
1. http://www.overnet.com
2. Click on the download image or icon
3. Scroll down pass the "buy pro" prices.
4 You'll then see OVERNET BASIC
5 Choose ur platform and download

Enjoy 8)
User avatar
crazyfox
New php-forum User
New php-forum User
 
Posts: 19
Joined: Wed Jun 02, 2004 7:59 am

Postby crazyfox » Thu Jun 17, 2004 12:53 pm

Well here we go...

The database in question.....point raised by wizard was created manually at the command prompt. Create table etc. etc.
I confess in the late hours my brain was on go-slow and I forgot to insert the initial values into the table to match the form input values
... well spotted wizard thanks. BUT.....then when I inserted the initial values to correspond with the values on the form itself, hence 1, 2 and 3 input values on the form correspond "exactly" to the values in the table. I still got a blank page....??

Hence the point mentioned by ruturajv, made perfect sense also since I was trying to access data that didn't exist! On my PC where I STILL have this problem of blank page in the broweser; I have suspected it to be something I did from an earlier format I mentioned when I first installed xp professional over windows 98se.

I formatted my hdd to start with a clean installation and when I rebooted with the xp disc I formatted the hdd as FAT32 istead of NTFS or something along that line....anyway, I then read that Apache may cause problems on FAT32 formatted drives running "xp", as oppose to 98x and instead xp should be formatted or converted to NTFS in order to work favourably...????

I will convert my hard drive to the NTFS option and see what happens, sounds the better choice between FAT32 and plain FAT anyway.

next post to follow raises issues about installing PHP5 and Apache 1.3 on my Laptop.....
What have I done in this world to desrve this stress....
User avatar
crazyfox
New php-forum User
New php-forum User
 
Posts: 19
Joined: Wed Jun 02, 2004 7:59 am

Postby crazyfox » Fri Jun 18, 2004 7:38 am

Well I m breathing a sigh of relief

I have gotten PHP up and running on both machines and I have also solved the problems I had eariler. My image poll script is working lovely now.

8)
User avatar
crazyfox
New php-forum User
New php-forum User
 
Posts: 19
Joined: Wed Jun 02, 2004 7:59 am

Postby WiZARD » Sat Jun 19, 2004 3:01 am

... I then read that Apache may cause problems on FAT32 formatted drives running "xp", as oppose to 98x and instead xp should be formatted or converted to NTFS ...

Where you read this?
User avatar
WiZARD
Moderator
Moderator
 
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol

Postby crazyfox » Wed Jun 30, 2004 1:53 am

To be honest I can't remember exactly. It was quite awhile ago. It may not to do with PHP itself , maybe to do with Apache or MYSQL?

Try this link it may have been here: http://apache.mirror.positive-internet. ... in32/#pbug If it is not then If I come across it again I'll post it here for u 8)
User avatar
crazyfox
New php-forum User
New php-forum User
 
Posts: 19
Joined: Wed Jun 02, 2004 7:59 am


Return to PHP coding => Images

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron