Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 23 Oct 2011, 13:59
Cory Megitt Cory Megitt is offline
 
Join Date: Aug 2011
php script to extract thread titles

I'm starting to program a php script to extract thread titles.
I am new to PHP but I'm learning ...


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

The output of this is:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Reply With Quote
  #2  
Old 23 Oct 2011, 14:32
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
I think the problem is the quotes you have around the column and table names. The quote character should be a backtick (`) and it looks like you have single quotes. (You don't really have to quote column and table names unless they have special characters).

Also, if you look at the page for mysql_query (http://us2.php.net/manual/en/function.mysql-query.php) under the Return Values section, you'll see that it can return FALSE if there's an error, so that's why your error message says that mysql_fetch_array() was expecting an array.
Reply With Quote
  #3  
Old 23 Oct 2011, 14:45
Cory Megitt Cory Megitt is offline
 
Join Date: Aug 2011
Originally Posted by kh99 View Post
I think the problem is the quotes you have around the column and table names. The quote character should be a backtick (`) and it looks like you have single quotes. (You don't really have to quote column and table names unless they have special characters).

Also, if you look at the page for mysql_query (http://us2.php.net/manual/en/function.mysql-query.php) under the Return Values section, you'll see that it can return FALSE if there's an error, so that's why your error message says that mysql_fetch_array() was expecting an array.
I've adjusted the line to read:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

I've adjusted the single quotes to backticks. I now have an output that looks like this:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Reply With Quote
  #4  
Old 23 Oct 2011, 15:03
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
That probably means it's working. The return from mysql_fetch_array() will be an array even if you are only selecting one column. So if you change your echo to $row['title'] you should see the titles.
Reply With Quote
  #5  
Old 23 Oct 2011, 15:11
setishock setishock is offline
 
Join Date: Feb 2008
Pardon my butting in but my curiosity is killing me. What would you use that for?
__________________
Working on new projects and expanding our horizons. Come by and see what we're up to now.
Reply With Quote
  #6  
Old 23 Oct 2011, 15:15
Cory Megitt Cory Megitt is offline
 
Join Date: Aug 2011
kh ... I get this now:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /Applications/XAMPP/xamppfiles/htdocs/mysql.php on line 10

setishock - The reason for this is to generate a report of thread titles from the 15th of each month to the 14th of each month.
Based on the data I have, it will populate an excel spreadsheet and make my monthly reporting for the manager a lot less time consuming.

It's only the start of what I want to have the script do.
Reply With Quote
  #7  
Old 23 Oct 2011, 15:17
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Originally Posted by Cory Megitt View Post
kh ... I get this now:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /Applications/XAMPP/xamppfiles/htdocs/mysql.php on line 10

That usually means that quotes are mismatched or something.
Reply With Quote
  #8  
Old 23 Oct 2011, 15:27
Cory Megitt Cory Megitt is offline
 
Join Date: Aug 2011

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

That's what it looks like -- and it appears to have proper quotes.
Reply With Quote
  #9  
Old 23 Oct 2011, 15:44
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Oh right. Sorry, change the echo line to


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Reply With Quote
  #10  
Old 23 Oct 2011, 16:14
Cory Megitt Cory Megitt is offline
 
Join Date: Aug 2011

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

This is the final and working script.

Thanks for the help kh99.
It worked.
Just need to figure out how to calculate the from date and to date properly as needed.
Reply With Quote
  #11  
Old 25 Oct 2011, 05:10
Judge Dredd X's Avatar
Judge Dredd X Judge Dredd X is offline
 
Join Date: Oct 2011
Location: Arizona
Real name: Dustin
I just wanted to let you know that this part:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Would output "Connected to MySQL" in addition to the mysql error if there is one.

So basically, if the connection fails, it will display the error and Connected to MySQL.

I am not very good at PHP, but I believe you could write an if statement for this.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

__________________
-- Microsuck --
Reply With Quote
  #12  
Old 25 Oct 2011, 05:16
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Originally Posted by Microsuck View Post
I just wanted to let you know that this part:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Would output "Connected to MySQL" in addition to the mysql error if there is one.
That's a good thought, but in the case of a connection error the echo line wouldn't execute because die() ends the script.
Reply With Quote
  #13  
Old 25 Oct 2011, 05:24
Judge Dredd X's Avatar
Judge Dredd X Judge Dredd X is offline
 
Join Date: Oct 2011
Location: Arizona
Real name: Dustin
Originally Posted by kh99 View Post
That's a good thought, but in the case of a connection error the echo line wouldn't execute because die() ends the script.
Ah!

So maybe instead of
Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

He could use
Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

?

Please don't bash me if the above doesn't work, I'm not experienced and I'm also not sure if "or" works with echo.
__________________
-- Microsuck --
Reply With Quote
  #14  
Old 28 Oct 2011, 19:40
kkinsey kkinsey is offline
 
Join Date: Oct 2011
not sure if "or" works with echo
It doesn't.

However, you can concatenate strings, vars, and function calls inside the die() statement:
Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

HTH,
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 05:15.

Layout Options | Width: Wide Color: