-
Posts
3,404 -
Joined
-
Last visited
-
Days Won
55
Everything posted by Ch0cu3r
-
PHP and MySQL or Access database connection
Ch0cu3r replied to dancojocaru2000's topic in PHP Coding Help
Use var_dump to analyse the values correctly var_dump($_SERVER['PHP_AUTH_PW']); echo '<br />'; var_dump($row["Password"]); Whats the output now for the password values? -
PHP and MySQL or Access database connection
Ch0cu3r replied to dancojocaru2000's topic in PHP Coding Help
You are getting that error because your query is failing, due to an error, to see what the error is you can use erroInfo. change line 65 to 78 to be $result = $db->query($sql); // check query did not fail (returns false on error) if($result) { while ($row = $result->fetch()) { if(!empty($row["Username"]) AND !empty($row["Password"])) { $_SESSION['user'] = $row["user"]; echo "Login Succefull!"; } else { echo "You entered wrong username and/or password. Please refresh this page to retry. It may be possible that your account doesn't exist. In this case, cancel the login box and sign up."; } } } // query failed else { $error = $db->erroInfo(); trigger_error('Unable to process login query. DB Error: ' . $error[2]); } -
No. return will terminate the function and return the data at that point. The second return statement will never be reached. See the documentation on return here http://php.net/return Any, way you do not need the second query. You could pass the result of calling your function to count to get the total results, this is because $stmt->fetchAll() returns a multidimensional array of all the rows returned by your query. Example function yourFunction() { ... omitted code ... return $stmt->fetchAll(PDO::FETCH_ASSOC); } // when calling your function $results = yourFunction(); // pass the result of your function to count, get the number of results returned from your function $numResults = count($results); // loop though results foreach($results as $row) { // generate xml } The alternative is instead of using return $stmt->fetchAll(PDO::FETCH_ASSOC); to have it return the PDO Statement object return $stmt; then when calling your function the code will be // when calling your function $stmt = yourFunction(); // call the PDO Statement rowCount() method to get the number of results $numRows = $stmt->rowCount(); // call the PDO Statement fetchAll method to loop through the results foreach($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) { // generate xml }
-
JSON Error Occurred in registration- PHP
Ch0cu3r replied to james_martin_187's topic in PHP Coding Help
Really, I just told you what you had missing. The forum didn't highlight the ( for some reason. -
JSON Error Occurred in registration- PHP
Ch0cu3r replied to james_martin_187's topic in PHP Coding Help
you still forgot the ( after SET -
Where are you generating the number and setting it the session and where on the next page are getting the number?
-
JSON Error Occurred in registration- PHP
Ch0cu3r replied to james_martin_187's topic in PHP Coding Help
Thats because that is still a valid INSERT query. Valid Insert query is INSERT INTO table SET ( ... columns ... ) VALUES ( ... values ...) or INSERT INTO table SET column = 'value', column2 = 'value2', ... etc -
This is not done with Javascript. The menu is styled using CSS. It swaps to pull down menu using CSS media queries based on the width of the device window. Heres a tutorial which creates horizontal menu collapse down to a vertical menu, uses nothing but CSS. http://medialoot.com/blog/how-to-create-a-responsive-navigation-menu-using-only-css/
-
JSON Error Occurred in registration- PHP
Ch0cu3r replied to james_martin_187's topic in PHP Coding Help
The query on line 68 i n DB_functions.php, has the first part of the query missing. $result = mysqli_query($this->db, "unique_id, firstname, lastname, email, username, encrypted_password, salt, created_at) VALUES('$uuid', '$fname', '$lname', '$email', '$uname', '$encrypted_password', '$salt', NOW())"); You have only listed columns and values. I assume that should be a insert query? -
Try it an find out
-
Have you made sure you are calling session_start() before the use $_SESSION's
-
The error is saying you are missing an argument. What do you think needs to be passed as the argument? See http://php.net/mysqli_error to see what the required argument is.
-
It would be better if you did not store the option groups and option values in separate arrays. I would use the option group label as the key and assign the values for the group to it. Example this is how I would structure the array // options grouped in one array // the key is defined as the option group label // the options for the label are assigned to that key $options = array( 'Drinks' => array( 'Tea', 'Coffee', 'Orange Juice', 'Apple Juice' ), 'Food' => array( 'Toast', 'Ham Sandwich', 'Chicken Soup', ), 'Desert' => array( 'Ice Cream', 'Chocolate Moose', 'Jelly' ), ); Now creating the option groups and options becomes trivial using two foreach loops echo '<select name="menu">'; foreach($options as $optGroupLabel => $optgroupValues) { echo '<optgroup Label="'.$optGroupLabel.'">'; foreach($optgroupValues as $optionValue) { echo '<option>' .$optionValue. '</option>'; } echo '</optgroup>'; } echo '</select>';
-
DOMXPath error while looping with While for site scrape
Ch0cu3r replied to max_maggot's topic in PHP Coding Help
If you are using simple html dom, then there is no need for the use of xpath. You use one or the other. Both return the same result, just uses different syntax for the grabbing the data you require. This xpath //div[@class=highslide-gallery] is the equivalent in simplehtmldom as div.highslide-gallery (it uses css selectors as the dom path) The reason the script maybe crashing is because it is running out of memory? You should check your servers error logs or enable errors either in the php.ini or adding the following two lines of code at the top of your script ini_set('display_errors', 1); error_reporting(E_ALL); -
Sounds to me you most likely need to wrap the code that generates the number in a condition, so it only generates the number when the session variable does not exist. Eg if(!isset($_SESSION['num'])) { // generate new random number } // use random number
-
You cannot just rename mysql_ functions over to mysqli_ Before renaming functions you should first consult the mysqli documentation, eg http://php.net/mysqli_query ( concentrate on the documentation regarding the procedural method) You will see at the top of the page, the function synopsis states the mysqli_query requires two arguments, the first being the mysqli instance (in your case $dbConnect) and the second being the query, so your use of mysqli_query would be like $result = mysqli_query($dbConnect, $query); And not just mysqli_query($query). Looking at your pagination code this looks like this will be the only change you may need. Generally the difference between the mysql and mysqli functions is where the mysql resource (connection) was optional in the mysql_ functions, now becomes required for the mysqli_ functions and is always the first argument.
-
You are making no sense at all. If want use to help you fix the code we need to know what the problem is, preferably write your response in clear English sentences
-
What error is that? Post all error message(s) in full. It would also be helpful if you could explained what it is your are tying to do and what you are expecting the code to do? Also note when posting code place wrap it within tags or click the <> icon in the editor.
-
At the time that tutorial was written, it use using a version of MYSQL before 4.1 was released, the MySQL PASSWORD function would of returned a 16 character hash. However you are using MySQL version 5.x the password hash function now returns a 41 character hash. Because you have set the password field to be 16 characters when the password is inserted it will be truncated, from 41 characters to 16 characters. The SQL query that checks the password will be trying to find a 41 character hash. This is why the sql query for checking the password is failing. So you need to change the password field to hold 41 characters not 16. You will need to reset users existing passwords also ALTER TABLE user CHANGE `password` CHAR( 41 ) NOT NUL; But using MySQL password function for hashing passwords is not recommend. You should use PHP's password_hash function (if your are not using PHP5.5 or newer then use the compatibility library).
-
Is it the the default value? Then you need DEFAULT before it. Event then it work as you are using float datatype, prehaps you mean to use varchar datatype?
-
The error is trigger because of this '0|0|1338.2893066406|-1773.7534179688|13.552166938782|0' after `Spawnkoords` float NOT NULL What is that supposed to be?
-
The PHP code you posted, looks fine. It will echo the last message that was just inserted, although the select query is probably not needed, you could just echo out the message that was just submitted. Seem like the problem is to do with your javascript code. What is the "retrievation" method?
-
@black_pearl Why does your class have functions photo1(), photo2(), photo3() etc defined? Why not just have a photo function defined and pass the id of the photo to the function?
-
Your can wrap your content in a container. See example https://jsfiddle.net/arswgywm/
-
Thnaks for correcting me, I was just about to correct myself and suggest just that Yes, You can use the object and procedural functions interchangeably like that. Though I do agree you should stick to one style.