vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   I am getting a blank page/no error with this code: (https://vborg.vbsupport.ru/showthread.php?t=68695)

Doc203 08-25-2004 12:50 PM

I am getting a blank page/no error with this code:
 
I am learning php and I am trying to get this php script to return a result when called by a browser. Can someone look at it and give me a hand?

PHP Code:

$start_date "2004-08-01 00:00:00";
$end_date "2004-08-23 00:00:00";

$result $DB_site->query("SELECT COUNT(post.postid) AS count, user.username
FROM post
LEFT JOIN user ON (user.userid = post.userid)
AND (UNIX_TIMESTAMP('
$start_date')) <= post.dateline
AND post.dateline <= (UNIX_TIMESTAMP('end_date'))
GROUP BY user.userid ORDER BY count DESC, username"
); 


Xenon 08-26-2004 06:38 AM

Code:

(UNIX_TIMESTAMP('end_date'))
you've missed a $ before end_date ;)

Doc203 08-26-2004 04:02 PM

Thanks Xenon, I have added a line also so I could find out a little more and here is what I get now:

"I failed and here is why: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #14' at line 1
"

If I run the query directly in Mysql it returns the results correctly. Any ideas? Thanks for the help!


Quote:

<?PHP
require("./global.php");

$start_date = "2004-08-01 00:00:00";
$end_date = "2004-08-23 00:00:00";

$stmt = $DB_site->query("SELECT COUNT(post.postid) AS count, user.username
FROM post
LEFT JOIN user ON (user.userid = post.userid)
AND (UNIX_TIMESTAMP('$start_date')) <= post.dateline
AND post.dateline <= (UNIX_TIMESTAMP('$end_date'))
GROUP BY user.userid ORDER BY count DESC, username");

$sr = mysql_query($stmt) or die ("<p>I failed and here is why: " . mysql_error());

?>

Xenon 08-27-2004 02:01 PM

$DB_site->query already calls mysql_query, so $stmt contains already the mysql result, and therefore you cannot put it as argument of mysql_query again :)

Doc203 08-28-2004 02:26 PM

Thanks Xenon, not only did that help solve my problem, but I understand better as well!

Xenon 08-28-2004 03:17 PM

:) glad i could help


All times are GMT. The time now is 10:40 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00945 seconds
  • Memory Usage 1,725KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete