-
Posts
3,145 -
Joined
-
Last visited
-
Days Won
37
Everything posted by cyberRobot
-
Help with basic PHP website that works with MySQL database
cyberRobot replied to tekkenfan2's topic in PHP Coding Help
Note: just in case you're interested...the request can be posted here if you're willing to pay someone for help: http://forums.phpfreaks.com/forum/77-job-offerings/ -
No problem. Side note: MySQL doesn't always return results in the same order. If you haven't done so already, you should look into specifying a sort order. More information can be found here: http://dev.mysql.com/doc/refman/5.0/en/order-by-optimization.html
-
Have you tried using the offset created here in the query? $start_from = ($page-1) * 20; The query is currently hard coded to always get the first 20 entries: LIMIT 0, 20
-
The error was probably always there, it was likely just hidden in your previous hosting environment. As the error suggests, the second argument for preg_match() needs to be a string. You're passing $_POST which is an array. Is there a specific variable in the POST array that you want to use for the match? If so, you could modify the code to something like this: if( $_POST && preg_match( $matchstring, $_POST['valueToCheck'] ) ) If you're looking to check all variables in the POST array, you could look into using a loop.
-
That sounds like you have multiple tables using the same column name. SQL just wants to know which one you're referring to. For example: $sql_query = "SELECT regelk.leerlingnummer2 FROM regelk, wwspel, overigew...
-
Unless I'm missing something, that's just going to get the time zone for the server which may not match the time zone for the visitor. You could look into using AJAX to communicate with PHP. Or could also look into passing the information through an HTML form.
-
It might help if you let us know what you mean by they don't work properly. Are you getting errors, for example? If so, what are they? What is the unexpected behavior? Based on the code provided, I don't see where $con is defined. You'll need to pass the database connection object to your class and its methods.
-
So are you looking to update an existing entry? If so, try using update instead of insert: http://dev.mysql.com/doc/refman/5.0/en/update.html
-
As Jacques1 mentioned, you should not depend on client-side validation. To make sure the value contains a number, you can use ctype_digit as suggested by kicken. Here is a quick example of how to use the function: if(ctype_digit((string)$_POST['leerlingnummer2'])) { $veld = "leerlingnummer"; $doorgaan = false;
-
Perhaps the MySQL connection was never opened or maybe it was closed for some reason before the query could execute. What does your mysqli_connect.php code look like? Please obscure your database log-in information before posting the code.
-
Sorry, I went a little crazy with responses...so you may have missed Reply 7. Try changing this: $r = mysqli_query($q, $dbc); To this: $r = mysqli_query($dbc, $q);
-
Side note: Just in case you're not aware, your query is currently open to SQL injection attacks. Assuming that $movie_id is supposed to be a number, you can make sure it is with ctype_digit(): http://www.php.net/manual/en/function.ctype-digit.php If the ID isn't a number, display an error. Otherwise, run the query as normal.
-
Ah, it looks like the arguments for mysqli_query() need to be reversed. More information can be found here: http://www.php.net/mysqli_query
-
Have you tried turning on all PHP error. You can do that by adding the following to the top of your script: <?php //REPORT ALL PHP ERRORS error_reporting(E_ALL); ini_set('display_errors', 1); ?> You'll also want to remove the error-suppression characters (@) from your code. And MySQL errors can be displayed using mysqli_error(): http://www.php.net/mysqli_error Also when posting code, please surround it with tags. It makes your posts and code easier to follow.
-
Perhaps the issue is due to calling mysqli_fetch_array() prior to the loop. With how the code is written, the first result is always going to be thrown away. $row = @mysqli_fetch_array($r, MYSQLI_ASSOC); //<-- TRY REMOVING THIS LINE while ($row = @mysqli_fetch_array($r, MYSQLI_ASSOC));{
-
Have you tried adding some debugging statements to see if the query is even being executed? You could do something like this, for example: <?php if($submit){ echo '<div>Executing Query</div>'; $res = mysqli_query($con,$query) or die(mysqli_error($con)); } else { echo '<div>Query Skipped</div>'; } ?> If the "Query Skipped" message is displayed, try echoing the contents of the $_POST array to see if it contains a value for "submit". echo '<pre>' . print_r($_POST, true) . '</pre>';
-
You need to run the query with mysqli_query() before calling mysqli_fetch_array(). More information can be found here: http://www.php.net/mysqli_query Also note that you could use mysqli_fetch_assoc() instead of modifying mysqli_fetch_array() with the MYSQLI_ASSOC flag. More information can be found here: http://www.php.net/mysqli_fetch_assoc
-
Parse error: syntax error, unexpected end of file.
cyberRobot replied to Stylow's topic in PHP Coding Help
It looks like you're missing the end curly brackets for your if and while statements. I would imagine that they're supposed to go near the end. <?php } } get_footer(); ?> Also note that there is a set of mystery brackets after the call to the_content(). <?php the_content(); { } ?> As far as I can tell, these brackets aren't needed.- 1 reply
-
- php
- parse error
-
(and 3 more)
Tagged with:
-
Have you looked into Local Storage? http://www.smashingmagazine.com/2010/10/11/local-storage-and-how-to-use-it/ Note that I haven't used this option myself. I've only seen it used by third-party solutions like JotForm.
-
Side note: in case you're not aware, using PHP_SELF in the form's action tag opens the script to XSS attacks. More information can be found here: http://seancoates.com/blogs/xss-woes
-
embed pdf in page but need html to be on the page also
cyberRobot replied to accend's topic in PHP Coding Help
Have you considered using a third-party solution like FlexPaper? http://flexpaper.devaldi.com/ The PDF could be uploaded there and embedded on a page that has a close button. -
You may also want to check out PHP's parse_url() function: http://www.php.net/manual/en/function.parse-url.php
-
Have you tried just searching for "example.com"?
-
Where is $query supposed to come from? Based on your description, it sounds like it comes from an HTML form. If so, you'll need to use either $_POST or $_GET to get the value for $query. The one you use is based on the "method" attribute for the form. If the form is set to POST, for example, your code might look something like this: <?php $min_length = 3; //min length of the search $query = $_POST['query']; if(strlen($query) >= $min_length){ //... ?> Also note that if the query value comes from a form, you'll want to protect your database from SQL injection attacks. One way to do this is to use mysqli_real_escape_string(). More information can be found here: http://www.php.net/manual/en/mysqli.real-escape-string.php Or you could look into binding with MySQLi.
-
Just in case it was missed, did you see my reply?