| | |
MSqyl error
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jul 2009
Posts: 12
Reputation:
Solved Threads: 0
U get the following error on my one page
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /usr/www/users/stealtf/components/com_aclassf/top.php on line 111
This is my coding
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /usr/www/users/stealtf/components/com_aclassf/top.php on line 111
This is my coding
<?php /** * This file is part of Almond Classifieds Component for Joomla! (site:http://www.almondsoft.com/j ) * Copyright (C) 2008-2009 AlmondSoft.Com. All rights reserved. * http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ include('funcs2.php'); function print_categories() { global $html_header, $html_footer, $categories,$ad_ind_width,$schopt,$ads_fields,$subcnmb,$javastl,$hghltcat, $catl_width, $top_page_info, $top_page_width, $topsearchfields, $top_leftcol,$catcols,$_REQUEST,$hdhctgrs, $tbclr_1, $tbclr_2, $tbclr_3, $tbclr_4, $fntclr_1, $msg, $top_rightcol,$btmtophtml, $templ, $top_bottom,$getcityval, $popctgr, $top_rightcol, $tmltads, $slctcntr, $indx_url, $use_ajax, $locations; $top_rightcol=""; global $rmmbrloc; if ($_REQUEST[$schopt]!=''){ $cityhtml=" <p class='pst1'> <font class=stfntb> <b>".$ads_fields[$schopt][0].": ".$_REQUEST[$schopt]." </b></font> <font class='stfnt'>( <a href='{$indx_url}allc=1'>".$msg['all_cities']."</a> $rmmbrloc )</font> </font> <br> "; $citgtv1=$_REQUEST[$schopt]; $getcityval="$schopt=".checkgetfld($citgtv1)."&"; } if ($_REQUEST[$schopt]!=""){$ltstcityv="&city=".checkgetfld($_REQUEST[$schopt]);} else{$ltstcityv="";} $grp_cnt=get_grpcnt(); $popctgr=""; $divkey1="0"; foreach ($categories as $key => $value) { $aa1=split("_",$key); if ($aa1[0]=='newcolumn'){$divkey1="0"; $categ[$key]="</td><td valign='top' align=left>";} else { if($aa1[0] == 'title') { $p_val1=""; if ($divkey1=="1"){$p_val1="<p class='pst1'>";} $categ[$key]= " $p_val1<p class='pst1'> <TABLE BORDER=0 WIDTH='90%' cellspacing=0 cellpadding=0 > <TR><td class='ct_group'><a href='{$indx_url}".$getcityval."md=browse&mds=search&gmct=".$aa1[1]."'> <font class='ttl_grp'>".$categories[$key].":</a></font> (".$grp_cnt[$aa1[1]].") </TD></TR></table> "; }else { if (($categories[$key][2] != 'h') and ($key != 'evntcl')) {$divkey1="1";$categ[$key]=print_cat_name($key);} } } } include ($templ['top']); return; } function get_grpcnt() { global $categories, $sql_mct1, $table_ads, $grpcnt, $gkey2, $HTTP_GET_VARS; foreach ($categories as $key => $value) { $aa1=split("_",$key); if($aa1[0]== 'title'){$kk1=0; if ($sql_mct1!=""){ get_gcnt2(); } $sql_mct1=""; } if($kk1==1 and $key!="evntcl" and $key!="evcl_rpl" and $categories[$key][2]!="h" and $aa1[0]!='newcolumn'){$sql_mct1=$sql_mct1." catname='$key' or";} if($aa1[0]== 'title'){$kk1=1; $gkey2=$aa1[1];} } get_gcnt2(); return $grpcnt; } function get_gcnt2() { global $sql_mct1, $table_ads, $grpcnt, $gkey2, $HTTP_GET_VARS; if ($HTTP_GET_VARS['city']!=""){ $city_query=" and city='".$HTTP_GET_VARS['city']."' ";}; $sql_mct1=preg_replace ("/or$/", "", $sql_mct1); $sql_mct1="( $sql_mct1 ) and "; $sql_query="select count(idnum) from $table_ads where $sql_mct1 visible=1 $city_query"; $sql_res=mysql_query("$sql_query"); $row=mysql_fetch_row($sql_res); $grpcnt[$gkey2]=$row[0]; } function print_cat_name($key) { global $categories, $fntclr_1, $msg, $subcnmb, $getcityval,$popctgr, $indx_url; # $dtupd=get_date_update($key); if ($dtupd!=''){$dtupd=$msg['updated_t'].": ".$dtupd;} $vhtml= " <nobr><a href='".sturl_ct_top($key,$getcityval, "1")."' > ".$categories[$key][0]."</a> <font class='ct_count'>(".get_cat_count($key).")</font></nobr> <br> "; return $vhtml; } function checkgetfld($value) { $value=ereg_replace(' ', '+', $value); $value=ereg_replace('@', '%40', $value); $value=ereg_replace('!', '%21', $value); $value=ereg_replace("'", '%27', $value); $value=ereg_replace("\"", '%27', $value); return $value; } function get_total_count() { global $cat_fields, $table_ads, $ct, $page, $adsonpage, $html_header, $html_footer; global $sqlaflcl; $sql_query="select count(idnum) from $table_ads where $sqlaflcl visible=1 "; if( !($sql_res=@mysql_query("$sql_query"))) {echo $html_header; echo " <center> <font FACE='ARIAL, HELVETICA' COLOR='#bb0000' size=-1><b> Error in connecting to ads MySQL table <font color='#000099'>'$table_ads'</font>. <br> Seems, this table is not created, <a href='createtb.php'>click here </a> to create this table. </b></font></center> "; echo $html_footer; return; } $row=mysql_fetch_row($sql_res); $count=$row[0]; return $count; } ?>
Last edited by jjtao; Jul 29th, 2009 at 7:26 am.
Replace this:
With this:
The die method(above post) could be used instead of the if statement, its a matter of personal preference, tho the die may be milliseconds faster
Your issue could be as simple as a SQL error, when $sql_res is failing you will receive an error on mysql_fetch_row.
Perhaps add a LIMIT 1 to the end of the query. Are you sure that there aren't more than 1 result being returned by the query?
php Syntax (Toggle Plain Text)
$sql_res=mysql_query("$sql_query"); $row=mysql_fetch_row($sql_res);
With this:
php Syntax (Toggle Plain Text)
$sql_res=mysql_query($sql_query); if (!$sql_res) { echo 'Could not run query: ' . mysql_error(); exit; } $row=mysql_fetch_row($sql_res);
Your issue could be as simple as a SQL error, when $sql_res is failing you will receive an error on mysql_fetch_row.
Perhaps add a LIMIT 1 to the end of the query. Are you sure that there aren't more than 1 result being returned by the query?
Last edited by SoN9ne; Jul 29th, 2009 at 12:05 pm.
•
•
Join Date: Jul 2009
Posts: 12
Reputation:
Solved Threads: 0
•
•
•
•
Replace this:
php Syntax (Toggle Plain Text)
$sql_res=mysql_query("$sql_query"); $row=mysql_fetch_row($sql_res);
With this:
The die method(above post) could be used instead of the if statement, its a matter of personal preference, tho the die may be milliseconds fasterphp Syntax (Toggle Plain Text)
$sql_res=mysql_query($sql_query); if (!$sql_res) { echo 'Could not run query: ' . mysql_error(); exit; } $row=mysql_fetch_row($sql_res);
Your issue could be as simple as a SQL error, when $sql_res is failing you will receive an error on mysql_fetch_row.
Perhaps add a LIMIT 1 to the end of the query. Are you sure that there aren't more than 1 result being returned by the query?
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 ') and visible=1' at line 1 when I use the die method I get this
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 ') and visible=1' at line 1 Very new to php and I didnt make the coding, its a app. line one doesnt make sense to be incorrect since I know thats normal coding. <?phpalso I know the syntax issue is with this line
PHP Syntax (Toggle Plain Text)
$sql_query="select count(idnum) from $table_ads where $sql_mct1 visible=1 $city_query";
Last edited by jjtao; Jul 30th, 2009 at 4:48 am.
•
•
Join Date: Jul 2009
Posts: 12
Reputation:
Solved Threads: 0
•
•
•
•
Line 1 is referring to the first line of the query, not php. This is a MySQL error, not a php error. There is something wrong with the SQL query.
It seems that the issue is in the variable, $sql_mct1. Would you mind posting that code up?
function get_gcnt2()
{
global $sql_mct1, $table_ads, $grpcnt, $gkey2, $HTTP_GET_VARS;
if ($HTTP_GET_VARS['city']!=""){ $city_query=" and city='".$HTTP_GET_VARS['city']."' ";};
$sql_mct1=preg_replace ("/or$/", "", $sql_mct1);
$sql_mct1="( $sql_mct1 ) and ";
$sql_query="select count(idnum) from $table_ads where $sql_mct1 visible=1 $city_query";
$sql_res=mysql_query("$sql_query");
$row=mysql_fetch_row($sql_res);
$grpcnt[$gkey2]=$row[0];
} You should not use $HTTP_GET_VARS, use $_GET instead. You also don't need to include that in the globals, $_GET is a superglobal so you don't need to use global to use it.
The issue is still with the $sql_mct1
Perhaps echo out the $sql_mct1 before the query to see what it is. When i see the value of $sql_mct1 I can of more help.
Possibility that the preg_replace is causing your problem, not sure tho without knowing the value of $sql_mct1.
I cleaned the code a little and added in some debug for you.
The issue is still with the $sql_mct1
Perhaps echo out the $sql_mct1 before the query to see what it is. When i see the value of $sql_mct1 I can of more help.
Possibility that the preg_replace is causing your problem, not sure tho without knowing the value of $sql_mct1.
I cleaned the code a little and added in some debug for you.
php Syntax (Toggle Plain Text)
function get_gcnt2() { global $sql_mct1, $table_ads, $grpcnt, $gkey2; $city_query=''; if (isset($_GET['city']) && $_GET['city']) { $city_query = " AND city='".$_GET['city']."' "; } $sql_mct1 = preg_replace("/or$/", "", $sql_mct1); $sql_query = "SELECT COUNT(idnum) FROM $table_ads WHERE $sql_mct1 AND visible = 1 $city_query"; $sql_res = mysql_query($sql_query); if (!$sql_res) { $errID = mysql_errno(); $errEr = mysql_error(); die('There was an error with SQL: '.(isset($errID) ? $errID.': '.$errEr : $errEr)); } $row=mysql_fetch_row($sql_res); if ($row) { $grpcnt[$gkey2]=$row[0]; } }
Last edited by SoN9ne; Jul 30th, 2009 at 12:53 pm.
![]() |
Similar Threads
- Code 19 Registry Error (Windows NT / 2000 / XP)
- Error Loading operating System (Windows NT / 2000 / XP)
- svchost.exe error (Windows NT / 2000 / XP)
- New Hardware Causing Error (Windows NT / 2000 / XP)
- office 2000 install error (Windows NT / 2000 / XP)
- VMWare Unrecoverable Error (*nix Software)
- Error in Wrox Book (Perl)
Other Threads in the PHP Forum
- Previous Thread: insert data into two separate table / 2 queries in same php file
- Next Thread: parse error on last line (line 802)
| Thread Tools | Search this Thread |
.htaccess ajax apache api array beginner binary broken buttons cakephp checkbox class cms code cron curl database date directory display download dynamic ebooks echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla limit link login loop mail mediawiki menu mlm mod_rewrite multiple mysql number oop paypal pdf php phpincludeissue phpmyadmin problem query radio random recursion regex remote script search server sessions sms soap source sp space speed sql subdomain syntax system table tag tutorial update upload url validation validator variable vbulletin video web websphere white xml youtube





