View Full Version : mySQL Errors
nickut
02-25-2002, 10:11 PM
I am attempting to get a php script to work with mySQL. However, I continue to receive an error that I am unfamilar with:
Warning: Supplied argument is not a valid MySQL-Link resource in /home/wxquest/public_html/PHP/content/headlines.php on line 10
Warning: Supplied argument is not a valid MySQL result resource in /home/wxquest/public_html/PHP/content/headlines.php on line 12
Can anyone help me with this and what it means exactly?
Thanks.
fatal
02-25-2002, 11:40 PM
give some code above and below line 29 :)
Damian
02-26-2002, 12:05 AM
Yes please post some code.
BTW, fellow Austin TX'er here :)
D
nickut
02-26-2002, 02:04 AM
Sorry...my head is not all there at the moment!
Here is the entire code:
1 <?php
2
3 include "include_fns.php";
4 include "header.php";
5
6 $conn = db_connect();
7
8
9 $pages_sql = "select * from pages order by code";
10 $pages_result = mysql_query($pages_sql, $conn);
11
12 while ($pages = mysql_fetch_array($pages_result)) {
13
14 $story_sql = "select * from stories
15 where page = '$pages[code]'
16 and published is not null
17 order by published desc";
18 $story_result = mysql_query($story_sql, $conn);
19 if (mysql_num_rows($story_result)) {
20 $story = mysql_fetch_array($story_result);
21 print "<TABLE BORDER=0 WIDTH=400>";
22 print "<TR>";
23 print "<TD ROWSPAN=2 WIDTH=100>";
24 if ($story[picture])
25 print "<IMG SRC=\"resize_image.php?image=$story[picture]\">";
26 print "</TD>";
27 print "<TD>";
28 print "<H3>$pages[description]</H3>";
29 print $story[headline];
30 print "</TD>";
31 print "</TR>";
32 print "<TR><TD ALIGN=RIGHT>";
33 print "<A HREF=\"page.php?page=$pages[code]\">";
34 print "<FONT SIZE=1>Read more $pages[code] ...</FONT>";
35 print "</A>";
36 print "</TABLE>";
37 }
38 }
include "footer.php";
?>
Thanks for the help!
--> and Damian...a Longhorn I would hope!?!
Stewart
02-26-2002, 01:45 PM
the error you're getting tends to mean that there is either no table, column or row that you are trying to request.
nickut
02-26-2002, 02:40 PM
That was my first thought as to what is occurring, but all the appropriate tables, rows and columns are there with correct names and case. Very strange I must say...but then again something must be wrong?!
fatal
02-26-2002, 07:04 PM
6 $conn = db_connect();
what does that function return?
nickut
02-26-2002, 07:27 PM
It's basically supposed to make sure that the database is connected.
But..what I have been trying to do and as you can tell quite unsuccesful is exactly what you have on your site fatal.
From you page http://www.fataldesigns.com/v4/ you have links int he flash header that go to other pages (i.e. members) but the link is http://www.theascendancy.net/v4/index.php?section=members thus using the same general page layout as the main page. I want to setup a system like this on my site, where php will pull the appropriate content from the database based on the url extensions (i.e. ?section=members) of the link and apply it to the default page design 'index.php'.
Do you know of an easy way to do this or know about an online tutorial somewhere because the way that I'm approaching this is obviously NOT working.
Thanks!!
fatal
02-28-2002, 04:56 PM
http://www.fataldesigns.com/v4/ does not use a database, that was one of my first sites using php and simple includes.
http://www.fataldesings.com/md/ fully utilizes an Access2000 database
http://www.alanpowell.net/ fully utilizes MySQL database
Both those have the construct you're looking for, as in ?secion=mysection but also integrates database for data storage, retrieval, and organization.
The logic is really simple for the includes:
if ($section == "home") {
include("scripts/home.php"); }
else if ($section == "news") {
include("scripts/news.php"); }
else if ($section == "somesection") {
include("scripts/somesection.php"); }
else { include("scripts/home.php"); }
if you always have file names same as the variable (Ex. $section variable has the same name as the file being include), you could just use:
if (file_exists("scripts/$section.php")) include("scripts/$section.php");
else include("scripts/home.php");
All that does is the inclusion of certain scripts depending on the $section variable, all the database stuff is handled in the scripts its calling.
Hope that helps and if thats what you were lookin for :p
nickut
03-01-2002, 07:05 PM
Thanks fatal...that's pretty much what I am looking for!
vBulletin® v3.7.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.