
DaveyK
Members-
Posts
289 -
Joined
-
Last visited
-
Days Won
1
Everything posted by DaveyK
-
have you tried just putting header() up without any IFs and see if that even redirects? Just guessing here
-
hey requinix, thanks for the effort (and of course for cleaning it up), and I used what you posted, but somehow I am still getting redirected to the wrong page... I am using this url: http://localhost/blog/title/1 but when I run the $_SERVER variable it turns out I'm on app.php [sCRIPT_FILENAME] => C:/Users/(...)/app.php For reference, the htaccess I am using is: Options +FollowSymlinks <IfModule mod_rewrite.c> RewriteEngine On # Remove the .php extension RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^([^.]+)$ $1.php [NC,L] # Blog articles RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^blog/([^/]+)/(\d+)$ blog.php?title=$1&id=$2 [L] #RewriteCond %{REQUEST_FILENAME} !-f #RewriteCond %{REQUEST_FILENAME} !-d #RewriteRule ^(.*)$ index.php?page=$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ app.php?tag=$1 [QSA,L] </IfModule> # ---------------------------------------------------------------------- # Custom 404 page # ---------------------------------------------------------------------- # You can add custom pages to handle 500 or 403 pretty easily, if you like. ErrorDocument 403 /error.php?type=403 ErrorDocument 404 /error.php?type=404 ErrorDocument 500 /error.php?type=500 Am I doing something wrong?
- 9 replies
-
- htaccess
- vanity url
-
(and 1 more)
Tagged with:
-
Oh sorry barand, I totally missed that.
-
are p1, p2, p3 and such ids of rows or the names of columns?
-
what is the difference between the tbl_tof and tbl_def table?
-
As barand stated: $sql=mysql_query("SELECT * FROM TABLE WHERE id IN (1,2,3)"); this will return 3 results (if they exists), where id = 1 OR id = 2 OR id = 3. However, Barand, wouldn't this: $sql = "SELECT * FROM TABLE WHERE id IN ($list)"; require an implode() ?
-
What are the errors? Also, you can simply consider using two selects inside your FROM
-
No one benefits from sarcastic posts, get over it. The way I look at it, relating it to games: - One uses a cron job to calculate something that is publicly available. For instance, a score in a leaderboard in a game. Its imporatnt that this is always up to date even if the user itself is no longer online - One uses a regular page load /script to calculate stuff that only the user itself sees. For instance, the "resources" I have for a game. I dont care if I have a lot of them, or even a little. As long as the number is correct the moment I log in, I will not see any difference. In this case, I dont see how a cron job would improve the script.
-
Help combining data from 2 tables... I keep failing!
DaveyK replied to DBookatay's topic in MySQL Help
The error is there because mysql_query() is failing. Use this code to find out what the actual error is: $result = mysql_query($query) or die(mysql_error()); -
If you ask me, if the tickets you are referring to are not publicly visible I would not use a cron job, simply because no one cares and the script is the same.
-
where table two only holds the info as to what rank what position has... SELECT * FROM $tablename as t1 LEFT JOIN $tabletwo AS t2 on t1.Position = t2.Positions WHERE t1.TimeOut = '0000-00-00 00:00:00' AND t1.Location = '$location' ORDER BY t2.Rank DESC and this doesnt work?
-
Could you add the table structure(s) you are using?
-
Hey guys, I'm in the process of creating a website and Im currently adding a blog. I have the htaccess working so far, but I dont know how to add another condition for the blog and htaccess is really tricky for me... regardless, this is current htaccess: <IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine On </IfModule> # If requested resource exists as a file or directory, skip next two rules RewriteCond %{DOCUMENT_ROOT}/$1 -f [OR] RewriteCond %{DOCUMENT_ROOT}/$1 -d RewriteRule (.*) - [s=2] # Remove the .php extension RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L] #RewriteCond %{REQUEST_FILENAME} !-f #RewriteCond %{REQUEST_FILENAME} !-d #RewriteRule ^(.*)$ index.php?page=$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ app.php?tag=$1 [QSA,L] # ---------------------------------------------------------------------- # Custom 404 page # ---------------------------------------------------------------------- # You can add custom pages to handle 500 or 403 pretty easily, if you like. ErrorDocument 403 /error.php?type=403 ErrorDocument 404 /error.php?type=404 ErrorDocument 500 /error.php?type=500 This works, though I have no idea if its in any way correct. What I need is a normal vanity url thing which would rewrite /blog/some-blog-title-here/1 to /blog.php?title=some-blog-title&id=1 but obviously the user would see the first option. Any help or suggestions?
- 9 replies
-
- htaccess
- vanity url
-
(and 1 more)
Tagged with:
-
The issue is the fact that, if there are no IDs specified, the sql you generate dynamically is not valid. So thats where you need to start, where you generate your sql.
-
I see. The issue you are facing is caused because you have nothing in your cart "SELECT * FROM products WHERE id IN) ORDER BY id ASC" is not a valid SQL query. It is supposed to be: "SELECT * FROM products WHERE id IN (id1, id2) ORDER BY id ASC" <-- In case of Ids OR "SELECT * FROM products ORDER BY id ASC" <-- in case of no Ids So you need to edit this block of code to get the above result: if(isset($_SESSION['cart'])){ $sql = "SELECT * FROM products WHERE id IN("; foreach($_SESSION['cart'] as $id => $value){ $sql .= $id. ","; } $sql = substr($sql,0,-1). ") ORDER BY id ASC"; In summary: Right now you re always adding the WHERE IN, while in fact you are not supposed to add that if there are no IDs in the cart. Let me know if you do not understand or dont know where to start.
-
Header('Location'); redirects the user, so the (update) query right after the header() wont even run...
-
Well, its obvious that the SQL is indeed not correct. It would be easier to recognize if you did this: $sql = substr($sql,0,-1). ") ORDER BY id ASC"; $query = mysql_query($sql) or die(mysql_error()); In between those lines, perform a var_dump($sql);die();. So: $sql = substr($sql,0,-1). ") ORDER BY id ASC"; var_dump($sql);die(); $query = mysql_query($sql) or die(mysql_error()); This will show the entire SQL query without actually running it. Please post it back here!
-
The issue is not really on line 72, its on line 70: $query = mysql_query($sql); this is returning FALSE, which is a BOOLEAN and not a resource. mysql_fetch_assoc() can not proccess such boolean and in return, it fails. Use this line and see what pops up: $query = mysql_query($sql) or die(mysql_error()); This will echo the mysql_error() when mysql_query() fails. I presume you are facing a query issue.
-
I am pretty sure that this is done through JS. I would suggest an onchange event followed by an ajax call to fetch the info. You say JS didnt work, what did you try? But, unless you have SQL related issues, you may want to ask this thread to be moved!
-
If you use a unique identifier (and you should), isnt that enough for a version? If you want the last, just use ORDER BY id DESC and limit the result to 1 row. That should fetch the most recent (highest ID) row.
-
http://php.net/function.include Appearantly you need to set "allow_url_fopen"
-
Quick Question About Session Variables & Posting Through PHP Form
DaveyK replied to jdlev's topic in MySQL Help
can you post the form file? -
PHP MYSQL get a users first name and surname from their user ID
DaveyK replied to dannyp100's topic in PHP Coding Help
Maybe I am not following this thread correctly but... <?php function getNameFromID1($userID){ include 'gradnetconn.php'; $query = ("SELECT CONCAT(userFirstName, ' ', userSurname) AS full_name FROM gn_users INNER JOIN gn_messages WHERE userID = messageFrom"); $result = mysql_query($query); while($row = mysql_fetch_array($result)) { return( $row['full_name']); } } ?> this function has a variable $userID but you don't even use it in the query. You may wanna start with that. EDIT: Also the JOIN does not have an ON clause. -
Connect to a mysql database // connect to the db mysql_connect(database, username, password) or die(mysql_error()); mysql_select_db(table_name) or die(mysql_error());
- 10 replies
-
- mysql
- single value
-
(and 2 more)
Tagged with:
-
Quick Question About Session Variables & Posting Through PHP Form
DaveyK replied to jdlev's topic in MySQL Help
Why would you post a session to a hidden field? The session will exist throughout the pages so you should just be able to use it on the other page. Also, input values can be changed using firebug, so if you would use this method, a user would be able to change the variable in that hidden input and be anyone he wants to be.