Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
Possible duplicate, but I lost hours on this one
$stmt=$mysql->prepare(" insert into test_booked_tickets(book_id, ticket_id, num_people) values(:book_id,:ticket_id,:num)");
echo (int)$ticket->id."<br/>";
echo (int)$ticket->number_people."<br/>";
echo (int)$booking->id."<br/>";
$stmt->bindValue(":ticket_id", (int)$ticket->id);
$stmt->bindValue(":num", (int)$ticket->number_people);
$stmt->bindValue(":book_id", (int)$booking->id);
try{
$stmt->execute();
}
catch(PDOException $e){
echo "catched <br/>";
echo $e->errorInfo;
}
Other queries work perfectly. These are the returned values from echo
30
1
10
It doesn't get into catch, and it doesn't insert into table...
Thanks everyone for useful comments, I had a typo in database, column name.
Thanks A.O. for the most useful comment.
And thanks everyone else for other useful suggestions.
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
might be a very dumb question but i'm trying to make a html string with a php var and then html.. what the heck am I doing wrong?!? :(
$author_name = get_the_author(); ?>
<h4><?php $author_name;?> On-Demand Webinars</h4>
Thank you!
Just missed the echo.
<h4><?php echo $author_name;?> On-Demand Webinars</h4>
You missed "echo" statement
e.g
<?php echo $author_name;?> On-Demand Webinars
OR
<?=$author_name;?>
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I get this error while trying to update. The query works in phpmyadmin just fine.
Was a bind error, all fixed thanks to the great people here.
That's because you've got typo in your parameters.
You are using :serreceivetxt instead of :userreceivetxt and :serreceiveemail instead of :userreceiveemail.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
SO, I want to create a pretty big mysql table that should save all of the squares of a chess board and their value, I'm using a PHP for() since it has 64 squares.
This always gives me 'not working'
<?php
mysql_connect('localhost','pierostesting','');
mysql_select_db('my_pierostesting');
$query="CREATE TABLE board (";
for($i=0;$i<63;$i++){
$query .= "i".$i." INT(1) NOT NULL,";
}
$query .="turno BOOL";
if (mysql_query($query)){
echo 'working';
}else echo 'not working'; ?>
I'm an idiot, didn't close the bracket.
try echoing out your complete SQL string, then use phpMyAdmin and see if the sql string actually works, or if it throws errors. You may have a sql syntax error.
If it does work, make sure your connection variables are correct (host, db name, username, password)
that should get you close to the answer.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
foreach($db->fetch_array("SELECT id_categories FROM csn_categories_join_kartes where id_kartes===".$card['id']."") as $kat){
echo (kat['id_categories']);
}
table cols and values are all matched, something is wrong in this part of code
I tried adding $ before kat and using only one "=", sill doesnt work
NEW LINK
http://pastebin.com/RPK7vEaJ
this
where id_kartes===".$card['id']."
would be
where id_kartes=".$card['id']."
and missing $
echo $kat['id_categories'];
so full code :-
foreach($db->fetch_array("SELECT id_categories FROM csn_categories_join_kartes where id_kartes='".$card['id']."'") as $kat){
echo $kat['id_categories'];
}
best practice if you store your query result in a variable and loop over this variable.
foreach($db->fetch_array("SELECT id_categories FROM csn_categories_join_kartes where id_kartes=".$card['id']."") as $kat)
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 years ago.
Improve this question
I am running the below code and know that this is the suspect peice as I have placed an echo above and below it. The first runs fine but the second does not.
If I change the query to something like "show tables" it will run but I cannot see what if anything is wrong with this. I have checked reserved words and syntax. Am I missing something obvious!
try
{
$sth = $dbh->prepare('SELECT COUNT(*) AS val FROM users WHERE username=:user');
$sth->binvalue('user',$_POST['user']);
$sth->execute();
}
catch(PDOException $e)
{
echo $e->getMessage();
}
There is a type error:
instead of
$sth->binvalue('user',$_POST['user']);
Try
$sth->bindvalue('user',$_POST['user']);
^
$sth->binvalue('user',$_POST['user']);
should be
$sth->bindValue(':user',$_POST['user']);
Notice both the bindValue and the :user