Jump to content

help with php/mysql inserting with binds


afallingpanda

Recommended Posts

hello guys, so i have an interface that inserts data into a mysql database with PDO.

 

so i am binding params, however not everything in my query is binded, as some of them are just ints which i entered my self (see below):

 


$query = $pdo->prepare('INSERT INTO leaderboards (rank, username, rounds, players, last_round_time, system, verified, game_id, mode_id, map_id) VALUES (?, ?, ?, ?, ?, ?, ?, 3, 1, 8)');


$query->bindValue(1, $rank);
$query->bindValue(2, $username);
$query->bindValue(3, $rounds);
$query->bindValue(4, $players);
$query->bindValue(5, $lastroundtime);
$query->bindValue(6, $system);
$query->bindValue(7, $reference);


$query->execute();

 

Now as you can see the game_id,mode_id,and map_id are the ones which i set the value of in the query. here is the result in the table:


 

As you can see all the data is succesfully inserted depending on what the user types into the interface, but the last 3 columns are for some reason "1" and not the ones i put in the query?

 

Why is this?

please help? mabey some syntax fault?

Link to comment
Share on other sites

the 'jargon' used in programming (or any activity) is not to exclude people, but to insure that the people partaking in the activity share a common base of information, so that a book doesn't have to be written each time information is exchanged, because there have been books written to teach the basics.

 

you were not asked which database columns were the offending ones, you were asked for the definition of your database table, and then more specifically what the field types are of those columns.

 

edit: i'm kind of curious how you know there are ones in these columns? what is the method or code that produced the output showing those?

Edited by mac_gyver
Link to comment
Share on other sites

the 'jargon' used in programming (or any activity) is not to exclude people, but to insure that the people partaking in the activity share a common base of information, so that a book doesn't have to be written each time information is exchanged, because there have been books written to teach the basics.

 

you were not asked which database columns were the offending ones, you were asked for the definition of your database table, and then more specifically what the field types are of those columns.

 

edit: i'm kind of curious how you know there are ones in these columns? what is the method or code that produced the output showing those?

because i went into the database my self and saw that they were entered as ones, what information do you need, that i can tell you, all the field types are there. and they are all INT apart from "username" ,"system", and "reference" aka "verified"

 

If you read my whole post and clicked on the link, you wouldnt of asked the question of how i know the ones are produce, just like previously where you didnt read my previous thread and thought i was using PDO and not PDOStatement

Edited by afallingpanda
Link to comment
Share on other sites

show us the line where you check the result of your execute statement.  Prove to us that the line ran and we're not looking at a duplicate record.  Or perhaps add a retrieval query and output the results of your insert.  Do Something to solve this yourself instead of whining about what to do.

Link to comment
Share on other sites

show us the line where you check the result of your execute statement.  Prove to us that the line ran and we're not looking at a duplicate record.  Or perhaps add a retrieval query and output the results of your insert.  Do Something to solve this yourself instead of whining about what to do.

okay so ive just reported your post and i will see to blocking you on this site some how, reason being you have absolutely no knowledge in fixing this so you are just posting complete junk for god knows what reason,

 

"Do something to solve this your self" = you absolute idiot, wtf you think i been doing for last 2 days.

"instead of whining about what to do"= err this is a forum where people ask for help, if you dont like it then get out.

 

and also, i showed you a picture of the query running and outputting the records, so again dont ask for code that is already pretty much had evidence shown to, It is not duplicate data because its the only data thats in there ( i delete them all one by one) .

 

next time, dont pretend like you CAN solve problems when you clearly dont even know what your talking about.

 

 

To all others: sorry about the above, his just really annoyed me, i would appreciate if you could help me out.

 

thanks

Link to comment
Share on other sites

If you read my whole post and clicked on the link, you wouldnt of asked the question of how i know the ones are produce, just like previously where you didnt read my previous thread and thought i was using PDO and not PDOStatement

Your image doesn't show jack-shit. You were asked what your table definition was, not what values it contains. You can get the definition by running a 'DESC tableNameHere' query, or just post the CREATE TABLE statement you used when creating the table.

 

Secondly, assuming there is no problem with the table definition, there is no reason those columns would contain 1 rather than the values you set. There is nothing syntactically wrong with your query or code. As such, the most likely explanations are:

1) You are not giving us an accurate representation of your code or

2) You are not verifying the results of your code accurately.

 

There have been numerous times people have come on here adamant that they have correctly checked things only to realize days later(after being told numerous times) that they actually were not. Hence the suggestions to make sure you are checking correctly by having your code select and output the data after inserting. Or at the very least have your code output the ID for the row just entered and make sure you match it up properly when check the table data.

Link to comment
Share on other sites

 

just like previously where you didnt read my previous thread and thought i was using PDO and not PDOStatement

 

that's the other help forum site where you have been posting these same questions.

 

you need to keep your threads and replies straight between all the different places you have posted them. i'm pretty sure no one that has replied in this thread is the same as the member you are referring to on that other site and someone misreading code and stating there's not a function/method is hardly anything to whine about, especially since he was questioning your code because it contains an obvious problem that would have prevented it from producing any output.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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