jimmyslam Posted July 5, 2006 Share Posted July 5, 2006 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 14And my code isVars![code]<?define ( "DB_SERVER", "x.x.x.x" );define ( "DB", "d177397_news" );define ( "DB_LOGIN", "user..." );define ( "DB_PASSWORD", "pass..." );?>[/code]Connect![code]<?$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());?>[/code][code]<? 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();?>[/code]What is going on?I think the queryrow is wrongly used. I dont see what is the problem really...Anyone help? Thanks Link to comment https://forums.phpfreaks.com/topic/13734-hello-there-new-on-mysql-and-i-am-having-errors-already/ Share on other sites More sharing options...
Wildbug Posted July 5, 2006 Share Posted July 5, 2006 Which line is line 14? This one: "$row = $sql->data;"?In this line -- [b]$sql->QueryRow("select * from news where 'ID'=1");[/b] -- 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. Link to comment https://forums.phpfreaks.com/topic/13734-hello-there-new-on-mysql-and-i-am-having-errors-already/#findComment-53333 Share on other sites More sharing options...
king arthur Posted July 5, 2006 Share Posted July 5, 2006 Where are you setting up the $sql object, as it looks like that is where the error is coming from. Link to comment https://forums.phpfreaks.com/topic/13734-hello-there-new-on-mysql-and-i-am-having-errors-already/#findComment-53372 Share on other sites More sharing options...
jimmyslam Posted July 5, 2006 Author Share Posted July 5, 2006 Well the error is in this line:[code]$sql->QueryRow("select * from news where 'ID'=1");[/code]I think i tried doing[code]$sql->QueryRow("select * from news where ID=1");[/code]and didnt work either. Link to comment https://forums.phpfreaks.com/topic/13734-hello-there-new-on-mysql-and-i-am-having-errors-already/#findComment-53416 Share on other sites More sharing options...
Wildbug Posted July 5, 2006 Share Posted July 5, 2006 I agree w/ kingarthur; there's probably an error with the object creation.But the 'ID'=1 was comparing a [i]string[/i] to a number, not a column to a number. It would always evaluate to FALSE and was, no doubt, not what you had intended. Link to comment https://forums.phpfreaks.com/topic/13734-hello-there-new-on-mysql-and-i-am-having-errors-already/#findComment-53536 Share on other sites More sharing options...
jimmyslam Posted July 6, 2006 Author Share Posted July 6, 2006 I just followed other steps and is working now..Thanks anyway! ;) Link to comment https://forums.phpfreaks.com/topic/13734-hello-there-new-on-mysql-and-i-am-having-errors-already/#findComment-53825 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.