scootstah
Staff Alumni-
Posts
3,858 -
Joined
-
Last visited
-
Days Won
29
Everything posted by scootstah
-
Select form to display data from MySQL not working when using AJAX
scootstah replied to webguync's topic in PHP Coding Help
Can you confirm that str holds a value before passing it via AJAX? -
Select form to display data from MySQL not working when using AJAX
scootstah replied to webguync's topic in PHP Coding Help
It's acceptable to use in this case, because otherwise if you fail to connect it's going to spit it out something like this for everyone to see: Warning: mysql_connect(): Access denied for user 'blah'@'localhost' (using password: YES) EDIT: By the way, why are you mixing jQuery with native Javascript? One of the most awesome things about jQuery is handling AJAX. jQuery.post unless you suppress the warnings/errors the correct way, which would be to set the php.ini directives "error_reporting" and "display_errors" to 0 and no, respectfully, for a live server. True, you shouldn't be displaying ANY warnings to the public on a live server. But there's no ill side effects from suppressing mysql_connect(). It ensures that if your code ever lands on an improperly configured server that the world isn't going to get a glimpse at your database credentials. -
Select form to display data from MySQL not working when using AJAX
scootstah replied to webguync's topic in PHP Coding Help
It's acceptable to use in this case, because otherwise if you fail to connect it's going to spit it out something like this for everyone to see: Warning: mysql_connect(): Access denied for user 'blah'@'localhost' (using password: YES) EDIT: By the way, why are you mixing jQuery with native Javascript? One of the most awesome things about jQuery is handling AJAX. jQuery.post -
That isn't the default Apache behavior. This is usually done by routing everything through the index.php file. By doing this, pages are never technically "not found", since the index.php file exists. Therefore you can have the functionality you are looking for and force 404 headers when something is "not found".
-
Whoops, made an error. Updated: <?php require "scripts/connect.php"; $query = mysql_query("SELECT * FROM p WHERE section='gtkphp'"); ?> <table id="barTop"> <tr id="sign"> <td id="blue"><b>Pages</b></td> </tr> <?php while($rows = mysql_fetch_assoc($query)): $id = $rows['id']; $title = $rows['title']; $body = $rows['body']; ?> <tr> <td> • <a href="viewp?view=<?php echo $id; ?>"><?php echo $title; ?></a><br> • <a href="viewp?view=<?php echo $id; ?>"><?php echo $title; ?></a><br> </td> </tr> <?php endwhile; mysql_close(); ?> </table>
-
sprintf printf works the same way except it echo's it instead of returning it.
-
Readable Programming Language to Create Audio Software
scootstah replied to Glese's topic in Miscellaneous
And the answer is: a lot. So pick one you are proficient with, make sure it has libraries for this, and use it. Ask a vague question, get a vague answer. I'm not sure why you've got your knickers in a twist over it. -
That's not how it works. You need to put everything in the while loop that you want repeated. I imagine you want something like: <?php require "scripts/connect.php"; $query = mysql_query("SELECT * FROM p WHERE section='gtkphp'"); ?> <table id="barTop"> <tr id="sign"> <td id="blue"><b>Pages</b></td> </tr> <?php while($rows = mysql_fetch_assoc($query)): ?> $id = $rows['id']; $title = $rows['title']; $body = $rows['body']; <tr> <td> • <a href="viewp?view=<?php echo $id; ?>"><?php echo $title; ?></a><br> • <a href="viewp?view=<?php echo $id; ?>"><?php echo $title; ?></a><br> </td> </tr> <?php endwhile; mysql_close(); ?> </table>
-
Readable Programming Language to Create Audio Software
scootstah replied to Glese's topic in Miscellaneous
Fail You can do what he wants with a ton of languages. Without asking a more specific question, that's all he's going to get. next time I want to make a synthesizer in CSS, ill come to you It's funny the attitude you are giving me considering your signature, -
You don't necessarily need to output an error. Just design in such a way that unhandled errors aren't going to happen. For example don't rely on a database query happening and then have a bunch of undefined variable errors. If you rely on something that should always happen, then you could always do a 500 - Internal Server Error if it doesn't happen. It will likely only be a very temporary thing, like a hiccup in the database or something. You can turn on error logging in the background to give you more detailed information without the public knowing. After all, when your server takes a shit the last thing you want to do is tell everybody the problem.
-
Readable Programming Language to Create Audio Software
scootstah replied to Glese's topic in Miscellaneous
Fail You can do what he wants with a ton of languages. Without asking a more specific question, that's all he's going to get. -
It would likely be a ton more work to "retrofit" an existing CMS than it would be to just create your own.
-
Okay, I misunderstood what users.php was for. So then yes, this would be for profile.php
-
Readable Programming Language to Create Audio Software
scootstah replied to Glese's topic in Miscellaneous
The one you are most proficient with. -
Recommendations to Separate the Website Parts Into Their Own
scootstah replied to Glese's topic in Miscellaneous
Look at the HMVC pattern. -
PHP6, being released when? The beta is gone.
scootstah replied to QuickOldCar's topic in Miscellaneous
Even when it is released it will take a long time to be mainstream. 5.3 isn't even mainstream yet. -
How are you gathering what page to view on users.php? I don't see anything relating to a query string or anything. Try something like: if (isset($_GET['user'])) { $user = $_GET['user']; } else if (isset($_SESSION['user'])) { $user = $_SESSION['user']; } if (isset($user)) { $user = mysql_real_escape_string($user); $query = mysql_query("SELECT * FROM users WHERE id='" . $user . "'"); if (mysql_num_rows($query)) { // user found, do whatever } else { echo 'user not found'; } } else { echo 'you must be logged in to view your profile'; } To view the profile you'd go to users.php?name=James Smith If you don't supply a name, it tries to use the session. If it can't find the session either, it will say you need to login to view your profile. To "follow" other users, basically you're just going to fetch all posts by that user. So say your follow table is like: user_id | follow_user_id ------------------------- 1 | 2 1 | 3 1 | 4 So user 1 (lets say that's you) is following users 2, 3 and 4. Then you would just select the posts these users make in whatever fashion you wanted.
-
Just leave the action blank and the form will go to the current page, you don't need to use PHP_SELF here.
-
$_SERVER['PHP_SELF'] is vulnerable to XSS attacks and really shouldn't be trusted ever. Also, if you are accessing it with $PHP_SELF that tells me that you have register_globals on, which is bad bad bad. Turn it off.
-
Recommendations to Separate the Website Parts Into Their Own
scootstah replied to Glese's topic in Miscellaneous
I would build a mini framework and use a modules system. Each thing (commenting, favoriting, rating...) would be its own module and completely independent of one-another. This way you can just drop in whatever module you want and you're good to go. -
Using a Combination of Sign In Modules for the Website?
scootstah replied to Glese's topic in Miscellaneous
Huh? -
You can't use onclick events with PHP. But you can use AJAX like that.
-
SEO and creating pages with a Page class.......
scootstah replied to tinwakr's topic in Application Design
By the way, if you want to do something similar to what I suggested, bear in mind that you can also pass variables to the header and footer...so you can dynamically slip in meta keywords and stuff. load_template('somepage.php', array('keywords' => 'keyword, keyword2, keyword3')); in header.php: <meta name="keywords" content="<?php echo $keywords; ?>" /> -
You make a for loop but you aren't accessing each index, you just refer to the entire array again. Try something like this: $checks = $_POST['chkColor']; $where = ''; foreach($checks as $check) { $where .= 'id = "' . $check . '" OR '; } $where = rtrim($where, ' OR '); if (!empty($where)) { mysql_query("DELETE FROM crew_messages WHERE " . $where); }
-
SEO and creating pages with a Page class.......
scootstah replied to tinwakr's topic in Application Design
You can use that function in OOP. Just because you use OOP doesn't mean you can't use procedural functions as well. If you want the template system to be more advanced feel free to implement an OOP solution. In the end your markup is sent to the browser one way or another, and this is what Google will see. It doesn't matter if you write the entire layout on every page or section it off like this. The advantage to doing it the way I suggested is that you don't duplicate code. If you have your entire layout on every single page, and then decide you want to change one little thing in the layout you have to edit every page. If you use my suggestion, you simply edit the header.php and you're done.