/    Sign up×
Community /Pin to ProfileBookmark

another error

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in on line 28

Line 28 is the

$result2 = mysql_query($sql2, $conn) or die(mysql_error());
if (mysql_num_rows($result2 ==1)) {

The entrie source can be found

Thanks Adam[URL=http://www.webdeveloper.com/forum/showthread.php?s=&postid=227556#post227556]Here[/URL]

Thanks Adam

to post a comment
PHP

16 Comments(s)

Copy linkTweet thisAlerts:
@96turnerriAug 12.2004 — $result2 = mysql_query($sql2, $conn) or die(mysql_error());

if (mysql_num_rows($result2 ==1)) {

please dont double post,

EDIT: oops i copied wrong one wrong other post
Copy linkTweet thisAlerts:
@solavarAug 12.2004 — You've got...

[code=php]

$result2 = mysql_query($sql2, $conn) or die(mysql_error());
if (mysql_num_rows($result2 ==1)) {

[/code]


...must be

[code=php]

$result2 = mysql_query($sql2, $conn) or die(mysql_error());
if (mysql_num_rows($result2) ==1) {

/* Meaning:
'If the number of rows returned to the result resource called 'result2' is equal to 1, then ...blah...blah... */

[/code]


To understand it better, do this...

[code=php]

$result2 = mysql_query($sql2, $conn) or die(mysql_error());

$numrows = mysql_num_rows($result2);

if ($numrows ==1)) {

//makes it much clearer

[/code]
Copy linkTweet thisAlerts:
@k0r54authorAug 12.2004 — sorry bout double posting btw

is there any difference

?
Copy linkTweet thisAlerts:
@k0r54authorAug 12.2004 — ooo i c.

Thanks alot its all working now

Thanks every1 i will be posting some more though lol
Copy linkTweet thisAlerts:
@k0r54authorAug 12.2004 — ok i do have another one.

If i set the field in sql to a text type

how can i put in html as a value?

coz what i want it to click on a link and that link will open a new page with the content of that field in

i know how to do it accept when i put html into the value it errors

Any ideas.

Thanks Adam
Copy linkTweet thisAlerts:
@96turnerriAug 12.2004 — umm dont set it as text set it as varchar(255)
Copy linkTweet thisAlerts:
@k0r54authorAug 12.2004 — but the html code may be over 255 charactors

Also how do i pass on a variable through php files

I.e i have linked the page you have seen to another php document and i need to use the variable $AuctionID

how do i do that m new page has this on

[code=php]
<?PHP

//conn
$conn = mysql_connect("localhost", "k0m0d0", "ragnarok") or die(mysql_error());

//select db
mysql_select_db("ebay",$conn) or die(mysql_error());

//statement
$sql = "SELECT Source FROM auctions WHERE ID = '$AuctionID'";

//if script
$result = mysql_query($sql, $conn) or die(mysql_error());
if (mysql_num_rows($result) ==1) {

//fetch results
$row = mysql_fetch_array($result);

//extract is into the echo
extract($row);

echo "$Source";
};
?>
[/code]
Copy linkTweet thisAlerts:
@k0r54authorAug 12.2004 — do i need to add something like

[code=php]
$AuctionID = $HTTP_POST_VARS['AuctionID'];
[/code]


The thing is i want a step by step registration so how do i keep all the variables that are entered. So when im at the end i can write it all the the database even something the user and written in on a previous page.

Thanks Adam
Copy linkTweet thisAlerts:
@96turnerriAug 13.2004 — well in that case you need to look up http://uk.php.net/manual/en/ref.session.php

and yes if the HTML is over 255 characters it will still go in mysql table, varchar(255) is like infinte characters
Copy linkTweet thisAlerts:
@solavarAug 13.2004 — [i]Originally posted by 96turnerri [/i]

and yes if the HTML is over 255 characters it will still go in mysql table, varchar(255) is like infinte characters [/QUOTE]


I think you may have to check on this one.

The MySQL manual says:

<i>
</i>If you assign a value to a CHAR or VARCHAR column that exceeds the column's maximum length,
the value is truncated to fit.


...source:

http://dev.mysql.com/doc/mysql/en/CHAR.html
Copy linkTweet thisAlerts:
@k0r54authorAug 13.2004 — as predicted, the html was truncated, and when i put it into a text type it dont allow it to go in.

The varchar 255 didn't put in anything after the 255 charactors.

Any idea's on how to do it now coz i cant use text or varchar

Thanks

Adam
Copy linkTweet thisAlerts:
@solavarAug 13.2004 — Here are the data types:

[code=php]

TINYTEXT
A BLOB or TEXT column with a maximum length of 255 (2^8 - 1) characters.

BLOB
TEXT
A BLOB or TEXT column with a maximum length of 65,535 (2^16 -1) characters.

MEDIUMBLOB
MEDIUMTEXT
A BLOB or TEXT column with a maximum length of 16,777,215 (2^24 - 1) characters.

LONGBLOB
LONGTEXT
A BLOB or TEXT column with a maximum length of 4,294,967,295 or 4GB (2^32 - 1) characters. Up to MySQL 3.23, the client/server protocol and MyISAM tables had a limit of 16MB per communication packet / table row. From MySQL 4.0, the maximum allowed length of LONGBLOB or LONGTEXT columns depends on the configured maximum packet size in the client/server protocol and available memory.
[/code]
Copy linkTweet thisAlerts:
@k0r54authorAug 13.2004 — The problem i am having is with what one to use. When i use text it dont alow parts of HTML but varchar does but only up to 255 ?

Im a bit lost on what to do
Copy linkTweet thisAlerts:
@solavarAug 13.2004 — Try BLOB

BLOB = "Binary Large OBject";
Copy linkTweet thisAlerts:
@Stephen_PhilbinAug 13.2004 — Why not just change the html characters into the sgml version when ya put 'em in yer database and convert them back when ya retrieve 'em?

So for example you write "&amp;" into the text box, then your script will convert "&amp;" into "&amp;amp;" when inserting it into the database, and reconverts it back from "&amp;amp;" to "&amp;" after retrieval. That would work for a text field wouldn't it?
×

Success!

Help @k0r54 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...