I have a query, and I want to get the last ID inserted. The field ID is the primary key and auto incrementing. I know that I have to use this statement: That statement works with a query like this: But if I want to get the ID using this statement: I get this error: What am I doing wrong?
Query with a PHP foreach using OR and LIKE %?
I have sort of a tricky problem, and I want to see if there is an easier way about solving it. I have let’s say $numbers= $_GET[‘numbers’]; //resulting in $numbers=array(1,2,3) The count in the …
Regexp ignore certain parts in string
I need to use regex for a string to find matching results. I need to find the (.+?) but would like to ignore everything where it says (*) right now: $regex=’#<a …
Is there any way in php to make SWITCH opreator compare cases strict?
I have such control structure: And my NULL case is never invoked because as I found in php manual: Note that switch/case does loose comparision. I know I can use IF instead of SWITCH but I wouldn’t like to, I have already some IF’s in every CASE of my SWITCH. Is there any way to rewrite somehow SW…
Why are my Amazon S3 images loading slow?
It seems like the images read from amazon s3 load really slow. I had the images on the same server as the website and it loaded super fast. Is it loading slow cause it has to access it from s3 now? …
ereg(“^[0-9a-z] restricts only 0-9 and a-z character what about other language character
I have a form and I want to allow users with all character without any space . so I was using this for english character ereg(“^[0-9a-z] but later I have decided to allow other character of …
WordPress prepared statement with IN() condition
I have three values in a string like this: When I feed it into a prepared statement like this: echo $query; shows: It is not writing the string as three separate values — it is just one string with the double quotes escaped. How can I properly implement a prepared statement in WordPress with multiple va…
SQL get results 21-30?
This seems like a really simple question but I can’t seem to find information on it. If I have 100 results, and I only want to get the results results between 21 and 30 (from the order my SQL query is grabbing them), how would I accomplish this? Answer You can use this: E.g.,
Unable to access an error message corresponding to your field name
I have a callback function that check_captcha which sees if $row is ==0 or == 1 (this information is queried from sql). The problem is that I can not call it from $self->form_validation->set_rule(‘captcha’, ‘call_back_check_captcha’) due to the fact that my function takes in a $r…
How to attach PDF to email using PHP mail function
I am sending an email using PHP mail function, but I would like to add a specified PDF file as a file attachment to the email. How would I do that? Here is my current code: Answer You should consider using a PHP mail library such as PHPMailer which would make the procedure to send mail much simpler and better…