|
List Info
Thread: MySQL problem
|
|
| MySQL problem |

|
2007-12-16 18:57:48 |
Hi, Im running into a problem that I dont know how to get
by. I keep
on getting this error:
Warning: mysql_fetch_assoc(): supplied argument is not a
valid MySQL
result resource in C:wampwwwxcvidsindex.php on line 8
Here is my code:
<?php
require("header.php");
$sql = "SELECT entries.*, categories.cat FROM entries,
categories
WHERE entries.cat_id = categories.id
ORDER BY dateposted DESC
LIMIT 1;";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
echo "<h2><a href='viewentry.php?id=" .
$row['id']. "'>" .
$row['subject'] ."</a></h2><br
/>";
require("footer.php");
?>
The interface and everything is displaying properly, but Im
getting
that error instead of the content I want to show. Anyone
know whats
going on? (Im really new to php and sql)
thanks in advance!
J
--~--~---------~--~----~------------~-------~--~----~
This group is managed and maintained by the development
staff at 360 PSG. An enterprise application development
company utilizing open-source technologies for todays
small-to-medium size businesses.
For information or project assistance please visit :
http://www.360psg.com
You received this message because you are subscribed to the
Google Groups "Professional PHP Developers"
group.
To post to this group, send email to Professional-PHP googlegroups.com
To unsubscribe from this group, send email to
Professional-PHP-unsubscribe googlegroups.com
For more options, visit this group at http:
//groups.google.com/group/Professional-PHP
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: MySQL problem |

