mysql | always print 0...
#1

hello !

i do this:

pawn Код:
new Props;
mysql_query("SELECT * FROM `props`");
mysql_store_result();
Props = mysql_num_rows();
printf("MAX Props: %i",Props);
and this always print:

MAX Prosp: 0

this should be 4 not 0.

what's the problem here exactly?
thanks in advance helpers ...
Reply
#2

You should try using this:

pawn Код:
mysql_affected_rows()
Reply
#3

you better use sscanf to do it ... the way you doing it seems more like php and i never tested that way of script in pawn so can't help much..
Reply
#4

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
You should try using this:

pawn Код:
mysql_affected_rows()
not working.
Reply
#5

Idiot quesion but have you insert any data?
Reply
#6

Try removing ` ` around props.
Reply
#7

Turn on debugging at the top of your script
pawn Код:
mysql_debug(1);
Then check what the error is in the error log in the server directory.
Reply
#8

here the debug text:

Код:
[02:34:44]  

[02:34:44] ---------------------------

[02:34:44] MySQL Debugging activated (07/15/11)

[02:34:44] ---------------------------

[02:34:44]  

[02:34:44] >> mysql_query( Connection handle: 1 )

[02:34:44] >> mysql_query() - Invalid connection handle. (You set: 1, Highest connection handle ID is 0).

[02:34:44] >> mysql_store_result( Connection handle: 1 )

[02:34:44] >> mysql_store_result() - Invalid connection handle. (You set: 1, Highest connection handle ID is 0).

[02:34:44] >> mysql_num_rows( Connection handle: 1 )

[02:34:44] >> mysql_num_rows() - Invalid connection handle. (You set: 1, Highest connection handle ID is 0).

[02:34:44] >> mysql_connect( )

[02:34:44] CMySQLHandler::CMySQLHandler() - constructor called.

[02:34:44] CMySQLHandler::CMySQLHandler() - Connecting to "localhost" | DB: "QDM" | Username: "root" ...

[02:34:44] CMySQLHandler::Connect() - Connection was successful.

[02:34:44] CMySQLHandler::Connect() - Auto-Reconnect has been enabled.
Reply
#9

Which Plugin is this? G-StylezZz or StrickenKid's?


Quote:
Originally Posted by PrawkC
Посмотреть сообщение
Try removing ` ` around props.
This will make the query not function right ^.
Reply
#10

Quote:
Originally Posted by dr.pepper
Посмотреть сообщение
Which Plugin is this? G-StylezZz or StrickenKid's?



This will make the query not function right ^.
edit:

G-sTyLeZzZ
Reply
#11

pawn Код:
new Props, szQuery[128];
format(szQuery, sizeof(szQuery), "SELECT * FROM `Props`");
SendQuery(szQuery);
mysql_store_result();
Props = mysql_num_rows();
mysql_free_result();
printf("MAX Props: %d",Props);
Not sure if this would work ^
Reply
#12

Quote:
Originally Posted by dr.pepper
Посмотреть сообщение
pawn Код:
new Props, szQuery[128];
format(szQuery, sizeof(szQuery), "SELECT * FROM `Props`");
SendQuery(szQuery);
mysql_store_result();
Props = mysql_num_rows();
mysql_free_result();
printf("MAX Props: %d",Props);
Not sure if this would work ^
again , not working
Reply
#13

At the end of my code

pawn Код:
new Props, szQuery[128];
format(szQuery, sizeof(szQuery), "SELECT * FROM `Props`");
SendQuery(szQuery);
mysql_store_result();
Props = mysql_num_rows();
mysql_free_result();
printf("MAX Props: %d",Props);
Try adding this:
pawn Код:
return Props;
So it would look like this:
pawn Код:
new Props, szQuery[128];
format(szQuery, sizeof(szQuery), "SELECT * FROM `Props`");
SendQuery(szQuery);
mysql_store_result();
Props = mysql_num_rows();
mysql_free_result();
printf("MAX Props: %d",Props);
return Props;
Reply
#14

not working ...
and from what the return ?
Reply
#15

pawn Код:
new Props, szQuery[128], szString[128];
format(szQuery, sizeof(szQuery), "SELECT * FROM `Props`");
SendQuery(szQuery);
mysql_store_result();
Props = mysql_num_rows();
mysql_free_result();
format(szString, sizeof(szString), "Max Props= %d", props);
printf("MAX Props: %d",szString);
return Props;
idk lol, this should work ._.
Reply
#16

Check your connection (ping it) before and after
Reply
#17

Quote:
Originally Posted by EviLpRo
Посмотреть сообщение
here the debug text:

Код:
[02:34:44]  

[02:34:44] ---------------------------

[02:34:44] MySQL Debugging activated (07/15/11)

[02:34:44] ---------------------------

[02:34:44]  

[02:34:44] >> mysql_query( Connection handle: 1 )

[02:34:44] >> mysql_query() - Invalid connection handle. (You set: 1, Highest connection handle ID is 0).

[02:34:44] >> mysql_store_result( Connection handle: 1 )

[02:34:44] >> mysql_store_result() - Invalid connection handle. (You set: 1, Highest connection handle ID is 0).

[02:34:44] >> mysql_num_rows( Connection handle: 1 )

[02:34:44] >> mysql_num_rows() - Invalid connection handle. (You set: 1, Highest connection handle ID is 0).

[02:34:44] >> mysql_connect( )

[02:34:44] CMySQLHandler::CMySQLHandler() - constructor called.

[02:34:44] CMySQLHandler::CMySQLHandler() - Connecting to "localhost" | DB: "QDM" | Username: "root" ...

[02:34:44] CMySQLHandler::Connect() - Connection was successful.

[02:34:44] CMySQLHandler::Connect() - Auto-Reconnect has been enabled.
You are trying to use the query befor you are connected to any database. Try to Connect to MySQL before you use the query, not after^^
Reply
#18

apfelhorst thank's you very much (:
this work
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)