|
-
Apr 14th, 2003, 11:26 AM
#1
mysql database problem
I recently changed servers, and now when I try to access my guestbook, I keep getting this error:
Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /home/mendhak/public_html/guestbook/index.php on line 51
For some reason, mysql_numrows, is not... valid/recognized???
Here's the code:
PHP Code:
<?php
global $offset; // the string will be in the URL, say index.php?offset=9
if($offset==0 OR $offset==""){
$offset=0;
}
$dbh=mysql_connect("localhost", "mendhak_hello", "hello") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db("mendhak_thewebsite");
$displayperpage = 5; //set this variable to the number of records you want per page.
$sqloffset=$offset*$displayperpage;
$query="SELECT * FROM guestbook ORDER BY id DESC LIMIT $sqloffset,$displayperpage";
$countquery="SELECT COUNT(*) FROM guestbook";
$result=mysql_query($query);
$pagecount=mysql_query($countquery);
$rowsonthispage=mysql_numrows($result);
//[b][color=black]THIS IS LINE 51[/color][/b]
$tempcount = mysql_fetch_row($pagecount);
$num = $tempcount[0]; //now we have total records
Last edited by mendhak; Apr 14th, 2003 at 11:40 AM.
-
Apr 14th, 2003, 11:32 AM
#2
First thing I would do is findout what version of MySQL is running on the server, and then find out if the command in question is supported in that version.
-
Apr 14th, 2003, 02:09 PM
#3
Ok, it turned out to be a missing column in the table, which is why the argument being received was invalid.
Thanks anyways.
-
Apr 14th, 2003, 07:18 PM
#4
Stuck in the 80s
Re: mysql database problem
Originally posted by mendhak
For some reason, mysql_numrows, is not... valid/recognized???
Here's the code:
I know you fixed this already, but just a little FYI: that error is telling you that the supplied resource is not valid, not that the function itself is invalid.
So when you were missing your column, your mysql_query() was not returning a valid result.
-
Apr 15th, 2003, 12:41 AM
#5
Re: Re: mysql database problem
Originally posted by The Hobo
I know you fixed this already, but just a little FYI: that error is telling you that the supplied resource is not valid, not that the function itself is invalid.
So when you were missing your column, your mysql_query() was not returning a valid result.
Thanks for the info.
I had another question. On both servers, I had phpMyadmin (the web based mySQL admin thing).
Now, I was wondering if it's possible for me to take a backup of the database, along with the tables and values stored in it? I know how to do this in SQL Server, which is what I used previously. But I don't know how to do this in mySQL.
Any ideas?
-
Apr 17th, 2003, 11:31 AM
#6
Frenzied Member
first, mysql_numrows is deprecated and shouldn't be used.
second, in phpmyadmin there is a export link. just select what you want "structure and data" and save it as a zip or sql file. either way will be sql file when done. then just upload the sql file in the new phpmyadmin adn it will install everything.
-
Apr 17th, 2003, 11:54 AM
#7
Originally posted by phpman
second, in phpmyadmin there is a export link. just select what you want "structure and data" and save it as a zip or sql file. either way will be sql file when done. then just upload the sql file in the new phpmyadmin adn it will install everything.
I've done that before.... it' pretty handy for creating "backups".... depending on the size if the DB, you may want to do it inbatch of a few tables at a time. I had a problem once, where the host had a veryshort timeout period, and so tables that took a while to script (because of the #of rows), I got TO errors when I scripted them w/ other tables.
-
Apr 17th, 2003, 11:57 AM
#8
Frenzied Member
very true, if a very big database than you would want to do it one table at a time.
-
Apr 17th, 2003, 04:03 PM
#9
Stuck in the 80s
Originally posted by phpman
first, mysql_numrows is deprecated and shouldn't be used.
I'm going to invent a language so I can randomly deprecate functions and create new ones with extra underscores in them.
-
Apr 17th, 2003, 04:16 PM
#10
Frenzied Member
that's what is seems like huh? but in fact you can't even find it in the manual anymore so, deprecated, heck it is gone
-
Apr 17th, 2003, 04:19 PM
#11
Stuck in the 80s
Originally posted by phpman
that's what is seems like huh? but in fact you can't even find it in the manual anymore so, deprecated, heck it is gone
Indeed, although there is a reference to it under mysql_num_rows(), but that just says that it's deprecated.
-
Apr 17th, 2003, 04:50 PM
#12
Frenzied Member
-
Apr 18th, 2003, 03:05 AM
#13
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Apr 18th, 2003, 05:06 AM
#14
Alright,
if mysql_numrows() is depreciated, then what do I use instead?
It's important that I get the number of rows, after all, it's for the guestbook, and I do ned the 'sorting' scheme I'm implementing.
Second, I have winmysqladmin, which is a pain in the ass to say the least. Where can I get phpmyadmin from?
-
Apr 18th, 2003, 07:56 AM
#15
Frenzied Member
use mysql_num_rows()
and
www.phpmyadmin.net
-
Apr 18th, 2003, 10:43 AM
#16
Stuck in the 80s
Also in the downloadable .chm documentation.
-
Apr 18th, 2003, 12:49 PM
#17
Frenzied Member
that is funny, because I ooked at mysql.com and you would think they would now what is in there program and what is not. they dont' even list it.
-
Apr 19th, 2003, 05:07 AM
#18
Jeez, mysql_numrows() and mysql_num_rows() differ by one friggin' under_score. I really don't see what difference it makes, other than causing the inconvenience of having to change that single line in several pages of my site. (Thank you PHP.NET)
Thanks guys, I'll try out phpmyadmin.
-
Apr 19th, 2003, 07:51 AM
#19
Stuck in the 80s
Originally posted by phpman
that is funny, because I ooked at mysql.com and you would think they would now what is in there program and what is not. they dont' even list it.
phpman...mysql_num_rows() is a PHP function, not a native MySQL function.
-
Apr 19th, 2003, 07:58 AM
#20
In the old PHP API for mysql it was mysql_numrows(). Then the name was changed to mysql_num_rows() so that it is the same as the native mysql function that phpman found.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Apr 20th, 2003, 06:47 PM
#21
Member
may be error at server, my script is ok on this server but error at
other. report your problem to server admin
-
Apr 20th, 2003, 07:16 PM
#22
Stuck in the 80s
Originally posted by lejohn
may be error at server, my script is ok on this server but error at
other. report your problem to server admin
He already fixed his problem. Read the third post.
-
Aug 18th, 2003, 10:45 AM
#23
Fanatic Member
Undefined function mysql_connect
HI All
Since this thread is over a year aol and you guys know more php than I do, I wish to ask you this:
I have recently installed RH Linux 8 using the server installation option of the RH installer. PHP works fine and MySQL works fine. I have a problem when using MySQL connect in that an undefined function error is returned when i try to use:
VB Code:
$conn = mysql_connect("localhost");
I am logged in as a root user and there are no database permissions present yet. I think apache is not finding a module of sorts. Any help here would be really appreciated.
Thanks
Mike
-
Aug 18th, 2003, 10:54 AM
#24
Frenzied Member
what version of php are you using? and you really should start another thread.
-
Aug 18th, 2003, 10:54 AM
#25
Frenzied Member
what version of php are you using? and you really should start another thread.
-
Aug 19th, 2003, 04:36 AM
#26
Fanatic Member
new thread
Sorry about the posting , but you can find the new thread here
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|