Jump to content


Photo

Hello there , new on mySQL and I am having errors already...


  • Please log in to reply
5 replies to this topic

#1 jimmyslam

jimmyslam
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 05 July 2006 - 01:58 PM


Ok i am having this error.

Fatal error: Call to a member function on a non-object in /datos/home/d177397/public_html/public_html/html/admin/view.php on line 14

And my code is

Vars!
<?

define ( "DB_SERVER", "x.x.x.x" );
define ( "DB", "d177397_news" );
define ( "DB_LOGIN", "user..." );
define ( "DB_PASSWORD", "pass..." );

?>



Connect!
<?

$db = mysql_connect(DB_SERVER, DB_LOGIN, DB_PASSWORD) or die("Could not connect: ".mysql_error());
mysql_select_db(DB) or die("Could not select database: ".mysql_error());

?>


<?
	include_once ("vars.php");
	include_once ("connect.php");
	

//ver infos de las tablas
//$sql->QueryRow("select * from news where 'ID'=0");
$sql->QueryRow("select * from news where 'ID'=1");


$row = $sql->data;

echo ("$row[ID]");
echo ("$row[date]");
echo ("$row[description]");
echo ("$row[links]");

mysql_close();
?>

What is going on?

I think the queryrow is wrongly used. I dont see what is the problem really...

Anyone help? Thanks


#2 Wildbug

Wildbug
  • Members
  • PipPipPip
  • Advanced Member
  • 1,149 posts

Posted 05 July 2006 - 02:13 PM

Which line is line 14?  This one:  "$row = $sql->data;"?

In this line -- $sql->QueryRow("select * from news where 'ID'=1"); -- I think ID shouldn't be in single quotes.  You don't really need anything around it, but you can use backticks if you really want to quote it.
Twice a day my clock works PERFECTLY!  I can't figure out what's wrong with it.

#3 king arthur

king arthur
  • Members
  • PipPipPip
  • Advanced Member
  • 335 posts
  • LocationUK HQ

Posted 05 July 2006 - 03:14 PM

Where are you setting up the $sql object, as it looks like that is where the error is coming from.
Sir Isaac Newton said "If I have seen farther, it is by standing on the shoulders of giants". But it is not recorded as to whether he said it before or after he was hit on the head by a falling apple.

#4 jimmyslam

jimmyslam
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 05 July 2006 - 04:40 PM

Well the error is in this line:

$sql->QueryRow("select * from news where 'ID'=1");

I think  i tried doing
$sql->QueryRow("select * from news where ID=1");
and didnt work either.


#5 Wildbug

Wildbug
  • Members
  • PipPipPip
  • Advanced Member
  • 1,149 posts

Posted 05 July 2006 - 07:54 PM

I agree w/ kingarthur; there's probably an error with the object creation.

But the 'ID'=1 was comparing a string to a number, not a column to a number.  It would always evaluate to FALSE and was, no doubt, not what you had intended.
Twice a day my clock works PERFECTLY!  I can't figure out what's wrong with it.

#6 jimmyslam

jimmyslam
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 06 July 2006 - 12:25 PM

I just followed other steps and is working now..

Thanks anyway! ;)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users