CommonEnemy
-
Posts
4 -
Joined
-
Last visited
Never
Posts posted by CommonEnemy
-
-
So it would be an integer then? I've tried converting it using "{ }" in an echo but I still get errors.
Edit: If you look at the code, the query doesn't actually get executed, only echoed.
-
Catchable fatal error: Object of class PDO could not be converted to string in C:\inetpub\wwwroot\form.php on line 21
-
This is bothering me beyond belief I'm hoping that someone here might be able to help me. I've tried playing around with a few permissions, that could be the problem. Basically if I try to create/open a database it will create an error I've narrowed it down to this one line and it's the first one which leads me to believe that it's either a php configuration problem or a permissions thing. Running IIS 7.0
<html> <body> <?php $dbh = new PDO('sqlite:poems.sqlite'); ?> <?php //phpinfo(); $name=$_POST["userName"]; $contact=$_POST["userContact"]; $poem=str_replace(" ","<br />",$_POST["userPoem"]); $comment=str_replace(" ","<br />",$_POST["userComment"]); $query='INSERT INTO '.$dbh.' (name,contact,body,desc) VALUES ('.$name.','.$contact.','.$poem.','.$comment.')'; echo $query; /*$db->exec('INSERT INTO '.$db.' (name,contact,body,desc) VALUES ('.$name.','.$contact.','.$poem.','.$comment.')');*/ ?> <p> <b>Your name:</b> <?php echo $name; ?><br /> <b>Your contact info:</b> <?php echo $contact; ?><br /> <b>Your Poem:</b><br /> <?php echo $poem; ?><br /> <b>Your Comments:</b><br /> <?php echo $comment; ?> </p> </body> </html> <?php $dbh = null; ?>
Any and all help is appreciated. Would Apache be any better? I'm considering just switching over if so.
Failing to open an sqlite database.
in Other RDBMS and SQL dialects
Posted
Right, I read it but since I'm not used to object/class programming I assumed that the database connection object could be represented as an integer which I could echo to see if my open function succeeded or not. That aside, I've cleaned up my query and I'm getting this error:
Warning: PDO::exec(): SQLSTATE[HY000]: General error: 1 near "Morrison": syntax error in C:\inetpub\wwwroot\form.php on line 26 Array ( [0] => HY000 [1] => 1 [2] => near "Morrison": syntax error )
Where Morrison is the name. I've used sqlite before, awhile ago mind, and I can't see the syntax error regarding the query. Could it be a PHP error I've made?
Got that one sorted out, forgot about the ' ' since they were already there for adding the strings together. New problem is:
But I think I can handle it on my own, thanks for all your help.