« first day (1772 days earlier)      last day (3186 days later) » 

10:00 AM
and how my english (`
;
 
you english is terrible .. I would recommend audiobooks, they are really good for improving the "feel" for the language
 
@tereško He English is terrible?
6
;)
BTW, pay attention to the line number indicated in the error message, just FYI. That error wasn't saying the first mysql_fetch_array failed FWIW.
 
@UnderPhp since you are 13, I would recommend audiobookbay.co/audio-books/…
 
Abe
@JoeWatkins is there a way to define the booly value of an object by using the extension api? something like python's __nonzero__()?
 
update: I find the error.
the error was variable
 
10:05 AM
*found
 
@UnderPhp Good job. Now let's see if you can also figure out your second error :)
 
ok thanks (:
 
See... paying attention to error messages is very useful in debugging.
 
include "web/config.php";
// $top_users_c = "SELECT * FROM `voteslist` ORDER BY `voteslist`.`VoteID` DESC LIMIT 0,15;";
$top_users_q = mysql_query("SELECT * FROM `voteslist` ORDER BY `voteslist`.`VoteID` DESC LIMIT 0,15;");
$number = 1;
while($top_user = mysql_fetch_array($top_users_q) && $number<=15) {
$top_user_id = $top_user["ID"];
$top_user_voteid = $top_user["VoteID"];
$top_users_votes_sql = "SELECT COUNT (`VoteID`) FROM `voteslist` WHERE `VoteID` = '".$top_user_voteid."';";
$top_users_votes = mysql_query($top_users_votes_sql);
Error message:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in x/x/x/xvote.php on line 166
line 166 = $top_users_votes
 
@UnderPhp Please don't paste more than 3 lines of code in here. It clutters up the chat rather quickly. Especially when you're doing it every time you change a line of code. Instead use a pastebin or codepad like pastebin.com or codepad.org to paste your code and just provide the link here.
 
10:08 AM
If I have a request to correct a mistake in English
oh ok.. eait
wait
 
$top_users_q = mysql_query("SELECT * FROM `voteslist` ORDER BY `voteslist`.`VoteID` DESC LIMIT 0,15;");
$top_users_votes_sql = "SELECT COUNT (`VoteID`) FROM `voteslist` WHERE `VoteID` = '".$top_user_voteid."';"
why do you have these two lines?
 
Dude, stop quoting column names with backticks.
And while you're at it stop using mysql_*
You've already developed two very poor habits.
 
26 secs ago, by Sherif
Dude, stop quoting column names with backticks.
yeah ... this is really fucking annoying
 
@UnderPhp What do you think the value of $top_user will be in the statement $top_user = mysql_fetch_array($top_users_q) && $number<=15 ?
I'm willing to bet you that it will not be an array for sure ;)
 
10:12 AM
backticks is ` ?
 
@UnderPhp yes. Those are used in SQL to escape keywords.
 
for example, if you have column named "select", you would have to escape it, or SQL will think that it is a keyword
like this: SELECT userID, name, `select` FROM SomeTable
 
@Sherif good moaning
 
Oh, ok.. so remove the `?
 
10:14 AM
@Ja͢ck What's up @Ja͢ck! :)
 
hey, nothing much .. enjoying my sunday evening heh
 
I'll concede to moaning. Not sure about the good.
 
@UnderPhp look at the example I gave above. Use ` only when you need to.
 
@tereško Which should actually be never.
 
i wanted to ask you ... what did the m$ guy give as a solution to the rand7 problem? :)
 
10:15 AM
ok (:
 
@Sherif I tend to have a column called "order" .. it's a thing
 
Not a smart idea to name your columns/tables after reserved words.
Any any language, really.
@tereško Do you index that column?
 
sometimes, depends on the project
 
just prefix all your columns with _ ... done
 
hell no
 
10:16 AM
haha
 
@tereško Because in the cases that you're reusing that index you would mostly likely never name it order ;)
 
How can i merge the $top_users_votes_sql with $top_users_q ?
 
i jest of course
ORDER BY `order`
that totally makes sense ;-)
 
If I have a mistake in language please correct me
 
Think of it like this. Naming a column in your user table as id is a bad idea if you plan to use the id index in JOINs, because you should name it something like user_id so that you can do stuff like SELECT ... FROM user_profile JOIN user_profile ON user_id = user_profile.user_id
 
10:19 AM
@UnderPhp is VoteID a unique column?
 
Verbosity++
 
yes @tereško
 
@Sherif USING (user_id) no?
 
@UnderPhp then this will always return 1
 
