-
Posts
3,145 -
Joined
-
Last visited
-
Days Won
37
Everything posted by cyberRobot
-
Help needed: SELECT specific user data from MySQL in PHP
cyberRobot replied to raneyron's topic in MySQL Help
Have you tried outputting your variables to make sure things work as expected? I would likely start with $userID. You could try the following: <?php //... $userID = $_SESSION['user']['username']; var_dump($userID); //... ?> If the ID came through properly, you could check the $row_count variable to make sure a row is being returned. Also, it looks like you are using MySQLi for the database connection. If that's correct, you can find some information about checking for MySQL errors here: http://php.net/manual/en/mysqli.error.php -
Have you tried style.color? Note that the following reference sheet might be helpful: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Properties_Reference
-
Have you tried using array_change_key_case()? More information can be found here: http://php.net/manual/en/function.array-change-key-case.php
-
Are you still getting the session_start() error? If so, please post the updated code. When posting the code, please surround it with tags. It will make your code and post easier to follow. Also note that you'll want to make sure that all errors are being reported. Try adding the following to the top of your code: <?php error_reporting(E_ALL); ini_set('display_errors', 1); ?> Note that the original code posted has the following line: error_reporting(0); This hides the errors and makes the script difficult to debug. Of course, you'll want to hide errors once the script is fixed and live.
-
Also, have you tried seeing if MySQL is throwing errors? http://php.net/manual/en/mysqli-stmt.error.php
-
Is your database object stored in $con or $conn? The code seems to use both: <?php $con->prepare(... //... $conn->close(); ?>
-
To use a variable within a string, you need to use double quotes. mail('me@telusplanet.net',"$user",'From news page'); In this case, the quotes technically are not needed. This should work just fine: mail('me@telusplanet.net',$user,'From news page');
-
The manual mentions that the headers are optional...assuming that the php.ini contains a default for the from header.
-
If you post the attempted code, we may be able to let you know why it's not working. If you post more code, please surround it with tags. It makes the code and post easier to follow. When including a variable like $user in the subject line, are you using single or double quotes? Note that you need to use double quotes for a variable to work in a string. For example: <?php mail('yourEmailAddress@yourDomain.com', "$user is unable to log in", 'This is the body of the e-mail!'); ?>
-
Could you provide more information about what you mean by "...there are times that it transmits correctly, and times that it won't...". Does the script show any errors? Does it only send part of the message...if so, what's missing? Does it fail to send the message altogether?
-
You could use PHP's DOMDocument class: http://php.net/manual/en/class.domdocument.php
-
Creating a dynamic table with 5 columns per row
cyberRobot replied to Texan78's topic in PHP Coding Help
My current preference is to read all the values into an array. Then split the array with array_chunk() and loop through the results. http://php.net/manual/en/function.array-chunk.php -
Your first example seems to work. The problem is that the code only executes when the page is first loaded. If the inner width is less than 751 when the page loads, it removes the class. If you're looking to dynamically remove the class, you could look into using .resize(). More information can be found here: http://api.jquery.com/resize/
-
Should "secret questions" be used to allow password changes?
cyberRobot replied to NotionCommotion's topic in PHP Coding Help
I'm personally not a fan of "secret questions". If the questions are answered honestly, it's fairly easy for someone who knows me to access my account. So I usually answer the questions with fake answers which are harder to remember and can lead to loosing access to an account. -
You're using the grave accent in the following line: $searchq = $_GET[`search`]; You need to use straight quotes: $searchq = $_GET['search']; With that said, the following lines aren't really doing anything: $searchq = $_GET[`search`]; $searchq = ("#[^a-z, A-Z]#i"); I would imagine these lines need to happen before the query where the $searchq variable is used. For now, I would just comment them out until you get the script working. Especially since the second line is going to just overwrite your variable. The second line looks like an attempt to do a regular expression. If you want to get it working, you'll need to look into how they are executed.
-
The following if test isn't needed: if ($result->num_rows > 0) { mysqli_fetch_array() returns NULL if there are no results. If it's NULL, the loop content will be skipped. Also, you can avoid the extra overhead of mysqli_fetch_array() since you only use the associative array version of the data. You can use mysqli_fetch_assoc() instead. Perhaps the following will work: while($row = $result->fetch_assoc()) { Note that I switch the code to use the object-oriented version. I'm not sure if that's causing the issue.
-
The following will apply the styles to the <ul> tag in the "nav-bar" <div>...and to every <li> tag on your page: #nav-bar ul, li { Instead, I recommend splitting the styles. You could try something like this: #nav-bar ul { list-style: none; margin: 0; padding: 0; } #nav-bar li { display:inline-block; line-height: 44px; height: 37px; border: 4px solid #000000; border-bottom-color: red; } Hopefully the above also answers your question. Also note that CSS comments are different than the ones in HTML. More information can be found here: http://css-tricks.com/snippets/css/comments-in-css/
-
Have you tried seeing if there is any MySQL errors? Note that you can find out more information about doing that here: http://php.net/manual/en/mysqli.error.php Basically, you would do something like this: $sql = ("SELECT * FROM applicant WHERE `Firstname` LIKE $searchq OR `Lastname` LIKE $searchq") or die("Could Not Search"); $result = $dbhandle->query($sql) or die($dbhandle->error); Once you get the query working, you'll want to get rid of the "or die..." debugging part.