View Full Version : downloaded php/mysql/flash poll. "supplied argument" errors
WorldBuilder
January 23rd, 2004, 12:11 PM
Hi all,
I downloaded a premade script written in php. Here's where I got it from:
http://www.sephiroth.it/file_detail.php?id=51
First, I had some trouble with the Flash, but airnine was kind enough to try to help me out here (http://www.webmasterlingo.com/showthread.php?s=&threadid=155). I got that worked out, but the php/mysql is having issues now.
It seems that a lot of people are having trouble with this script, and so am I. I tried e-mailing the author of the script, but I don't think he's going to help out. :P I thought I'd ask for help here.
Ok, first of all, I know very little about php/mysql. I've created a FEW databases and tables and done minimal php coding, but please consider me a dolt when it comes to these things.
When I go to the admin.php file in a browser to set up the poll, I input the options I want, click to submit, and I get the following message:
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/www/poll/admin.php on line 42
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/www/poll/admin.php on line 43
Apparently, this script is SUPPOSED to create all the tables, etc automatically, but that is obviously not happening. I've attached a zip file with all the necessary files that came with the original script (plus the swf file I had to make). Could someone please take a look and help me figure out what's wrong and how to fix it? Thanks!
Chris
ZYV
January 23rd, 2004, 12:23 PM
Try to add this
$conn = @mysql_pconnect($host, $db_user, $db_pass);
@mysql_select_db($db, $conn);
before
/*****************************************/
in config.inc.php
That should work imo...
ZYV
January 23rd, 2004, 12:25 PM
P.S. and don't forget to set up user/pass etc. as well. And yes, it looks like the script creates everything he needs itself.
WorldBuilder
January 23rd, 2004, 12:37 PM
Thanks for the reply, mon ami.
Ok, I added the code you suggested. Now, when I go to the admin.php page to set up the poll it no longer gives me those errors, but a blank screen instead. That's progress at least!
I looked in my phpmyadmin page and there has been no database creation. How can I set up a password and username for a database that doesn't exist? What steps do I need to take here. Remember, I'm a php/mysql n00b. :D
Thanks!
Chris
ZYV
January 23rd, 2004, 12:55 PM
WorldBuilder
De rien...
Hey, you must create a database for the script! It will create the tables itself, but not the DB. DB's name should be filled in $db = "dbname" ..
WorldBuilder
January 23rd, 2004, 01:27 PM
Ok, I did create the database with no tables. Ran the admin.php file, same trouble. Just a blank screen. I guess I have to set up the UN and password in phpmyadmin. Where do I go to do that? I click "privileges" and the db I created (called "flashpoll") is not listed. Is this because it has no tables?
In the database list, though, "flashpoll" is listed. How do I set up the UN and password for this new database? Thanks!
Chris
WorldBuilder
January 23rd, 2004, 01:56 PM
Ok,
My config.inc.php file has been altered to this:
<?
$conn = @mysql_pconnect($host, $db_user, $db_pass);
@mysql_select_db($db, $conn);
/******************************************
* MYSQL_PHP_FLASH POLL
* V.1
* Sephiroth - Alessandro Crugnola
* alessandro@sephiroth.it
* http://www.sephiroth.it
******************************************/
/*** mysql connection information ****/
/*****************************************/
$db = "flashpoll";
$host = "localhost";
$db_user = "chris";
$db_pass = "xxxxxx";
$table = "poll";
$tempo = 640000;
$pass = "sam76937"; // password used in admin interface
$pollName = "poll"; // poll title
/*****************************************/
?>
In phpmyadmin, I created a new user called "chris" with the proper password (thus reflecting the changes to these variables above). Still getting a blank screen in the poll admin page after submitting the poll info I desire. Ugh... Any thoughts?
Chris
ZYV
January 23rd, 2004, 02:23 PM
You should put
$conn = @mysql_pconnect($host, $db_user, $db_pass);
@mysql_select_db($db, $conn);
AT THE END of the script, where all the password/user/table/db stuff is set. Otherwise it just tries to connect with empty un/pwd.
WorldBuilder
January 23rd, 2004, 02:40 PM
That's been done. The db has been created as well as the UN and password in phpmyadmin. I've also been IMing Matt about it, and we're both stumped, man. Argh! LOL. Any other ideas?
Chris
WorldBuilder
January 23rd, 2004, 02:46 PM
Just to get the most updated files, here's a zip file with all the updates!
ZYV
January 23rd, 2004, 03:01 PM
Thus it should be a problem with your DB and not the script. I have just downloaded and unpacked it, created a database "poll" and set the ini file to the following:
<?
$db = "poll";
$host = "localhost";
$db_user = "root";
$db_pass = "";
$table = "poll";
$tempo = 640000;
$pass = ""; // password used in admin interface
$pollName = "poll"; // poll title
$conn = @mysql_pconnect($host, $db_user, $db_pass);
@mysql_select_db($db, $conn);
?>
I have a root access to my local server with no password and I don't want the admin password either.
Do you have JS enabled?
I have the following in my "mysql" database in table "user":
INSERT INTO `user` (`Host`, `User`, `Password`, `Select_priv`, `Insert_priv`, `Update_priv`, `Delete_priv`, `Create_priv`, `Drop_priv`, `Reload_priv`, `Shutdown_priv`, `Process_priv`, `File_priv`, `Grant_priv`, `References_priv`, `Index_priv`, `Alter_priv`) VALUES ('%', 'root', '', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y');
You might want to create a "god" user with similar priveleges for testing. I that'll work you have probs with mySQL permissions.
WorldBuilder
January 23rd, 2004, 03:16 PM
ZYV,
Thanks for all your suggestions. I have the same user info you do (except for the name and password), but it still isn't working. I'm not getting any errors, just a blank screen after I put info into the admin page of the poll setup. I don't see what I'm doing wrong in the db. If you use phpmyadmin, what are the exact steps I need to take to set it up properly. I MUST be doing something wrong, but darned if I know what it is. If it would be best, I can delete everything and start from scratch.
Chris
ZYV
January 23rd, 2004, 03:24 PM
WorldBuilder,
I do use phpMyAdmin. The only thing I did is to create the DB (there is an input box on the front page). Then I altered the config and that worked.
Another thing for you is to try to remove the " @" in the config. @'s suppress the error messages and they might be somehow usefull in your case...
WorldBuilder
January 23rd, 2004, 03:31 PM
Ok, I created a db named "flashpoll" with NO tables. Then, I created a user named "chris" with password equal to what is in the config.inc.php file. That user has Global privileges set to ALL PRIVILEGES. Grant is set to "yes", and Table-specific privileges is also set to "yes". That user is also bound to database "flashpoll".
All my php files are as you see them in the above zip file. Am I missing anything in my database setup?
Chris
PS. I take it that you have tried this yourself and gotten it to work?
PPS. Call me Chris :)
WorldBuilder
January 23rd, 2004, 03:36 PM
Ok, I just noticed something very weird. In phpmyadmin, when I use the drop down menu on the left to select "flashpoll", then I click "Browse", I DO see a table in there with domanda set to "Working?". Now, the last time I tested the admin page by putting info in there, the question I simply asked in the poll was, in fact, "Working?".
Now, if you go to www.bartlett-family.net/poll , you'll actually see that it DOES seem to be working (well, sorta). I think there's something wrong with the Flash. I'll keep you posted...
Chris
ZYV
January 23rd, 2004, 03:54 PM
Chris,
I looks like you aren't missing anything.
PS. I take it that you have tried this yourself and gotten it to work?
Right I did. I said that above.
I think there's something wrong with the Flash. I'll keep you posted...
And what did you expect it to do?
Do you have JavaScript enabled in your browser? It displays JS dialogs in admin. If it's disabled you'll just see a blank screen.
P.S. Call me Z :lol:
WorldBuilder
January 23rd, 2004, 04:06 PM
Sup Z,
And what did you expect it to do? Well, it looks like at the bottom where it says "votes tot", it's supposed to be "votes total:" Also, if you have already voted once and try again, it won't let you (because of the cookies), but in the top right corner of the poll, it says, "You have already voted", except that some of that is cut off, too.
Do you have JavaScript enabled in your browser? It displays JS dialogs in admin. If it's disabled you'll just see a blank screen. Well, after inputting data in the admin area, it DOES (and always has) popped up a JS button with something written in some other language (I think it's Spanish). Once you click ok to that, then it just goes to a blank screen for me. You?
Also, on mine, there aer no selections! For instance, right now at www.bartlett-family.net/poll there is a question, but no available answers! Gotta be a flash problem, I guess.
Chris
WorldBuilder
January 23rd, 2004, 04:12 PM
Oh... There is only ONE table in this database. A table called "Is this poll working, fellas?", which of course, is the poll question right now. Shouldn't there also be tables for the answers I put into the admin.php area? I input answers of Yes and No. Perhaps it's not a flash problem?
Chris
ZYV
January 24th, 2004, 07:34 AM
It looks like you are having now a register_globals = false problem.
Please search this forum for the r_g solution (you'll have to alter the config) and then you might want to try my SWF with correct positioning.
And yes, the script is in Italian. And the screen should be blank indeed after the submission.
I've looked through the script... er... why have you choosen it? Even the phpPolls and phpPictureVote are better than this.
WorldBuilder
January 24th, 2004, 09:09 AM
It looks like you are having now a register_globals = false problem.
Please search this forum for the r_g solution (you'll have to alter the config) and then you might want to try my SWF with correct positioning.
Ok, I'll search because I have no idea what register_globals are. I'll see what I can find out, Z. I did try your swf. Seems to work a little better. I made a new poll and attached a screenshot. Looks a little better, but there are supposed to be 2 answer options. As you'll see, there's only one radio button and no text at all. Flash problem or php problem, you think?
And yes, the script is in Italian. And the screen should be blank indeed after the submission. Ok ;)
I've looked through the script... er... why have you choosen it? Even the phpPolls and phpPictureVote are better than this. I actually talk to Matt about this, too. To tell you the truth, I already HAD a poll on my site written in CGI. It is ok, but I was looking for something a little more animated, and this seemed to fit the bill alright. I just wanted something animated, colorful (which even this one is not), and more fun. That's all.
If you want to see the old poll, it's here (http://www.bartlett-family.net/cgi-bin/poll.cgi). I'd be more than happy to look at any other polls you would suggest. As long as it's cute and colorful and animated, I'd be a happy guy. I've searched all over, and this was about the best I could find unfortunately.
Chris
WorldBuilder
January 24th, 2004, 09:09 AM
Forgot the screenshot! Here you go.
ZYV
January 24th, 2004, 12:07 PM
And yes, I understand whatd are you saying.
Ok, I'll search because I have no idea what register_globals are. <...> As you'll see, there's only one radio button and no text at all. Flash problem or php problem, you think?
Well, exactly, I have said above that in my opinion it is a PHP problem. And if I am right, the solution is to emulate r_g = on. R_g is a PHP setting which defines if the POST and GET variables are accessible from the script. There is no need to search, just look here: http://webmasterlingo.com/showthread.php?s=&threadid=30
In short you'll have to add
extract($_COOKIE); extract($_POST); extract($_GET); extract($_SERVER);
At the beginning of the config file. Just try that and I'm quite sure that'll work.
About other polls. Heh, they don't look better than yours, so no need to try then out if you have a perl one and need animation.
If you need animation, just download Flash MX and edit this fla file. It's quite simple to add background, fancy buttons et al... After several hours of work you will have an animated chef-d'oeuvre :)
WorldBuilder
January 24th, 2004, 07:26 PM
YES!!!!!!!!
Try it now, my friend!
My Poll (http://www.bartlett-family.net/poll)
You're the man, Z. I hear you live in Russia. Is that right? You certainly have an exceptional grasp of English (and French as well :D)
Thanks a million, hoss!
Chris
Interactive
January 25th, 2004, 12:10 AM
Originally posted by WorldBuilder
YES!!!!!!!!
Try it now, my friend!
My Poll (http://www.bartlett-family.net/poll)
You're the man, Z. I hear you live in Russia. Is that right? You certainly have an exceptional grasp of English (and French as well :D)
Thanks a million, hoss!
Chris
Wow that's pretty tricked, time to look at the code.
ZYV
January 25th, 2004, 07:54 AM
Try it now, my friend!
Yep, that seems to work in the right way now...
You're the man, Z. I hear you live in Russia. Is that right? You certainly have an exceptional grasp of English (and French as well :D)
Well, yes, I live in Russia, I'm quite sure that's written in my profile. But according to my teacher my English is à souhaiter mieux :)
WorldBuilder
January 31st, 2004, 02:42 PM
Hey Z,
I seem to have another problem with this same poll script now. Obviously, this script uses cookies to prevent people from voting more than once. The trouble is that I just created a NEW poll and submitted it, but when I try to vote myself, it tells me that I already voted (presumably from the last poll). Any ideas why? I've been looking through the php code and am at a loss so far.
Thanks!
Chris
ZYV
February 3rd, 2004, 11:09 AM
Hello,
It looks like that you have to change
$pollName = "poll_3"; // poll title
in config.inc.php to something else every time you make a new poll to change the cookie name.
WorldBuilder
February 3rd, 2004, 06:11 PM
Yeah, I was wondering about that. I read something like that from the place I downloaded the script from in the first place, but I couldn't find it again.
Thanks, that's what I was looking for. Annoying, but tolerable. :D
Chris
ZYV
February 4th, 2004, 07:39 AM
Heh, I've said that it's not an advanced system =)
vBulletin v3.0.5, Copyright ©2000-2009, Jelsoft Enterprises Ltd.