Jump to content


Member Since 01 Dec 2005
Offline Last Active Oct 13 2017 11:04 AM

Topics I've Started

Mysql Syntax Being Rejected

21 May 2017 - 01:50 PM

I have the following SQL being executed by a mysqli_query() statement in my PHP code:


DROP TEMPORARY TABLE IF EXISTS tmptable; CREATE TEMPORARY TABLE tmptable SELECT * FROM Members WHERE MemberId = '105' AND Status > '0'; UPDATE tmptable SET RecordId = '', Status = '0', ChangedBy = '4', ChangedOn = '2017-05-21 19:03:39'; UPDATE Members SET Status = '0' WHERE MemberId = '105' AND Status > '0'; INSERT INTO Members SELECT * FROM tmptable;


It is being rejected with the following error:


Errno: 1064 Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE TEMPORARY TABLE tmptable SELECT * FROM Members WHERE MemberId = '105' AND' at line 1 at line 952 in file: /home/sylvest/public_html/swchoir/edit_member.php


If I put the same SQL into the SQL tab in phpMyAdmin, it works fine.


What do I have to do to make this work in my PHP code?


Thanks - Rowan

Trouble With Header() Redirect On My Php Page

04 May 2017 - 06:53 AM

I have a web page which under certain conditions forwards to another one using the statement:




where $next_page == "Location: http://www.sylvester...p?v=1493894983"


This causes a 500 error.


I am reasonably sure that I have sent no output at all (other than to a log file) before the header statement. In any case, on other occasions where I have done this I seem to get a warning, which in this case is not happening.


I see nothing in any error_log files that I am aware of (that is /home/sylvest/error_log and /home/sylvest/pubic_html/swchoir/error_log) nor do I see anything relevant in the cPanel Errors list.


What am I doing wrong? How can I debug what is happening? I have a log statement early in the redirected-to file (index.php) and this does not seem to be being triggered, so I don't think it is ever executing this file.


Thanks - Rowan

Why Am I Getting "class 'passwordhash' Not Found" In P

27 April 2017 - 12:53 PM

I am trying to use the PHP password hashing module in my code, but the following line:

$hasher = new PasswordHash(8, false);

is giving me the error:

Fatal error: Class 'PasswordHash' not found in /home/myaccount/public_html/directory/edit_member.php on line 124


I am running PHP version 5.6.30. I thought that all versions from 5.5.0 onwards had this module? What do I have to do to enable me to use this?


Thanks - Rowan

Getting Mod_Rewrite To Work

20 April 2017 - 01:21 PM

I am trying to come up with a way of redirecting all requests for files in the directory http://mydomain/swchoir/<filename> to the file with the same name (and the same GET parameters if present) in the directory /home/myaccount/build00001/public_html/swchoir/<filename>.

My end objective is to allow the server to contain several different builds and for people who have the necesary permissions to be able to choose which one they want to look at, so for example I could have one build that is on public release, another that is in QA, and a third which is in development. Ordinary users would only be able to see the public release one. QA people would be  able to see either the public release or the QA build. And developers would be able to see all of them.

As a step towards this, I am trying to develop some rewrite rules that will send _all_ users to build00001. The lines I have added to the .htaccess file in /home/sylvest/public_html are:

SetEnvIfExpr True build_num=00001
Rewrite Rule ^swchoir/([0-9a-z/\.?&_=-]+)$ /home/myaccount/buildbuild_num/public_html/swchoir/$1 [NC, L]
php_value include_path ".:/home/myaccount/buildbuild_num/include"

Now when I try to access a page I get an internal server error.

Please can you suggest what is wrong with my rule, or how to best get this to do what I want? In particular I'm not sure how to use the Environmental Variable build_num that I have tried to define. I'm not sure whether "SetEnvIfExpr True" is valid, and I'm not sure whether "sylvest/buildbuild_num/public_html" is a valid way of using the variable. Seems unlikely, but I'm not sure whether it needs some kind of quotes to indicate that it is a variable name, and if so, what kind.

If you know a better way of doing the whole job, please tell me that too. It seems odd to me that something like this doesn't already exist somewhere, since it surely must be a commmon need.

Thanks - Rowan


Running Php File From Cron Job

10 April 2017 - 05:34 AM

 Is it possible to run a PHP program from a cron job? I am trying to do this, and have set up a cron job to run
 once per day at 3am. It attempts to do it, but fails as follows:
      [06-Apr-2017 20:49:33 America/Detroit] PHP Warning: require_once(basic_init.php): failed to open stream: No such file or directory in /home/xxxx/public_html/swchoir/index.php on line 2
      [06-Apr-2017 20:49:33 America/Detroit] PHP Fatal error: require_once(): Failed opening required 'basic_init.php' (include_path='.:/opt/cpanel/ea-php56/root/usr/share/pear') in /home/xxxx/public_html/swchoir/index.php on line 2

 My first question is, why is it trying to run index.php, which is my default page, but is not involved in do-email.php at all, as far as I can see.

 The second question is why is the include path set to '.:/opt/cpanel/ea-php56/root/usr/share/pear'?

 I have the following in my php.ini file:
 include_path = ".:/home/myaccount/include:/usr/lib/php:/usr/local/lib/php"

 Which works fine when running the PHP files as part of web pages, but it seems that this is not working in a cron job.

 I hope you can help me put my finger on why this is not working.

 Thank you - Rowan