problems with "mysql_num_rows()"

anilson1

New Member
Messages
45
Reaction score
0
Points
0
Hi,
I am having problems with mysql_num_rows().
I used to have this:

$sqr1="SELECT * FROM $table WHERE GroupName = '$mygroup' ORDER BY SlipNum ASC, DrawNum ASC";

and my site worked well. but now, it seems that every apostroph (') was replaced by ('), and I passed to have this:

$sqr1="SELECT * FROM $table WHERE GroupName = '$mygroup' ORDER BY SlipNum ASC, DrawNum ASC";

and I get the error:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/anilson1/public_html/Molingokoko_3303/Quem_O_PuroMadie1094/proccessingPLAY.php on line 61

I tried the following and worked

$sqr1="SELECT * FROM $table";

I even tried this:

$sqr1="SELECT * FROM $table WHERE GroupName = '$mygroup' ORDER BY SlipNum ASC, DrawNum ASC";
if(!($result1=mysql_query($sqr1,$connector)))
{echo "problems with selector<br>";}

and I got this:

problems with selector

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/anilson1/public_html/Molingokoko_3303/Quem_O_PuroMadie1094/proccessingPLAY.php on line 61



How can I solve this problem with the apostroph, I tried to change &apos; by "'" but it goes back to &apos;.

Any help please.
 

tttony

Member
Messages
147
Reaction score
0
Points
16
try this:

Code:
$sqr1= sprintf("SELECT * FROM %s WHERE GroupName = '%s' ORDER BY SlipNum ASC, DrawNum ASC", $table, $mygroup);
 

anilson1

New Member
Messages
45
Reaction score
0
Points
0
Thank you for you replay. It worked. I do not want to be bored, but I have in the same page something more complicated.

How would I modify this:

Code:
$sqr = "INSERT INTO $table (RefNum,PersonalID,GroupName,SlipNum,DrawNum,Num1,Num2,Num3,Num4,Num5,Num6,Num7,DatePlayed)VALUE(&apos;$countRefNum&apos;,&apos;$userID&apos;,&apos;$mygroup&apos;,&apos;$sendSlipNum&apos;,&apos;$sendDrawNum&apos;,&apos;$myrealnumber[1]&apos;,&apos;$myrealnumber[2]&apos;,&apos;$myrealnumber[3]&apos;,&apos;$myrealnumber[4]&apos;,&apos;$myrealnumber[5]&apos;,&apos;$myrealnumber[6]&apos;,&apos;$myrealnumber[7]&apos;,&apos;$getcurrentDate&apos;)";
 
Last edited by a moderator:

tttony

Member
Messages
147
Reaction score
0
Points
16
never use variables into string:

echo "this is a $variable";

use it like this:

echo "this is a " . $variable;

or

printf("this is a %s", $variable);

use the function sprintf() for multiple variables, you can do it just try it...
 
Last edited:

anilson1

New Member
Messages
45
Reaction score
0
Points
0
So, I would have:

Code:
$sqr = "INSERT INTO %$ (RefNum,PersonalID,GroupName,SlipNum,DrawNum,Num1, Num2,Num3,Num4,Num5,Num6,Num7,DatePlayed) VALUE (‘%$’, ‘%$’,‘%$’, ‘%$’,‘%$’,‘%$’, ‘%$’,‘%$’, ‘%$’,‘%$’, ‘%$’, ‘%$’,‘%$’", $countRefNum, $userID, $m ygroup, $sendSlipNum, $sendD rawNum, $myrealnumber[1], $myrealnumber[2], $myrealnumber[3], $myrealnumber[4], $myrealnumber[5], $myrealnumber[6], $myrealnumber[7], $getcurrentDate), [B][U]$table[/U][/B];

OR

Code:
$sqr = "INSERT INTO %$ (RefNum,PersonalID,GroupName,SlipNum,DrawNum,Num1, Num2,Num3,Num4,Num5,Num6,Num7,DatePlayed) VALUE (‘%$’, ‘%$’,‘%$’, ‘%$’,‘%$’,‘%$’, ‘%$’,‘%$’, ‘%$’,‘%$’, ‘%$’, ‘%$’,‘%$’" [B][U]$table[/U][/B], $countRefNum, $userID, $m ygroup, $sendSlipNum, $sendD rawNum, $myrealnumber[1], $myrealnumber[2], $myrealnumber[3], $myrealnumber[4], $myrealnumber[5], $myrealnumber[6], $myrealnumber[7], $getcurrentDate);
 
Last edited by a moderator:

tttony

Member
Messages
147
Reaction score
0
Points
16
Use %s not %$, do you have the NumX fields as INT in the table??

if it is remember that you dont have to use ' the simple quote for number fields

other thing is if the data of variable is only string use %s if it is number use %d
 

anilson1

New Member
Messages
45
Reaction score
0
Points
0
Why does it happens?
why instead of ' I am getting &apos; ?
does it have to do with encoding characters?

I noticed that if I open it in view the page in file manager I still have ' but if I open it for edit then I get &apos;, and if I save that then even in view format I get &apos;

Does it have to do with my computer? I do not want to chance all my pages.
 

anilson1

New Member
Messages
45
Reaction score
0
Points
0
here goes a single page. right now I am only worried with this &apos;

the code:

-----------------------

--Code removed by compwhizii--
 
Last edited by a moderator:

leafypiggy

Manager of Pens and Office Supplies
Staff member
Messages
3,819
Reaction score
163
Points
63
If you are using an old browser, it WILL put the html special char "&apos;"

PLEASE PUT YOUR TEXT IN
Code:
 tags!!!!!!!!!!!!!
 
Last edited:

compwhizii

Banned
Messages
779
Reaction score
0
Points
0
I already asked you to put the code in code tags. Next time that you don't you will receive an infraction.
 
Top