Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-23-2012, 05:59 PM   PM User | #1
Uniqueconcepts
New to the CF scene

 
Join Date: Oct 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Uniqueconcepts is an unknown quantity at this point
Error in SQL syntax

I get this error message whenever we try to add items. I'm not a PHP wizard, and I'm currently working on a website designed by two previous designers. Any help would be appreciated!

Quote:
A Database Error Occurred
Error Number: 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 '' at line 1

SELECT * FROM item_images WHERE items_id =

PHP Code:
<?php
if (isset($items))
{
    
?>
    <?if(count($items) > 0):?>
    <table class="no-arrow colstyle-alt rowstyle-alt onload-zebra">
        <tr>
            <th class="sortable">Name</th>
            <th class="sortable">SKU</th>
            <th class="sortable">Image</th>
            <th class="sortable">Conversion</th>
            <th class="sortable center">Featured</th>
            <th class="sortable">Category</th>
            <th class="icon"></th>
            <th class="icon"></th>
        </tr>
        <?foreach($items as $Item):?>
        <tr class="tr_link link" url="<?= site_url("/admin/items/create-group-item/$Item->groups_id/$Item->id"?>">
            <td><? echo substr($Item->name040); echo (strlen($Item->name) > 40) ? '...' '' ?></td>
            <td><?=$Item->sku?></td>
            <td><?=$Item->image?></td>
            <td><?= (isset($conversions[$Item->conversions_id])) ? $conversions[$Item->conversions_id]->name '' ?></td>
            <td class="center"><?= (!empty($Item->featured)) ? $Item->featured '' ?></td>
            <td>
                <?php
                    
if (isset($categories_dropdown))
                    {
                        echo 
$categories_dropdown[$Item->categories_id];
                    }
                    else
                    {
                        echo 
$categories[$Item->categories_id];
                    }
                
?>
            </td>
            <td class="icon"><img src="<?php echo base_url();?>assets/images/admin/pencil-edit-icon.png" /></td>
            <td class="icon"><?=anchor('admin/items/item-delete/' $Item->id'<img src="' base_url() . 'assets/images/admin/delete-icon.png" />''class="delete"')?></td>
        </tr>
        <?endforeach?>
    </table>
    <?endif?>
    
    <script>
        $$('.delete').invoke('observe', 'click', function(e) {
            response = confirm('Are you sure you want to delete this item?');
            if(!response)
                e.stop();
        });
    
        $$('.link').invoke('observe', 'click', function(e) {
              window.location = $(this).readAttribute("url");
    
        });
    </script>

    <?php
}
?>
Uniqueconcepts is offline   Reply With Quote
Old 10-23-2012, 06:09 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
You don't have the code for the SQL here, but the error itself indicates that it has not been provided with any items_id in which to search. Since you don't post the full error (as in PHP error), we can't show you where to look for it. Enable PHP's error reporting:
PHP Code:
ini_set('display_errors'1);
error_reporting(E_ALL); 
It may tell you that you have undeclared variables.
Fou-Lu is offline   Reply With Quote
Old 10-23-2012, 06:22 PM   PM User | #3
Uniqueconcepts
New to the CF scene

 
Join Date: Oct 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Uniqueconcepts is an unknown quantity at this point
I'm sorry for being so ignorant about this stuff, but where should I insert that line of code?

Also, where can you generally find the SQL code? What would the extension be? Thank you so much for your help!
Uniqueconcepts is offline   Reply With Quote
Old 10-23-2012, 06:25 PM   PM User | #4
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
SQL code can be embedded wherever in PHP code.
Ini and error reporting sets are typically done at the top right after the <?php tags.
Fou-Lu is offline   Reply With Quote
Old 10-23-2012, 07:08 PM   PM User | #5
Uniqueconcepts
New to the CF scene

 
Join Date: Oct 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Uniqueconcepts is an unknown quantity at this point
I found some .sql files, and they say they're Server version 5.0.91. Could this be part of the problem?

I looked to see if the error was simply changing TYPE= to ENGINE=, but it was already done.

Not sure what part, if any, of this .sql coding I should paste here. Thanks!
Uniqueconcepts is offline   Reply With Quote
Old 10-23-2012, 08:08 PM   PM User | #6
Uniqueconcepts
New to the CF scene

 
Join Date: Oct 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Uniqueconcepts is an unknown quantity at this point
Quote:
Run SQL query/queries on database
Quote:
`items_id``image`SELECT * FROM `item_images` WHERE 1
Is there an error with that at all?
Uniqueconcepts is offline   Reply With Quote
Old 10-23-2012, 08:11 PM   PM User | #7
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,168
Thanks: 59
Thanked 3,992 Times in 3,961 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
In the first line of the code you showed you use if (isset($items)) but you never show us where $items came from. If you want help, *THAT* is what you must show.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 10-23-2012, 08:15 PM   PM User | #8
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,168
Thanks: 59
Thanked 3,992 Times in 3,961 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Quote:
Originally Posted by Uniqueconcepts View Post
Is there an error with that at all?
How can we tell when you don't show us WHERE it is being used?

The actual SQL that you show there is unusual but not illegal.

But it doesn't match the error message you gave in your first message. So it may be entirely irrelevant.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 10-23-2012, 08:45 PM   PM User | #9
Uniqueconcepts
New to the CF scene

 
Join Date: Oct 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Uniqueconcepts is an unknown quantity at this point
I think my complete lack of php and SQL knowledge is making this hard to solve. Thank you guys, but I think I'll have to hire somebody else to work this out!
Uniqueconcepts is offline   Reply With Quote
Old 10-23-2012, 11:55 PM   PM User | #10
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,168
Thanks: 59
Thanked 3,992 Times in 3,961 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
You can't show more of the PHP coding???

Or is this page being generated by some kind of tool that generates the PHP for you?
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:14 AM.


Advertisement
Log in to turn off these ads.