|
2007-12-16 20:43:32 |
|
Hii james ,
Mysql_fetch_assoc is same as mysql_fetch_array .the function is no problem, suppose i will check ur code i dont have ur database ..
i think problem in ur sql query thats why this error come. just print in sql query and check in local phpmyadmin
<?php require("header.php"); $sql = "SELECT entries.*,
categories.cat FROM entries, categories WHERE entries.cat_id = categories.id ORDER BY dateposted DESC LIMIT 1;";
echo $sql; //print it and check it $result = mysql_query($sql); $row = mysql_fetch_assoc($result); echo "<h2><a href='viewentry.php?id=" . $row['id']. "';>" .
$row[39;subject'] ."</a></h2><br />"; require("footer.php"); ?>
and always check database connection,
On 16/12/2007, James < trialstyles gmail.com">trialstyles gmail.com> wrote:
Hi, Im running into a problem that I dont know how to get by. I keep on getting this error:
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:wampwwwxcvidsindex.php on line 8
Here is my code: <?php require("header.php"); $sql = "SELECT entries.*, categories.cat FROM entries, categories WHERE entries.cat_id = categories.id
ORDER BY dateposted DESC LIMIT 1;"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); echo "<h2><a href='viewentry.php?id=" . $row['id']. "';>" .
$row[39;subject'] ."</a></h2><br />"; require("footer.php"); ?>
The interface and everything is displaying properly, but Im getting that error instead of the content I want to show. Anyone know whats
going on? (Im really new to php and sql)
thanks in advance! J
-- ♥ <º))))><.·´¯`·. ¯|¯hê ßÕ§§ Thãñj觸.·´`·.¸><((((º>♥
•°¤*(¯`°(ßåch飨® Õƒ §oftwå®ê §è®v좣)°´¯)*¤°•
--~--~---------~--~----~------------~-------~--~----~
This group is managed and maintained by the development staff at 360 PSG. An enterprise application development company utilizing open-source technologies for todays small-to-medium size businesses.
For information or project assistance please visit :
http://www.360psg.com
You received this message because you are subscribed to the Google Groups "Professional PHP Developers" group.
To post to this group, send email to Professional-PHP googlegroups.com
To unsubscribe from this group, send email to Professional-PHP-unsubscribe googlegroups.com
For more options, visit this group at http://groups.google.com/group/Professional-PHP -~----------~----~----~----~------~----~------~--~---
|
| Re: MySQL problem |

|
2007-12-16 21:30:48 |
|
| Ensure you have a valid connection to MySQL, and possibly remove that ; in the string.
The best way to connect to MySQL is by assigning the resource ID to a variable, such as:
<?php
$link = mysql_connect("localhost", "user", "pass") or die(mysql_error());
mysql_select_db("db_name", $link) or die(mysql_error());
// will print "output" the active resource ID if one was established
// if this value is not valid, make sure the MySQL server is properly running. print "Active Database Resource: " . $link;
// remainder of code here ...
?>
Hope that helps. On 12/16/07, ♥ Ѐ ÕÑê & ÕÑ£¥ Thãñjè§ Hè®è ♥ <
thanjeys gmail.com">thanjeys gmail.com> wrote: Hii james ,
Mysql_fetch_assoc is same as mysql_fetch_array .the function is no problem,
suppose i will check ur code i dont have ur database ..
i think problem in ur sql query thats why this error come. just print in sql query and check in local phpmyadmin
<?php require("header.php
"); $sql = "SELECT entries.*,
categories.cat FROM entries, categories WHERE entries.cat_id = categories.id ORDER BY dateposted DESC LIMIT 1;";
echo $sql; //print it and check it $result = mysql_query($sql); $row = mysql_fetch_assoc($result); echo "<h2><a href='viewentry.php
?id=" . $row['id']. "';>" .
$row[39;subject'] ."</a></h2><br />"; require("footer.php"); ?>
and always check database connection,
On 16/12/2007, James < trialstyles gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
trialstyles gmail.com> wrote:
Hi, Im running into a problem that I dont know how to get by. I keep on getting this error:
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:wampwwwxcvidsindex.php on line 8
Here is my code: <?php require("header.php"); $sql = "SELECT entries.*, categories.cat FROM entries, categories WHERE entries.cat_id =
categories.id
ORDER BY dateposted DESC LIMIT 1;"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); echo "<h2><a href='viewentry.php?id=" . $row['id']. "';>" .
$row[39;subject'] ."</a></h2><br />"; require("footer.php"); ?>
The interface and everything is displaying properly, but Im getting that error instead of the content I want to show. Anyone know whats
going on? (Im really new to php and sql)
thanks in advance! J
-- ♥ <º))))><.·´¯`·. ¯|¯hê ßÕ§§ Thãñj觸.·´`·.¸><((((º>♥
°¤*(¯`(ßåch騮 Õƒ §oftwå®ê §è®v좣)°´¯)*¤°•
--~--~---------~--~----~------------~-------~--~----~
This group is managed and maintained by the development staff at 360 PSG. An enterprise application development company utilizing open-source technologies for todays small-to-medium size businesses.
For information or project assistance please visit :
http://www.360psg.com
You received this message because you are subscribed to the Google Groups "Professional PHP Developers" group.
To post to this group, send email to Professional-PHP googlegroups.com
To unsubscribe from this group, send email to Professional-PHP-unsubscribe googlegroups.com
For more options, visit this group at http://groups.google.com/group/Professional-PHP -~----------~----~----~----~------~----~------~--~---
|
| Re: MySQL problem |

|
2007-12-16 22:09:50 |
Turns out it wasn't connecting to the database, your method
worked
well though!
thanks guys!
On Dec 16, 8:30 pm, mkeefe <mke... gmail.com> wrote:
> Ensure you have a valid connection to MySQL, and
possibly remove that ; in
> the string.
> The best way to connect to MySQL is by assigning the
resource ID to a
> variable, such as:
>
> <?php
>
> $link = mysql_connect("localhost",
"user", "pass") or die(mysql_error());
> mysql_select_db("db_name", $link) or
die(mysql_error());
>
> // will print "output" the active resource ID
if one was established
> // if this value is not valid, make sure the MySQL
server is properly
> running.
> print "Active Database Resource: " . $link;
>
> // remainder of code here
> ...
>
> ?>
>
> Hope that helps.
>
> On 12/16/07, ♥ Ѐ ÕÑê & ÕÑ£¥
Thãñj襧 Hè(R)è ♥ <thanj... gmail.com> wrote:
>
>
>
> > Hii james ,
>
> > Mysql_fetch_assoc is same as
mysql_fetch_array .the
> > function is no problem,
> > suppose i will check ur code i dont have ur
database ..
>
> > i think problem in ur sql query thats why this
error come.
> > just print in sql query and check in local
phpmyadmin
>
> > <?php
> > require("header.php");
> > $sql = "SELECT entries.*, categories.cat FROM
entries, categories
> > WHERE entries.cat_id = categories.id
> > ORDER BY dateposted DESC
> > LIMIT 1;";
> > echo $sql; //print it and check it
> > $result = mysql_query($sql);
> > $row = mysql_fetch_assoc($result);
> > echo "<h2><a
href='viewentry.php?id=" . $row['id'].
"'>" .
> > $row['subject'] ."</a></h2><br
/>";
> > require("footer.php");
> > ?>
>
> > and always check database connection,
>
> > On 16/12/2007, James <trialsty... gmail.com> wrote:
>
> > > Hi, Im running into a problem that I dont
know how to get by. I keep
> > > on getting this error:
>
> > > Warning: mysql_fetch_assoc(): supplied
argument is not a valid MySQL
> > > result resource in
C:wampwwwxcvidsindex.php on line 8
>
> > > Here is my code:
> > > <?php
> > > require("header.php");
> > > $sql = "SELECT entries.*, categories.cat
FROM entries, categories
> > > WHERE entries.cat_id = categories.id
> > > ORDER BY dateposted DESC
> > > LIMIT 1;";
> > > $result = mysql_query($sql);
> > > $row = mysql_fetch_assoc($result);
> > > echo "<h2><a
href='viewentry.php?id=" . $row['id'].
"'>" .
> > > $row['subject']
."</a></h2><br />";
> > > require("footer.php");
> > > ?>
>
> > > The interface and everything is displaying
properly, but Im getting
> > > that error instead of the content I want to
show. Anyone know whats
> > > going on? (Im really new to php and sql)
>
> > > thanks in advance!
> > > J
>
> > --
> > ♥ <º))))><.·´¯`·. ¯|¯hê
ßÕ§§ Thãñj襧¸.·´¯`·.¸><((((º>♥
>
> > •°¤*(¯`°(ßåch飨(R) Õƒ §oftwå(R)ê
§è(R)v좣)°´¯)*¤°•
--~--~---------~--~----~------------~-------~--~----~
This group is managed and maintained by the development
staff at 360 PSG. An enterprise application development
company utilizing open-source technologies for todays
small-to-medium size businesses.
For information or project assistance please visit :
http://www.360psg.com
You received this message because you are subscribed to the
Google Groups "Professional PHP Developers"
group.
To post to this group, send email to Professional-PHP googlegroups.com
To unsubscribe from this group, send email to
Professional-PHP-unsubscribe googlegroups.com
For more options, visit this group at http:
//groups.google.com/group/Professional-PHP
-~----------~----~----~----~------~----~------~--~---
|
|
[1-4]
|
|