@Ja͢ck Yup :)
 
10:20 AM
$top_users_votes_sql = "SELECT COUNT (`VoteID`) FROM `voteslist` WHERE `VoteID` = '".$top_user_voteid."';"
 
Which again, is rare that you would ever fall into the trap of having to name a column after a reserved word.
 
if VoteID is unique in that table, then it can only be once
thus: result is always 1
 
or 0
 
ok.. and what with my problem? Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /xxx/x/xxx/x/x/vote.php on line 166
 
That's almost never necessary. In any other language you would avoid reserved words like the plague. Why get into the habit of doing it regularly in SQL?
 
10:22 AM
@UnderPhp did you already try putting var_dump(mysql_error()) in the line above?
 
did you make sure that $top_users_vote is actually a "resource"?
 
His code is in a loop... and he hasn't shown us the rest of the loop body ;)
 
the problem is that php doesn't issue a fatal error: "mysql_fetch_array(): function not found"
 
hint hint
@Ja͢ck Who said it was fatal?
 
10:24 AM
 
I just did
 
@Sherif Except PHP now. ;-)
 
@Ja͢ck Why would you say that though? He didn't suggest it was fatal, did he?
 
@UnderPhp looks like your database is fucked
did you use MyISAM or InnoDB?
 
maybe because is in while?
 
10:24 AM
@kelunik What?
 
@Sherif it was a joke ... -_-
 
MySQL
 
@Ja͢ck OK, didn't get the context I guess.
 
@Sherif Context sensitive lexer RFC? ;-)
 
@UnderPhp mysql uses multiple storage engines\. InnoDB an MyISAM are the two most popular ones.
 
10:26 AM
hmm, does mysql have geospatial types?
 
@kelunik Is there an RFC for that? Sounds horrible.
 
I dont know
@ter
@tereško
 
then check
if you don't know how: try googling
 
oh, i remember that RFC; sounds good in theory, but there was quite some resistance to it
 
I think that i have mysql
 
10:27 AM
if you fail to find a way after few minutes of trying to google: ask here
 
i am use in free web hosting
 
mysql is the "relational database management system", not a storage engine
 
@kelunik Actually, I take that back. Variable naming is non problematic in the context of reserved words in PHP by default, but that's because we prefix variable names with a sigil intentionally. Once you get into function naming the waters get muddy so it could be horrible it could not.
 
mysql uses various storage engines
you need to check which one did you use for your votelist table
you should be able to see it in phpmyadmin (which I assume you are using)
 
@Sherif it was specifically about being able to use reserved words for classes and functions
like, ehh, class List
 
10:29 AM
@Ja͢ck Yea, see that's where things could get tricky. It depends on what your intention is.
 
@Ja͢ck stick with postgre :)
 
haha yeah, i'm using PostGIS now
 
aha
 
MyISAM
@tereško
 
@tereško do you have any practical knowledge with polygons, etc.?
in the context of db
 
10:31 AM
PHP's parser never really did a good job at distinguishing keywords from bare words. To PHP it's all just bare words and the scramble to lex them is just idiotic.
 
@UnderPhp that's probably why table imploded. MyISAM is a bit faster engine, but it is shit for stability. Try remaking your votelist table as InnoDB
that should solve your error
 
@tereško I think you're over-thinking his problem just a tad :)
 
i'm working on this project for my new company and the whole thing has no foreign key constraints =.=
it's just so scary
 
@Sherif this was his error: pastebin.com/h8Gr6YqJ
 
free hosting is as good as what you pay for it
 
10:33 AM
@tereško Well, that's not an error, but again you are over-thinking it. Pay attention to the loop condition. What happens if there are no more rows left and $number is still <= 15 ?
hint hint
 
@Sherif the numbers don't match
 
@tereško i.e. the condition is still true
Right?
i.e. the loop continues
 
there is && not ||
 
Right, but the first condition is always going to be true.
 
this loop $number => 15
 
10:35 AM
Look at his first SQL query.
 
Court repeats itself 15 times
 
that $number => 15 part doesnt even matter, since he is only selecting 15 rows
 
@UnderPhp Pastebin the code for your entire loop. I'll show you where you're slipping.
 
it's an artifact from before he added LIMIT
 
@Sherif ok..
 
10:37 AM
 
@UnderPhp That's definitely not the entire loop since you're missing a closing bracket there.
oh wait you just added the bracket
So there was nothing else inside the loop body?
 
for what you mean? @Sherif
what did you mean*
 
Never mind.
 
so found the error?
 
10:41 AM
@UnderPhp Place var_dump( $top_user ) inside your loop.
Notice that it's not what you expect.
 
bool(true)
 
Exactly.
Look at the very next line where you use it.
$top_user_id = $top_user["ID"];
You were expecting an array.
:)
What you meant to say was while(($top_user = mysql_fetch_array($top_users_q)) && $number<= 15) {
Which is very different.
See operator precedence as per above.
 
i need change the: mysql_fetch_array to: mysql_fetch_assoc ?
 
That was your second error.
@UnderPhp What? Who said that?
 
am..
I dont know where the problem in my code
 
10:45 AM
o.0
 
sorry for my english ..
 
Well, I was pointing out one of your problems.
Seems to me you're not actually interested though.
 
$top_user_id one of my problem?
 
@Ja͢ck Not really, it was not about functions. And class names have been removed due to those tricky concerns as well IIRC.
 
@UnderPhp Go back and read what I actually said carefully and don't ask me anymore questions until you have. I gave you both the problem and the solution.
Until you've fixed it and reran your code you can't really say that you're making any progress towards your problem.
So it's pointless to bother asking more questions at this point because it's just a perpetual bombardment of questioning.
 
10:49 AM
but try understand me.. i tried translate you and i can't so please asnwer me.
What i need do with $top_user_id?
 
@kelunik Yea PHP is a problem in that area.
@UnderPhp Did you require translation for my PHP code as well? Because that's pretty language agnostic there.
The worst you could have possibly done was just copy and paste the code and try it.
 
I am just 13 years old, and I am dont from usa..
 
@UnderPhp Your while loop should read while(($top_user = mysql_fetch_array($top_users_q)) && $number<= 15) { not while($top_user = mysql_fetch_array($top_users_q) && $number<=15) { is that clear enough for you?
 
@kelunik damn now you're making me read it again lol
yeah okay, i forgot constants
 
This same code exactly
@Sherif
 
10:53 AM
yes
wow, I just realized my 1 TB upload to S3 is finally done.
 
@sherif
so what i need change in my code?
 
You've got to be kidding me.
 
sorry about harassment
 
@UnderPhp I just told you what to change.
What are you not understanding?
 
@UnderPhp look at these two examples: 3 * 4 + 2 and 3 * (4 + 2)
athey the same?
4 mins ago, by Sherif
@UnderPhp Your while loop should read while(($top_user = mysql_fetch_array($top_users_q)) && $number<= 15) { not while($top_user = mysql_fetch_array($top_users_q) && $number<=15) { is that clear enough for you?
programming language have operator precedence
you need to learn how it works in php: php.net/language.operators.precedence
 
10:57 AM
@tereško its not same..
3*4+2 = 14
and 3*4+3*2 = 18 (:
 
now looks at what @Sherif wrote
notice the parentheses
 
oh! I did not notice the parentheses
but the error stay
 
codepad.org/inKQaALq .. this is what @Sherif was talking about
@Sherif are you still sure that I was over-thingng it?
 
hi all
got a design problem here that I could do with some ideas for if thats cool please? :) stackoverflow.com/questions/32164846/…
 
@UnderPhp now, could you please rebuild the table using InnoDB?
 
11:03 AM
@tereško thanks but i have error:
http://codepad.org/5E424veD
 
@tereško Yup
 
@UnderPhp you still have not changed the code as you were told to
 
Without ` ?
 
@UnderPhp Very good, now on to your next problem. Your schema defines VoteID, not ID :)
hint you're saying $top_user_id = $top_user["ID"]; when you should be saying $top_user_id = $top_user["VoteID"];
 
^ you are guessing, don't forget where he learned sql
 
11:06 AM
There's no guesswork here.
 
where did you get his DB schema from?
 
Oh wait, he's got both ID and VoteID.
Never mind.
 
... probably
 
I suspect ID should have been UserID? I don't see a JOIN anywhere. Time to var_dump($top_user)
 
think: w3cshools
 
11:09 AM
@PhilHudson What is the form for?
 
basically the form submits and processes the data into a json object of ids that the php will need to request
 
@PhilHudson That's great. So what is the form used for?
 
however getting the json into PHP is proving the hard bit (i'm used to working with restful apis and not this wordpress stuff)
basically submitting data to the process function
 
@PhilHudson That's its function. That's not what it's for.
 
it is for inputting user data
 
11:11 AM
From an end-user perspective, why are they submitting that form?
 
..
to get the relevant products returned
 
@PhilHudson Relevant to what? It's a search form? A shopping cart? A checkout form?
 
DONT WORK :[[
 
it's their requirements e.g. i have a house and i need X
so if my requirements are X you will get the relevant products for that
 
So it's a search form?
 
11:12 AM
kind of
 
So these products you're storing locally on the client, what is their relevance to this search?
 
but its more constrained and more complex
it's basically for deisgning a system of product that is derived from the users needs. e.g. from the form data
 
Alright, let's take a beat and be clear about your question here. You stated this was a design problem. Is your question about how you should design something or how you can accomplish some goal you already have in mind and just need some technical know-how for?
Because I sense that we're getting nowhere really really fast.
 
it's a design problem in terms of how to use the data (into PHP) to get the relevant products back
 
@PhilHudson OK, what does this data look like that's in local storage?
 
11:16 AM
array of json objects
[{12,1},{333,4}]
 
I meant, can you provide an actual example?
 
first number in object is id, second is quantity
that is the array
 
@UnderPhp what "doesn't work"?
 
@PhilHudson Yea, see, that's not valid JSON.
So that's completely useless as an example.
 
you still haven't shown us code that you changed in past hour .. or two
 
11:17 AM
It tells me nothing of your data structure.
 
[{id :12, quantity: 1},{id :333,quantity:4}]
 
@PhilHudson OK, so what is the thing that you're struggling with here? This all seems rudimentary so far.
i.e. your problemset has no definition.
 
using that JSON in PHP to get only those products
 
Only?
 
yes
 
11:20 AM
What is meant by only these products. What other products are there?
 
...
i mean the product ids in the array
 
@PhilHudson OK, so why not just send the entire array back to PHP? The only thing in your object is an id and quantity. What's the problem with that?
 
best way to do that via AJAX? then have a handler return the products?
 
@PhilHudson Why AJAX? You said you were submitting a form.
That doesn't necessarily require AJAX.
 
well the only other way i see it is attached the object to a hidden field in the form before it sends
 
11:26 AM
Why hidden?
It doesn't have to be hidden at all. In javascript you can override events or bind to them. Meaning you can either intercept the onSubmit handler or bind to it and add data to the form there before it is sent.
 
ah yeah nice idea
 
Rule of thumb is that you want your javascript to degrade gracefully.
Which means that using preventDefault() is actually vital :)
 
awesome thanks!
 
@tereško @Sherif some one can help me?
 
show us the updated code
 
what does $top_user_voteid contain?
did you try running that query directly in phpmyadmin?
what does $top_users_votes_code contain?
 
`$top_user_voteid` is the IDNumber of vote.
`$top_user_id` is serial number of vote.
`$top_users_votes_code` count all votes where VoteID = $top_user_voteid.
@tereško
 
that was not what I asked
 
So what did you mean?
 
what is the exact value in $top_user_voteid?
what is the exact value in $top_users_votes_code?
what happens when you run that query in phpmyadmin?
 
11:48 AM
I will try run it in phpmyadmin
 
when you see
> Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in ....
it means that the value, which you were passing in mysql_fetch_array(), is fucked up
the goal of debugging is to find:
 
@tereško look this.. if my query is this:
SELECT COUNT( VoteID )
FROM voteslist
WHERE VoteID = '6';
phpmyadmin give me this error:
 
1. what is that fucked up value
2. how did it get that way
 
#1547 - Column count of mysql.proc is wrong. Expected 20, found 16. The table is probably corrupted
 
cc @Sherif
 
11:50 AM
but if my query is:

@tereško look this.. if my query is this:
SELECT COUNT( VoteID )
FROM voteslist
WHERE VoteID = '6';
(with `)

its will work
what is cc?
*CODE:
SELECT COUNT( VoteID )
FROM voteslist
WHERE `VoteID` = '6';
 
it's an acronym which stands for "carbon copy" (nowadays used, when you need to send email to multiple people)
@UnderPhp does that query work in phpmyadmin?
 
@UnderPhp You upgraded MySQL after you created that database, didn't you?
 
@Sherif he's using free shared hosting
 
Wow, his situation just keeps getting worse and worse
 
the table was made using MyISAM .. it imploded
 
11:53 AM
@tereško The query work in phpmyadmin only with " ` "
 
huh ?!
 
Dude, vagrantup
Why the hell are you using free shared hosting?
 
what mysql version are you running there?
 
That's worse than using w3schools to learn.
Even worse than using mysql_*
There's just so much wrong with what you're doing it's not even conducive to learning anymore.
All you're learning is everything you should not do in the real world.
 
oh the error is no the ` is the space between the "COUNT" to "()"
 

« first day (1772 days earlier)      last day (3186 days later) »