Jump to content

Twitter API script failing to display


Riboflavin1

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.