w1ckd Posted April 23, 2009 Share Posted April 23, 2009 Hey, My first post but not my last:) I have just started with php or well just, i am in a learning progress. i am trying to make function but somehow it gives me on every way a *Fatal error : SQL error * The function looks like: function sed_get_previewimage() { $res = sed_sql_query("SELECT att_path FROM $db_attach WHERE att_type = 'pag' AND att_item = {$pag['page_id']} AND att_img = 1 ORDER BY att_id LIMIT 1"); if(sed_sql_numrows($res) == 1) { $att = sed_sql_fetcharray($res); $prev_path = att_get_preview($att['att_path']); if(!file_exists($prev_path)) att_create_preview($att['att_path']); echo "<img src="'.$prev_path.'" alt="" />"; } else echo "No screenshot uplouded"; } } $previewimg = sed_get_previewimage(); This should be more then logic but somehow it gives me the error? Quote Link to comment https://forums.phpfreaks.com/topic/155332-php-function-return-sql-query/ Share on other sites More sharing options...
jackpf Posted April 23, 2009 Share Posted April 23, 2009 What's the exact error? Quote Link to comment https://forums.phpfreaks.com/topic/155332-php-function-return-sql-query/#findComment-817264 Share on other sites More sharing options...
w1ckd Posted April 23, 2009 Author Share Posted April 23, 2009 Thank you for the reaction. Here is the error : 2009-04-23 04:05 Fatal error : SQL error : 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 'WHERE att_type = 'pag' AND att_item = AND att_img = 1 ORDER BY att_id LIMIT 1' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/155332-php-function-return-sql-query/#findComment-817272 Share on other sites More sharing options...
jackpf Posted April 23, 2009 Share Posted April 23, 2009 Hmm...you could try wrapping your column names with ` Quote Link to comment https://forums.phpfreaks.com/topic/155332-php-function-return-sql-query/#findComment-817273 Share on other sites More sharing options...
w1ckd Posted April 23, 2009 Author Share Posted April 23, 2009 No succes, It even doesnt matter what sql query i put there it is showing that error, And the query is working on other script, any more ideas? Quote Link to comment https://forums.phpfreaks.com/topic/155332-php-function-return-sql-query/#findComment-817354 Share on other sites More sharing options...
jackpf Posted April 23, 2009 Share Posted April 23, 2009 What's $db_attach? Quote Link to comment https://forums.phpfreaks.com/topic/155332-php-function-return-sql-query/#findComment-817371 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.