RE: [PHP-DB] MySQL query executes outside of PHP, but not in PHP

2009-01-26 Thread Dave.McGovern

snip

  error_log(Hey, the SQL is: $sql);

  Then look in your php error log (you do have error logging enabled,
  right?)
[McGovern, Dave] Enabled, yes.  Usefully enabled, no (correcting this
helped a lot).

  If that SQL in the error log is fine, then your problem is
  $client2-multi_query($sql) -- what does THAT return?  What SHOULD it
  return?  What are you expecting it to return?  Does it return what
you
  thought it did?
[McGovern, Dave] It was returning ''.  I was expecting 1.

  When you do if ($var) it can sometimes have unexpected results.  If
$var
  is an empty string, it's still true, and executes.  I don't know that
  multi_query SHOULD return, or how to determine if it throws an error,
but
  that's one place to start.

  Next, if multi_query worked, then this line is suspect:

if ($result = $client2-use_result()) {

  This will always result in TRUE, as the assignment will always
succeed.
  Change it to:

if (($result = $client2-use_result())) {

  (added parenthesis)
 What DB library are you using?
[McGovern, Dave] php_mysqli.dll

---

Peter Beckman  Internet
Guy
beck...@angryox.com
http://www.angryox.com/
---


[McGovern, Dave] 
Hi, Peter -
Thanks for the suggestions.  I did have error logging enabled, but I
wasn't writing any of my own errors to the log, so it wasn't doing me
much good. Once I started doing this, I was able to trace the source of
the error to the fact that this particular SQL script was meant to be
aimed at a different schema. The reason it worked in MySQL Query Browser
was that the required schema was already selected in the Query Browser
(ouch).

Sorry to have wasted the list's time with what turned out to be a silly
human error.
Dave


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] PostgreSQL Conference, U.S. East 09 Call for Papers

2009-01-26 Thread Joshua D. Drake
PostgreSQL Conference, U.S., East 09 will be held in Philadelphia at
historic Drexel University from April 3rd through 5th. The call for
papers is now out at: http://www.postgresqlconference.org/2009/east/ .

As always we let our submissions define our actual tracks. If you have
something you want to talk about it. Submit it. As long as it is about
PostgreSQL (or doing something with PostgreSQL) we will consider it.

We are seeking creative ideas about things we can do at the conference.
At West we had a code sprint. The sprint was very successful as it was
about all things postgresql and open source. It wasn't just hacking back
end code but people worked on all kinds of things.. Is someone up for
running a code sprint? 

There has also been specific interest in having us add (in addition to
our advanced topics) a newbie track. Please do not be afraid to submit a
talks on items such as:

  * Backing up PostgreSQL
  * Understanding and Configuring Autovacuum
  * Normalization
  * Trigger Happy (how to use triggers ;)
  * PITR -- happiness is a shipped transaction log

Other topics we are interested in beyond the standard PostgreSQL
architectural fanfare are:

  * Groovy/Grails
  * Django
  * PHP
  * Postgis
  * Pylons
  * SQL Alchemy
 
So don't delay, PostgreSQL Conference, U.S. is the premeire PostgreSQL
conference series for the United States PostgreSQL community! Please
submit your talk here: http://www.postgresqlconference.org/2009/east/ .

Sincerely,

Joshua D. Drake
-- 
PostgreSQL - XMPP: jdr...@jabber.postgresql.org
   Consulting, Development, Support, Training
   503-667-4564 - http://www.commandprompt.com/
   The PostgreSQL Company, serving since 1997


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] PHP Results on multiple pages

2009-01-26 Thread Chris



This script do everything fine counting total records
it display's 1 to 10 records on first page with numbers but
second location where i want it to display Showing results 1 to 10 it shows
17 to 26 second it displays a link to Next but not working.


It takes roughly 20 secs to do a search? Perhaps that should also be 
looked at.


Try to narrow down your problem.


// begin to show results set
echo  found  $numrows results p;
$count = 1 + $s;


Where does $s come from? What is it supposed to mean? (Name your 
variables properly).



// now you can display the results returned
 while ($row= mysql_fetch_array($result)) {

 $title = $row[sname];
 $url = $row[url];
 $message = $row[massage];
//nbsp;a href=\$row['url']\$row['sname']/abr /
$row['massage']brhr'\

 echo $count.)nbsp;
 echo ba href=\$url\ target=\_blank\$title/a/b;
 echo br;
 echo $messagebrhr height=12 color=lightbluebr;
 $count++;

 }

$currPage = (($s/$limit) + 1);

//break before paging
 echo br /;

 // next we need to do the links to other results
 if ($s=1) { // bypass PREV link if s is 0
 $prevs=($s-$limit);
 print nbsp;a href='{$_SERVER['PHP_SELF']}?s=$prevsq=$var' 
 Prev 10/anbspnbsp;;
 }

// calculate number of pages needing links
//  $s=intval($numrows/$limit);
 $s=ceil($numrows/$limit);


// $s now contains int of pages needed unless there is a remainder from
division

 if ($numrows%$limit) {
 // has remainder so add one page
 $s++;
 }


What is $s set to here when there's extra pages to display?


// check to see if last page
 if (!((($s+$limit)/$limit)==$s)  $s!=1) {


That's just too complicated to read. The first part seems redundant 
since you're calculating $s anyway, why re-do it?


// are there extra pages to display?
if ($s  1) {
  echo show extra pages;
}



 // not last page so give NEXT link  $PHP_SELF gt;gt;
 $news=$s+$limit;

 echo nbsp;a href='{$_SERVER['PHP_SELF']}?s=$newsq=$var'Next 10 
/a;

 }

$a = $s+$limit;
 if ($a  $numrows) { $a = $numrows; }
$b = $s+1;
 echo pShowing results $b to $a of $numrows/p;
include ('footer.inc');
?

I shall highly appreciate if anyone shall have a look at it
and let me know where i am wrong.

Thank you.





--
Postgresql  php tutorials
http://www.designmagick.com/


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] INSERT img+ID

2009-01-26 Thread Chris



I want to insert a JPG image ($creacion) with the ID (from the data base,
MEDIUMINT AUTOINCREMENT): 23image.jpg in the data base, and send the
information to a e-mail addres. How do I do that?


There are plenty of tutorials/examples of this around.

Search for something like mysql insert image database.

Here's one example: http://hockinson.com/index.php?s=37 (even with a 
downloadable script).


Most people suggest storing the filename with the database record, and 
leaving the actual image in a particular folder.


--
Postgresql  php tutorials
http://www.designmagick.com/


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php