Riboflavin1 Posted November 16, 2010 Share Posted November 16, 2010 Hello all, I have followed the stop on this page to what I thought was a tee: http://www.inkplant.com/code/pull-tw...-your-site.php but I guess I was wrong because I am getting errors. I have setup the database and table properly and created all files, but when I do step 4 and place the code on my site I am getting this error Fatal error: Call to undefined function dbQuery() The api pull went fine and it stored the tweets in the database, but it can't display them. Is there a missing step about connecting to the database somewhere? Thanks for any help Quote Link to comment https://forums.phpfreaks.com/topic/218861-twitter-api-script-failing-to-display/ Share on other sites More sharing options...
defeated Posted November 16, 2010 Share Posted November 16, 2010 It looks like you hit the nail on the head there Riboflavin! It's hard to tell without seeing the code (link doesn't work), but somewhere you have (or should have) a function called dbQuery(). It's not finding that. If your db is populating then you have got the hard bit done already. You could just find where the dbQuery() function is being called and write your own query there instead. Quote Link to comment https://forums.phpfreaks.com/topic/218861-twitter-api-script-failing-to-display/#findComment-1135055 Share on other sites More sharing options...
Riboflavin1 Posted November 16, 2010 Author Share Posted November 16, 2010 Gah, how did I mess that up. Try this: http://www.inkplant.com/code/pull-twitter-feed-into-your-site.php Quote Link to comment https://forums.phpfreaks.com/topic/218861-twitter-api-script-failing-to-display/#findComment-1135066 Share on other sites More sharing options...
defeated Posted November 16, 2010 Share Posted November 16, 2010 You're missing your DB connection. <?php //connect to database mysql_connect("localhost", "Username", "password") or die(mysql_error()); //connect to specific table mysql_select_db("twitter") or die(mysql_error()); ?> I usually put my connection into a separate file called something like dbconnect.php and use the line include('dbconnect.php'); at the start of my page. You can just put the code into your page before the "$result = dbQuery("SELECT * FROM `twitter`....." line. You will also have to change the screen_name from inkplant to your own screen name. On most sites leaving "localhost" is the correct server address, but now always. Your username and password were set when you created your db. Hope that sorts it for you. Quote Link to comment https://forums.phpfreaks.com/topic/218861-twitter-api-script-failing-to-display/#findComment-1135074 Share on other sites More sharing options...
Riboflavin1 Posted November 17, 2010 Author Share Posted November 17, 2010 Hm, the code I have on the display page now is this: <?php //connect to database mysql_connect("localhost", "user_twit", "password") or die(mysql_error()); //connect to specific table mysql_select_db("user_twitter") or die(mysql_error()); require_once 'db-functions.inc.php' ; //custom database functions $result = dbQuery("SELECT * FROM `twitter` WHERE `screen_name`='name' AND `hidden` != 'y' ORDER BY `time` DESC LIMIT 3"); while ($row = dbGetRow($result)) { $text = stripslashes($row['text']); $time = $row['time']; echo "<li>".date('M j, Y, g:i a',$time)." · $text</li>\n" ; } ?> But now it is giving this error: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/user/public_html/db-functions.inc.php on line 29 Warning: mysql_error(): supplied argument is not a valid MySQL-Link resource in /home/user/public_html/db-functions.inc.php on line 29 Error: Database error! Sorry for being so noob, but mysql errors are pretty foreign to me. Quote Link to comment https://forums.phpfreaks.com/topic/218861-twitter-api-script-failing-to-display/#findComment-1135291 Share on other sites More sharing options...
defeated Posted November 17, 2010 Share Posted November 17, 2010 I don't know what's in it or what else may be using it but try removing the line require_once 'db-functions.inc.php' ; //custom database functions which should really be require_once('db-functions.inc.php') ; //custom database functions anyway and see what happens. Something in that file there is making mysql unhappy (on line 29). If that doesn't work (or breaks something else) post line 29 from db-functions.inc.php and we will see what will be. Although I won't for now cuz I'm off to bed! Quote Link to comment https://forums.phpfreaks.com/topic/218861-twitter-api-script-failing-to-display/#findComment-1135301 Share on other sites More sharing options...
Riboflavin1 Posted November 17, 2010 Author Share Posted November 17, 2010 I removed it and it goes back to the original error Fatal error: Call to undefined function dbQuery() I thought maybe including that file might have the function but I guess not. Any Ideas? Quote Link to comment https://forums.phpfreaks.com/topic/218861-twitter-api-script-failing-to-display/#findComment-1135314 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.