FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » pgsql and exception
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: pgsql and exception [message #178103 is a reply to message #178100] Mon, 14 May 2012 07:34 Go to previous messageGo to previous message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma:
Senior Member
Am 14.05.2012 08:39, schrieb Une BĂ©vue:
> I have an INSERT generating an exception :
> ERROR: value too long for type character varying(30)
>
> this error comes from try out usinf command line.
>
> I'd like to print-out this error when using this database from php.
>
> Then, i did :
>
> $ret=$db->query($sql);

Your code is wrong here. Every database operation should be inside the try block,
otherwise it will not be catch'ed.

/Str.
> try {
> while($row=$ret->fetch()){ // line 492
> $rowid=$row['rowid'];
> }
> // do something
> } catch (Exception $e) {
> echo $e->getMessage()."<br />\n";
> }
>
> or using :
> } catch (PDOException $e) {
> echo $e->getMessage()."<br />\n";
> }
>
> From php i get :
> Fatal error: Call to a member function fetch() on a non-object in
> /Users/yt/Sites/landp_public/landp.php on line 492
>
> line 492 being "while($row=$ret->fetch()){"
>
> obviously the best way is to avoid having a varchar column with a length lower than 30.
>
> could i get the error from $ret ?
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic:
Next Topic: Re: reading a newline from a properties file
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 29 04:40:05 GMT 2024

Total time taken to generate the page: 0.04210 seconds