Welcome to Dream.In.Code
Become a PHP Expert!

Join 149,915 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 2,165 people online right now. Registration is fast and FREE... Join Now!




Bad Link Resource,

2 Pages V  1 2 >  
Reply to this topicStart new topic

Bad Link Resource,, This is making me mad.

max302
7 Dec, 2006 - 04:50 PM
Post #1

Proud supporter of the lulz
Group Icon

Joined: 5 Mar, 2006
Posts: 1,281


Dream Kudos: 200
My Contributions
So far, I have this, which is supposed to work:
CODE
<?PHP
include("./includes/main.php");
get_header("Home");

get_menu();

echo "<div class='news'> \n
      <h3>News:</h3> \n
      <table class='news'> \n";
$news_query = mysql_query("SELECT content FROM pmdbs_news WHERE 1 SORT BY date", $db_handle);
for ($news_counter = 0;$news_counter <= $config['max_news'];$news_counter++)
{
$news_title = mysql_result($news_query,"title",$news_counter);
$news_content = mysql_result($news_query,"content",$news_counter);
$news_date = mysql_result($news_query,"date",$news_counter);
echo "<tr class='news_title'> \n
        <td>".$news_title."</td> \n
       </tr> \n
       <tr class='news_date'> \n
        <td>".$news_date."</td> \n
       </tr> \n
       <tr class='news_content'> \n  
        <td>".$news_content."</td> \n
       </tr>";
}


get_footer();

?>


And, I get:
CODE
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in C:\Program Files\xampp\htdocs\pmdbs\index.php on line 10

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\pmdbs\index.php on line 13

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\pmdbs\index.php on line 14

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\pmdbs\index.php on line 15

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\pmdbs\index.php on line 13

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\pmdbs\index.php on line 14

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\pmdbs\index.php on line 15

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\pmdbs\index.php on line 13

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\pmdbs\index.php on line 14

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\pmdbs\index.php on line 15

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\pmdbs\index.php on line 13

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\pmdbs\index.php on line 14

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\pmdbs\index.php on line 15

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\pmdbs\index.php on line 13

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\pmdbs\index.php on line 14

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\pmdbs\index.php on line 15

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\pmdbs\index.php on line 13

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\pmdbs\index.php on line 14

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\pmdbs\index.php on line 15


ARGH! I point to my query ok, so what's up with that?
BTW, don't worry about the mysql connection being started, that is done in an include file via main.php.

I have tried declaring all my mysql stuff on the page you can find at the top, and still no results. The password is ok, the connection is fine (it seems), but friggin mysql result won't find the query! Whats up with that?
User is offlineProfile CardPM
+Quote Post

callumj
RE: Bad Link Resource,
7 Dec, 2006 - 05:00 PM
Post #2

New D.I.C Head
*

Joined: 8 Jan, 2006
Posts: 14


My Contributions
It appears that your query isn't proper, have you check out the query phpMyAdmin or mysql on the command line?

"SELECT content FROM pmdbs_news WHERE 1 SORT BY date"

"WHERE 1 SORT BY date", doesn't look too good in syntax.
User is offlineProfile CardPM
+Quote Post

max302
RE: Bad Link Resource,
7 Dec, 2006 - 05:07 PM
Post #3

Proud supporter of the lulz
Group Icon

Joined: 5 Mar, 2006
Posts: 1,281


Dream Kudos: 200
My Contributions
Yes, there was an error there, thanks for pointing it out. The query is now

SELECT content
FROM pmdbs_news
WHERE 1
ORDER BY date

Still, the error messages remain.
User is offlineProfile CardPM
+Quote Post

callumj
RE: Bad Link Resource,
7 Dec, 2006 - 05:13 PM
Post #4

New D.I.C Head
*

Joined: 8 Jan, 2006
Posts: 14


My Contributions
the WHERE 1 appears to be alone, shouldn't you be doing something with it, not just leaving a 1?
User is offlineProfile CardPM
+Quote Post

