tags:

views:

96

answers:

3
+4  A: 

It seems to me you have a comma too much after:

dbl.id dbl_id

Edit: Another error in the query is that you are referencing a field from table dbl:

dbl.id dbl_id

but you are not joining that table to the query so dbl.id is an unknown entity.

jeroen
Thank you very much as well, the comma was stopping the query to execute, Now please be kind and look at the EDITED PART in post one. I have dkb.id dkb_id, dkb.price price1, dkb.name name1, but they won't display any data on the html through the php is coming empty don't know why.
jona
Marc B
what would be the mysql monitor the RUN mysql query/queries box in phpmyadmin?
jona
What about if I have many other fields that I won't use in the cart will have I have to specifying them at the SELECT any ways even though I won't use them?
jona
No, you just select what you need. And yes, you could run the query as well in something like phpmyadmin.
jeroen
Jeroen I just run it on phpmyadmin but it will throw this error #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM cart LEFT OUTER JOIN dkb ON (cart.id = dkb.i' at line 21Instead on phpmyadmin I have put the query like LEFT OUTER JOIN dkb ON ( cart.id = dkb.id and dkb.id = 1 )Instead of using the variable $is I use 1 because it won't recognize the variable $is in php phpmyadmin if it is not the script. The real query is LEFT OUTER JOIN dkbON ( cart.id = dkb.id and dkb.id = $is )
jona
See my edit....
jeroen
@jeroen check I have edited the query at the ---EDITED PART--- Now I added another LEFT OUTER JOIN where dbl.id field makes sense to be there plus at the WHERE clause I have added the rest of the query and some fields missing at the SELECT clause. But still the error the following error being generated by phpmyadmin:#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM cart LEFT OUTER JOIN dkb ON (cart.id = dkb.id' at line 21
jona
Well, obviously that explains why you're not getting any data back from the query. You should ALWAYS call mysql_error() after running any database operations, just in case something does blow up.Some googling shows error 1064 to be related to using reserved words in a query.
Marc B
<?php mysql_query("SELECT....)$error = mysql_error ();if ($error === '') { echo "I can't believe it, query '$cobol' actually worked. Uncle Monty, I'm scared...";} else { echo "Thankfully, query '$cobol' failed! The error message generated was \"$error\"!";}?>What about the above code to set up of mysql_error(); function to display the error that is causing the query not to work fully?
jona
Now it is not displaying the error and it display MySQL returned an empty result set (i.e. zero rows). ( Query took 0.0001 sec )
jona
Which means that it is working now but it will still not display any name1 field or price1 on the html script.
jona
If the query returns an empty data-set, it should be easy to figure out why. Just start the query with one table, run it and add the other tables one by one. Then you will see exactly what mysql is doing.
jeroen
One possibility... is there any reason that `$is` and `$ic` are being set to the same value at the top of the script? They're both pulling data from `$_GET['is']`. Since the query's not returning any data, obviously the query's not constructed correctly (or your tables are empty).
Marc B
guys I have taken out the condition after the AND clause in the dbk and cdbk tables. Without the conditions it works. it display the data and name and prices but from table dkb. right now I am facing a different issue now with the modification and fixed of the query. Check out the edited first post I am explaining what's the problem and the possible source.
jona
+2  A: 

Your SELECT has a comma at the end of your last field. You should remove that comma.

SELECT
cart.id    cart_id,
dkb.id     dkb_id,
cdkb.id    cdkb_id,
dbl.id     dbl_id, <-- comma here isn't needed
Joseph
Thank you very much the comma was stopping the query to execute, Now please be kind and look at the EDITED PART in post one. I have dkb.id dkb_id, dkb.price price1, dkb.name name1, but they won't display any data on the html through the php is coming empty don't know why.
jona
You STILL have that comma in the code you posted. You're not checking whether the query actually executed or not, so mysql_fetch_array will be throwing a warning but you may not see it if you have error_reporting set not to display errors. Make sure you check if $result === false after mysql_query which indicates if an error occurred.
Andy Shellam
The comman has been fixed I put the last code but in server I have fixed the comman thank you. That would be something like if ($result===false){echo "<hr>mysql_error : ".mysql_error()."<br>";echo "mysql_errno : ".mysql_errno()."<hr>";}Please if be kind and make an illustration of what you talking.
jona
A: 

Your query will also blow up if $_GET['is'] is not set. You're assigning the value null to $is and $ic, not the string "null". A null value in string context is a blank string (''), so you'll end up with ON ( cart.id = dkb.id and dkb.id = ) which is a syntax error.

You'll have to change the initial assignment to something like this:

$ic= isset($_GET['is']) ? '= ' . (int)$_GET['is'] : 'is null';
Marc B
Thank you Marc B I did changed it but it still didn't display the fields values, Do you have any other thought of why this could be happening
jona