-
Posts
2,134 -
Joined
-
Last visited
-
Days Won
42
Everything posted by benanamen
-
You are using Mysql code that has been removed from Php. You need to use PDO with prepared statements. Here is a really good tutorial (Posted by @Jaques1) https://phpdelusions.net/pdo
-
For starters, you have almost 50% more Php code than you need. Is the page online? What is the URL? If your footer HTML is within the Bootstrap "container" class, the footer is not going to go end to end.
-
Here you go... http://bfy.tw/4bGg
-
session_start() creates new session on page reload
benanamen replied to runnerjp's topic in PHP Coding Help
Depending on the name of a button to be submitted will completely fail under certain circumstances. -
buttons are not working on a login system
benanamen replied to Michael_Baxter's topic in PHP Coding Help
Whatever your problem, you are missing a closing bracket here in sha512.js: //Same, except with 5 addends function int64add5(dst, a, b, c, d, e) { var w0 = (a.l & 0xffff) + (b.l & 0xffff) + (c.l & 0xffff) + (d.l & 0xffff) + (e.l & 0xffff); var w1 = (a.l >>> 16) + (b.l >>> 16) + (c.l >>> 16) + (d.l >>> 16) + (e.l >>> 16) + (w0 >>> 16); var w2 = (a.h & 0xffff) + (b.h & 0xffff) + (c.h & 0xffff) + (d.h & 0xffff) + (e.h & 0xffff) + (w1 >>> 16); var w3 = (a.h >>> 16) + (b.h >>> 16) + (c.h >>> 16) + (d.h >>> 16) + (e.h >>> 16) + (w2 >>> 16); dst.l = (w0 & 0xffff) | (w1 << 16); dst.h = (w2 & 0xffff) | (w3 << 16); -
Thanks to @Jaques1 one DIFF suggestion and @mac_gyver, the end of file issue was the short tag setting. I had missed several complete php opening tags and didn't know it since short tags were on, on my dev server. On the different versions, Client is on godaddy shared hosting and was on php 5.4, they just went to 5.5x. They are planning on getting a dedicated server with at least 5.6, so that is why the different versions. On to the other problems
-
Regarding Notice errors, What changed from Version 5.5.7 To PHP Version 5.6.15 I have Zend server running 5.5.7 and XAMPP running 5.6.15 with the same EXACT error reporting settings and same exact website. XAMPP is showing numerous notices whereas Zend server is not. Additionally, some pages flat out break in XAMPP (End of file error) while it works in Zend Server php 5.5.7 with same error reporting settings. XAMMP also says undefined functions even though a functions file is included and the function exists, works fine on zend server with 5.5.7 Error level on both error_reporting=E_ALL & ~E_DEPRECATED & ~E_STRICT What gives?
-
*Edit: Nevermind, I didnt understand you wanted a range. This is a correct query. Run it by itself. You will have to figure out what is up with your data assuming you have a correct date column and format.
-
Lol, that's what I get for pulling something off stack that I have never used or tested.
-
I usually use positional placeholders as well (?,?). The only technical difference I am aware of is that named parameters can be in any order. On a large query, named parameters could be easier to use. Some will say it is easier to read. Whatever method you choose, just be consistent. Both are just as safe.
-
<?php function insert($table, array $data) { /* * Check for input errors. */ if(empty($data)) { throw new InvalidArgumentException('Cannot insert an empty array.'); } if(!is_string($table)) { throw new InvalidArgumentException('Table name must be a string.'); } $fields = '`' . implode('`, `', array_keys($data)) . '`'; $placeholders = ':' . implode(', :', array_keys($data)); $sql = "INSERT INTO {$table} ($fields) VALUES ({$placeholders})"; // Prepare new statement $stmt = $dbconn->prepare($sql); /* * Bind parameters into the query. * * We need to pass the value by reference as the PDO::bindParam method uses * that same reference. */ foreach($data as $placeholder => &$value) { // Prefix the placeholder with the identifier $placeholder = ':' . $placeholder; // Bind the parameter. $stmt->bindParam($placeholder, $value); } /* * Check if the query was executed. This does not check if any data was actually * inserted as MySQL can be set to discard errors silently. */ if(!$stmt->execute()) { throw new ErrorException('Could not execute query'); } /* * Check if any rows was actually inserted. */ if($stmt->rowCount() == 0) { var_dump($dbconn->errorCode()); throw new ErrorException('Could not insert data into users table.'); } return true; } $table = 'your_table'; $fields = [ 'col_1' => 'value_1', 'col_2' => 'value_2' ]; //Check if insert returns success if(insert($table, $fields)){ //The insert was successful echo "success"; }else { //The insert was not successful } ?>
-
Implications of database schema on PHP implementation
benanamen replied to NotionCommotion's topic in PHP Coding Help
The fact that you are asking this question tells me you do not understand Database Normalization. It isn't something I feel, it is just a fact your DB is not normalized and neither is the second version. The first obvious sign is that you are duplicating data. You were already given correct responses from the other forum members. -
Implications of database schema on PHP implementation
benanamen replied to NotionCommotion's topic in PHP Coding Help
As pointed out neither of your designs are any good. What you need to do is learn about "Database Normalization'. It is not a complicated subject and you should be able to master the understanding of it very quickly. It is an important thing to know and will get you on your way to solving your problem. -
How to pass the array value to the function
benanamen replied to Fabio_Siqueira's topic in Third Party Scripts
Before even dealing with your question, you need to stop using deprecated Mysql code and stop suppressing errors with @. You need to use PDO with prepared statements. -
Security Questions About set_include_path and PEAR
benanamen replied to jdlev's topic in PHP Coding Help
@quickoldcar, you are slightly off. That is going to give you a V separator with directory slashes going in two different directions, This will give you the correct cross platform solution: $directory_path = __dir__; require_once($directory_path .DIRECTORY_SEPARATOR. "include" .DIRECTORY_SEPARATOR. "functions.php");- 9 replies
-
- 1
-
- set_include_path
- pear
-
(and 1 more)
Tagged with:
-
FYI: Php 5.2 is over one hundred versions behind.
-
Noob Question.. what does ? character do in this statement
benanamen replied to Why_Not_Zoidberg's topic in PHP Coding Help
That is called a Ternary Operator. Same thing as if/else https://davidwalsh.name/php-shorthand-if-else-ternary-operators http://php.net/manual/en/language.operators.comparison.php -
My website is being attacked MYsql getting all sorts of rubbish
benanamen replied to Topshed's topic in MySQL Help
Without seeing your code it is difficult to say how things are happening. My first thought is that you have outdated insecure code. Let us see what your working with. -
You used the Quote tag instead of the Code tag.
-
What you need to do is post a SQL dump of your DB so we can see what you actually have going on. If your DB structure is wrong there is no point addressing anything else until that is fixed and it may also solve whatever your problem is.
-
OP is using Joomla. OP, your better off finding a Joomla forum for help.
-
Darn it! Is google down again?
-
You also have to setup a virtual host in Apache.