BetaWar
RE: Bad Link Resource,
7 Dec, 2006 - 08:42 PM
Post #5

#include <soul.h>
Group Icon

Joined: 7 Sep, 2006
Posts: 2,293



Thanked: 101 times
Dream Kudos: 1275
My Contributions
WHERE 1 makes no sence to anything, including me. If you want to have an an argument that the computer will better understand try using this:

WHERE table_row=1
User is offlineProfile CardPM
+Quote Post

max302
RE: Bad Link Resource,
8 Dec, 2006 - 08:35 AM
Post #6

Proud supporter of the lulz
Group Icon

Joined: 5 Mar, 2006
Posts: 1,281


Dream Kudos: 200
My Contributions
Where 1 actually means where is not 0, or where exists. It does make sense, and phpmyadmin returns some info when I run it on the query tool.
User is offlineProfile CardPM
+Quote Post

snoj
RE: Bad Link Resource,
9 Dec, 2006 - 04:02 PM
Post #7

Fell off the face of the earth
Group Icon

Joined: 31 Mar, 2003
Posts: 3,325



Thanked: 9 times
Dream Kudos: 750
My Contributions
have you tried adding or die(mysql_error()) after mysql_query() and before the ; on that line?
User is online!Profile CardPM
+Quote Post

MathewS
RE: Bad Link Resource,
9 Dec, 2006 - 05:32 PM
Post #8

D.I.C Regular
***

Joined: 14 May, 2002
Posts: 252



Thanked: 1 times
Dream Kudos: 1
My Contributions
The error lies with $db_handle

Can you show the code you are using to connect to the DB?
User is offlineProfile CardPM
+Quote Post

BetaWar
RE: Bad Link Resource,
9 Dec, 2006 - 06:12 PM
Post #9

#include <soul.h>
Group Icon

Joined: 7 Sep, 2006
Posts: 2,293



Thanked: 101 times
Dream Kudos: 1275
My Contributions
Well you are using the ORDER BY function try something like so:

ORDER BY date

Then add either ASC or DESC to the end

User is offlineProfile CardPM
+Quote Post

manilodisan
RE: Bad Link Resource,
10 Dec, 2006 - 01:00 PM
Post #10

New D.I.C Head
*

Joined: 10 Dec, 2006
Posts: 2


My Contributions
WHERE 1 (Who is 1?)
User is offlineProfile CardPM
+Quote Post

snoj
RE: Bad Link Resource,
10 Dec, 2006 - 02:38 PM
Post #11

Fell off the face of the earth
Group Icon

Joined: 31 Mar, 2003
Posts: 3,325



Thanked: 9 times
Dream Kudos: 750
My Contributions
WHERE 1 is a valid statement since 1 is true, it's an expression, just like if(1) in PHP (or any language). Since every row exists and so is "true", they are returned.
User is online!Profile CardPM
+Quote Post

alpha02
RE: Bad Link Resource,
29 Dec, 2006 - 01:30 PM
Post #12

D.I.C Addict
Group Icon

Joined: 20 May, 2006
Posts: 687


Dream Kudos: 850
My Contributions
QUOTE(hotsnoj @ 10 Dec, 2006 - 03:38 PM) *

WHERE 1 is a valid statement since 1 is true, it's an expression, just like if(1) in PHP (or any language). Since every row exists and so is "true", they are returned.


That's right. However, I personnally omitted the "WHERE 1" condition, because if no condition is specified then all rows are returned. You can just use:
$query = mysql_query ("SELECT * FROM table ORDER BY column", $conn)
It works, it selects all rows. What I suggest you to try is :

"SELECT * FROM pmdbs_news ORDER BY date DESC"

You have nothing to lose if you use the * column name rather than the real name.

Did you solve your problem?
User is offlineProfile CardPM
+Quote Post

2 Pages V  1 2 >
Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 02:13PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month