I'm getting the error below, i've printed out the SQL query and its fine, it also works in the DB, SELECT sub_id,type FROM comments WHERE id='103' LIMIT 1, any ideas?
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Apache\htdocs\config\sql.php on line 798
This is the code: - function getCommentLink($id) {
-
$link = "";
-
$type = "";
-
-
$sql = "SELECT sub_id,type FROM comments WHERE id='".$id."' LIMIT 1";
-
echo $sql;
-
$sql = mysql_query($sql);
-
while ($row = mysql_fetch_array($sql)) //Line 798
-
{
-
$type = $row['type'];
-
$sql = mysql_query("SELECT id,title FROM ".$row['type']." WHERE id='".$row['sub_id']."' LIMIT 1");
-
while ($row = mysql_fetch_array($sql))
-
{
-
if($type == "news")
-
{
-
$type = "article-news";
-
}
-
else if($type == "reviews")
-
{
-
$type = "article-reviews";
-
}
-
else if($type == "previews")
-
{
-
$type = "article-previews";
-
}
-
-
$link = "../../../".$type."/".$row['id']."-".preg_replace('#[^a-zA-Z0-9]+#','-',$row['title']).".htm";
-
}
-
}
-
return $link;
-
}
5 1115
Is 'sub_id' and INT column? If so, you shouldn't have quotes around the value. -
$sql = "SELECT sub_id,type FROM comments WHERE id={$id}"
-
Thanks,
Markus.
It is an int column but i have commas around it for extra security against SQL injection attacks.
Got it sorted, had the db connect function after the sql statement.
Line 27 is just ugly, ugly, ugly, btw.
You should have a couple of constants defined in your application that point to various locations. That way, you don't need to use '../', etc,. to find the right directory. Something like.. -
define("ART_PATH", "/html/your-site.com/html_docs/articles/");
-
Then you can get to 'articles' easily and neatly.
Thanks,
Markus.
I know its terrible, I'm going to sort all those constants out once i get the system working properly, just a bit of jigging about, thanks for the feedback.
@ziycon
Jolly good!
Glad you got it sorted,
Markus.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: johnnyboy10017 |
last post by:
I am having a hell of a time with what I think is a very simple query:
It won't actually insert a new record into the specified table, but
returns no error, in fact it returns "1" (or true) that...
|
by: jaysonsch |
last post by:
Hello!
I am having some problems with a database query that I am trying to do.
I am trying to develop a way to search a database for an entry and
then edit the existing values. Upon submit, the...
|
by: Sean C. |
last post by:
Helpful folks,
I have recently migrated our test server, which runs Win NT 4, from
V7.2 FP11 to V8.1.3. Just about everything works wondefully, except I
am having major problems getting the...
|
by: Mal |
last post by:
Greetings.
I have a perplexing problem....please help.
I am having a problem with an insert query. (SQL below)
When I run the query via code (executing the SQL string) it crashes
Access and...
|
by: Adam Louis |
last post by:
I would like help resolving this problem. I'm a novice who's been
hired to query a hospital database and extract useful information,
available to me only in a dynamically generated, downloadable...
|
by: Martin Lacoste |
last post by:
Ok, before I headbutt the computer... don't know why when I add
criteria in a query, I get an 'invalid procedure call'. I also don't
know why after searching the help in access, the various access...
|
by: John Øllgård Jensen |
last post by:
Hi
Using MS Asccess 2000:
In a query I'm trying to create a new field with following expression:
FilmDate: Left(,4)
The field "FilmNo" is another text field in the query.
This is...
|
by: ARC |
last post by:
Hello all,
So I'm knee deep in this import utility program, and am coming up with all
sorts of "gotcha's!".
1st off. On a "Find Duplicates Query", does anyone have a good solution for...
|
by: QCLee |
last post by:
Sir can you help me to transfer my Access Query to MS excel? i have a
command button on the form to export the parameter query named
"HVACWindwardQuery" to excel spreadsheet and i got the codes...
|
by: dizzydangler |
last post by:
Hi, all! After receiving a lot of help from ADezzi, Msquared, and NeoPa getting my ms access 2007 db functioning, I've run into another hitch that I haven't been able to solve. The database itself...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |