Jump to content


Photo

I Am Getting These Mysql Warnings On A Website I Am Trying To Upload Thru A Php Template


  • Please log in to reply
7 replies to this topic

#1 jedenerio

jedenerio

    Newbie

  • New Members
  • Pip
  • 4 posts

Posted 12 December 2012 - 11:17 PM

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/asensoco/public_html/config.php on line 4
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/asensoco/public_html/config.php on line 4
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/asensoco/public_html/index.php on line 14
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/asensoco/public_html/config.php on line 4

How can i fix this?

#2 PFMaBiSmAd

PFMaBiSmAd

    Advanced Member

  • Staff Alumni
  • 16,767 posts
  • LocationColorado, U.S.A.

Posted 12 December 2012 - 11:22 PM

By finding out why the parameter you are passing into the mysql_num_rows function is a boolean instead of a resource.

A SELECT query that runs without any errors will return a result resource. The error you are getting is typical of a SELECT query that failed due to an error and you don't have any error checking logic in your code to test if the query worked before using the result in following statements.

You can echo mysql_error() after the point where you execute your query to find out why the query is failing.
Signature: (not a comment about anything you posted unless specifically indicated)
Debugging step #1: To get past the garbage-out equals garbage-in stage in your code, you must check that the inputs to your code are what you expect.

Programming is just problem solving, but it is done in another language. You must learn enough of the programming language you are using to be able to read and write code.

#3 jedenerio

jedenerio

    Newbie

  • New Members
  • Pip
  • 4 posts

Posted 12 December 2012 - 11:30 PM

This is what it looks like in my CONFIG.PHP file, i can't tell here which one is the error

<?php
include "dbconfig.php";
$rs=mysql_query("select * from adminsettings");
if(mysql_num_rows($rs)>0) {
$arr=mysql_fetch_array($rs);
$sitename=$arr[0];
$siteurl=$arr[1];
$webmasteremail=$arr[2];
$adminuser=$arr[46];
$adminpass=$arr[3];

$alertpay=$arr[4];

$fee=$arr[7];

$levels=$arr[8];

$level1=$arr[9];
$level2=$arr[10];
$level3=$arr[11];
$level4=$arr[12];
$level5=$arr[13];
$level6=$arr[14];
$level7=$arr[15];
$level8=$arr[16];
$level9=$arr[17];
$level10=$arr[18];

$forcedmatrix=$arr[19];
$membershipperiod=$arr[20];
$duration=$membershipperiod;
$signupbonus=$arr[21];

$bonusduration=$arr[47];
$pendingnotification=$arr[48];
$ipncode=$arr[52];

$yfwid=$arr[22];
$subject1=$arr[23];
$message1=$arr[24];
$subject2=$arr[25];
$message2=$arr[26];
$subject3=$arr[27];
$message3=$arr[28];
$subject4=$arr[29];
$message4=$arr[30];
$subject5=$arr[49];
$message5=$arr[50];

$eformat1=$arr[31];
$eformat2=$arr[32];
$eformat3=$arr[33];
$eformat4=$arr[34];
$eformat5=$arr[51];

$subject6=$arr[53];
$message6=$arr[54];
$eformat6=$arr[55];

$subject7=$arr[56];
$message7=$arr[57];
$eformat7=$arr[58];

$subject8=$arr[59];
$message8=$arr[60];
$eformat8=$arr[61];

$subject9=$arr[62];
$message9=$arr[63];
$eformat9=$arr[64];

$extramerchants=$arr[35];

$merchantname1=stripslashes($arr[36]);
$merchantcode1=stripslashes($arr[37]);

$merchantname2=stripslashes($arr[38]);
$merchantcode2=stripslashes($arr[39]);

$merchantname3=stripslashes($arr[40]);
$merchantcode3=stripslashes($arr[41]);

$merchantname4=stripslashes($arr[42]);
$merchantcode4=stripslashes($arr[43]);

$merchantname5=stripslashes($arr[44]);
$merchantcode5=stripslashes($arr[45]);


$rs=mysql_query("select * from adminsettingsm");
if(mysql_num_rows($rs)>0) {
$arr=mysql_fetch_array($rs);
$mlevel1=$arr[0];
$mlevel2=$arr[1];
$mlevel3=$arr[2];
$mlevel4=$arr[3];
$mlevel5=$arr[4];
$mlevel6=$arr[5];
$mlevel7=$arr[6];
$mlevel8=$arr[7];
$mlevel9=$arr[8];
$mlevel10=$arr[9];
}
}
?>

#4 PFMaBiSmAd

PFMaBiSmAd

    Advanced Member

  • Staff Alumni
  • 16,767 posts
  • LocationColorado, U.S.A.

Posted 12 December 2012 - 11:35 PM

i can't tell here which one is the error


The ones matching the file and line numbers listed in the error messages.
Signature: (not a comment about anything you posted unless specifically indicated)
Debugging step #1: To get past the garbage-out equals garbage-in stage in your code, you must check that the inputs to your code are what you expect.

Programming is just problem solving, but it is done in another language. You must learn enough of the programming language you are using to be able to read and write code.

#5 jedenerio

jedenerio

    Newbie

  • New Members
  • Pip
  • 4 posts

Posted 12 December 2012 - 11:43 PM

I don't know anything about PHP.

#6 PFMaBiSmAd

PFMaBiSmAd

    Advanced Member

  • Staff Alumni
  • 16,767 posts
  • LocationColorado, U.S.A.

Posted 13 December 2012 - 12:00 AM

The only thing in this thread that requires any specific php knowledge would be the actual syntax for the echo statement -

echo mysql_error();

Signature: (not a comment about anything you posted unless specifically indicated)
Debugging step #1: To get past the garbage-out equals garbage-in stage in your code, you must check that the inputs to your code are what you expect.

Programming is just problem solving, but it is done in another language. You must learn enough of the programming language you are using to be able to read and write code.

#7 jedenerio

jedenerio

    Newbie

  • New Members
  • Pip
  • 4 posts

Posted 13 December 2012 - 12:06 AM

if yu go to www.asenso500.com

you will see the warnings in there. im really struggling making the site work

i hope i can someone help me with those 2 remaining warnings.

#8 Christian F.

Christian F.

    Advanced Member

  • Staff Alumni
  • 3,106 posts
  • LocationNorway

Posted 13 December 2012 - 05:20 AM

If you haven't read this thread already, then I'd recommend doing so. It'll help you in debugging the MySQL errors, so that you can get them sorted out.
Keeping it simple.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com