Jump to content

scm22ri

Members
  • Posts

    89
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

scm22ri's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi Everyone, I have a form on my website where I allow people in insert information. That information will go into my database. My question is, how do I make sure the user/visitor isn't inputting apostrophe's into my database? Below I'm using the ergi_replace function which doesn't seem to work. What else can i do? $variable = stripslashes($variable); $variable = mysql_real_escape_string($variable); $variable = eregi_replace("'", " ", $variable); Thanks
  2. Hi Everyone, How would I go about accounting for a folder in my .htaccess? Meaning this is my domain mydomain.com mydomain.com/products/hot/cakes Should my htaccess code look like this? RewriteRule ^/products/^([_a-zA-Z]+)/([^/]*)$ script.php?product=$1&inventory=$2 [L] maybe this? RewriteRule ^/products/([_a-zA-Z]+)/([^/]*)$ script.php?product=$1&inventory=$2 [L] What am asking is this, how would I go about accounting for the actual folder that I want to put in-front of my URL? Thanks
  3. Thanks requinix, php function trim did the trick!
  4. Hi Everyone, I'm interested in replacing white space after a certain set of characters. The characters aren't a set number, they change depending on what the user types into the form. How would I go about doing that with str_replace? Is it even possible with str_replace or perhaps another function? $value = New York (I don't want to replace the white space between the w and Y but I do want to replace the white space after k if a user uses the space key) $value = str_replace(' ', '', $value); Thanks Everyone
  5. Hi Everyone, I know this question is kinda old but this is what I'm attempting to do. My only concern is when I have a default value 0. The item my user is inputting into the database via a form is automatically displaying on my website. It's my understanding if a item has a default value of 0 shouldn't my MySql database know not to show that item without me approving it first? aka turning the 0 into a 1? The structure of my column. My column is called 'approve' Type ENUM Length/Values '0','1' Default As Defined 0 With a setup like this shouldn't MySql know now to show the items that have a mark of 0?
  6. Hi Everyone, I have a question regarding echoing statements for my website. For some reason my website is echoing out statements that are unrelated to my website. For example, if you visit my website and type in whatever after the /(slash) Google is indexing the term "whatever" A few examples are http://www.mydomain.com/whatver http://www.mydomain.com/advices http://www.mydomain.com/review_ratings http://www.mydomain.com/widgets http://www.mydomain.com/terms_and_conditions http://www.mydomain.com/latest_news http://www.mydomain.com/users/frontend_change_year http://www.mydomain.com/put_whatever_you_want_here_because_google_will_index_it I can go on and on but I think you get the point of what I'm doing. Often times, on my landing page it will say "Latest News", "Whatever", "Review Ratings", "Widgets" etc... In other words, it's echoing out the keyword that's associated with the URL. My question is, how would I go out stopping/fixing this? Thanks Everyone.
  7. Hi PFMaBiSmAd, Thanks for the reply and help. I changed every URL link path to my domain. Some pages I had www, http://, .mydomain.com, / etc ... I changed everything to / and my problem seems to have fixed itself, which I'm happy about. Thanks. This is a little concerning because my phpinfo.php page is still saying session.cookie_domain Local Value > No Value | Master Value > No Value session.cookie_path Local Value > / | Master Value > / It's currently working but the cookie_domain and cookie_path aren't set correctly. Perhaps I'm still doing something wrong? I'm not sure what to make of this. Maybe my mydomain.phpinfo.php page didn't update itself? (although it's been 3-4hrs approx.) Thanks again
  8. Hi Everyone, Thanks for the help. Muddy_Foster, The reason why the session is commented out is because I didn't want to create duplicate pages. It's my understand every time a session is created it creates a unique ID onto that page and the major search engines don't like that. I've also tried this code with the session_start(); on for the inventory page and it still does not work. Perhaps maybe it's this page that's causing the problem? or am I totally wrong when I say that? You should check if the $_SESSION['id'] is actualy set rather than checking if the $user != 0 by using I did just that and it does not seem to be working. I'm testing a few things and changing the syntax around a bit on my get-inventoryphp page. What do you think I'm doing wrong here? Thanks everyone. Below is my syntax for get-inventory.php <?php session_start(); echo 'BEFORE-------------------------------------START><BR>'; print_r($_SESSION); echo 'BEFORE-------------------------------------END><BR>'; include "connect_to_mysql.php"; echo 'AFTER-------------------------------------START><BR>'; print_r($_SESSION); echo 'AFTER-------------------------------------END><BR>'; $_SESSION["pageurls"] = "$url"; $url = $_SERVER["REQUEST_URI"]; $loggedinuser = $_SESSION['id']; $username = $_SESSION["username"]; $carnumber = $_GET["carnumber"]; echo '<!DOCTYPE html> <html> <head> <title>Title goes here</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="description" content="description goes here" /> <meta name="keywords" content="keywords go here" />'; include 'header.php'; ################################## ## what actually is the $loggedinuser value ## ################################## echo '<BR> '.'>>>>>>>>>'.$loggedinuser.'<<<<<<<<<'.' <BR>'; ################################## ## ## ################################## if(isset($_SESSION['id'])) //checking if user is logged in? { echo "$loggedinuser".'<br>'; echo "$carnumber".'<br>'; echo "Your logged in!"; } else if (!isset($_SESSION['id'])) {//Not logged in echo "User is not logged in show loggin page link <a href=\"loginURL.php?url=$url\">Please login!</a><br>"; } ?> <?php include 'footer.php'; ?>
  9. Hi, I'm trying to figure out why my website isn't displaying a registered user. When I visit a specific page on my website, the page is displaying a message that I'm not logged in but when I visit other pages of my website I'm clearly logged in. My question is, how would I fix this? Right below is the syntax of the php page that's giving me a problem. Below this syntax is syntax of a page a visitor is most likely coming from to visit the "get-inventory.php" page. The "get-inventory.php" I believe is the problem page. get-inventory.php page <?php session_start(); echo 'BEFORE-------------------------------------START><BR>'; print_r($_SESSION); echo 'BEFORE-------------------------------------END><BR>'; // include "connect_to_mysql.php"; echo 'AFTER-------------------------------------START><BR>'; print_r($_SESSION); echo 'AFTER-------------------------------------END><BR>'; include "connect_to_mysql.php"; // $url = $_SERVER['REQUEST_URI']; // $_SESSION['pageurls'] = "$url"; $user = $_SESSION['id']; $car_id = $_GET["car_id"]; include 'header.php'; if ($user !=0){ // notes to myself // include 'header.php'; if I leave out the header.php within the if statement the header does not appear which means I'm def. not logged in. // But my question is why aren't I logged in if I already signed in earlier? // header('Location: http://mywebsite.com/class-work/sign3/valchecklogin.php'); //just redirect the user to thelogin page // header('Location: http://mywebsite.com/loginURL.php?url='.$url.''); echo "$car_id".'<br>'; echo "$user".'<br>'; echo "Your logged in"; // exit(); }else{ echo "$car_id".'<br>'; echo 'Your not logged in'.'<br>'; echo 'click on "Reg" or "Login" and you\'ll see I\'m logged in.'.'<br>'; // exit(); } include 'footer.php'; ?> >>>>> inventory.php page syntax (from this page most visitors will be visiting the above "get-inventory.php" page). I'm not sure if this page is causing the problem but I figured I would add it in here. <?php // session_start(); // $url = $_SERVER['REQUEST_URI']; //Getting Page url and storing in $url variable. // $_SESSION['pageurls']= "$url"; //Now storing that $url variable in SESSION. // $loggedinuser = $_SESSION['id']; include"connect_to_mysql.php"; $state = $_GET["state"]; $city = $_GET["city"]; $year = $_GET["year"]; $make = $_GET["make"]; $model = $_GET["model"]; // for making "pretty" URLS $state = str_replace (' ','_', $state); $city = str_replace (' ','_', $city); $model = str_replace (' ','_', $model); /* $state = str_replace (' ', '', $state); $city = str_replace (' ', '', $city); $make = str_replace (' ', '', $make); $model = str_replace (' ', '', $model); */ /* $state = str_replace (' ', '_', $state ); $city = str_replace (' ', '_', $city ); $year = str_replace (' ', '_', $year ); $make = str_replace (' ', '_', $make ); $model = str_replace (' ', '_', $model ); */ /* $state = str_replace (' ', '_', $state); $city = str_replace (' ', '_', $city); $model = str_replace (' ', '_', $model); */ //////////////// Below is the function function capit($element) { $element = strtolower($element); return ucwords($element); } //////////////// Above is the function $state = capit($state); $city = capit($city); $year = capit($year); $make = capit($make); $model = capit($model); ?> <!DOCTYPE html> <html> <head> <title><?=$year?> <?=$make?> <?=$model?> <?=$city?> <?=$state?></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="description" content="<?=$city?> <?=$state?> <?=$year?> <?=$make?> <?=$model?> " /> <meta name="keywords" content="<?=$city?>,<?=$state?>,<?=$year?>,<?=$make?>,<?=$model?> " /> </head> <body bgcolor="#FFFFFF" text="#000000"> <?php include 'header.php'; $sql = mysql_query ("SELECT d.id AS car_id, d.year, d.make, d.model, p.value AS price, p.exterior_color, p.interior_color, p.engine, p.mileage, p.transmission, p.gas_type, p.state, p.city FROM tbl_car_description d, tbl_car_prices p WHERE (d.id = p.cardescription_id) AND (p.state = '".$state."') AND (p.city = '".$city."') AND (d.year = '".$year."') AND (d.make = '".$make."') AND (d.model = '".$model."')"); while($row = mysql_fetch_array($sql)){ $car_id = $row["car_id"]; $year = $row["year"]; $make = $row["make"]; $model = $row["model"]; $price= $row["price"]; $exteriorcolor = $row["exterior_color"]; $interiorcolor = $row["interior_color"]; $engine = $row["engine"]; $mileage = $row["mileage"]; $transmission = $row["transmission"]; $gastype = $row["gas_type"]; $state = $row["state"]; $city = $row["city"]; echo "$car_id".'<br>'; echo "$year".'<br>'; echo "$make".'<br>'; echo "$model".'<br>'; echo "$price".'<br>'; echo "$exteriorcolor".'<br>'; echo "$interiorcolor".'<br>'; echo "$engine".'<br>'; echo "$mileage".'<br>'; echo "$transmission".'<br>'; echo "$gastype".'<br>'; echo "$state".'<br>'; echo "$city".'<br>'; echo "<a href ='http://www.mywebsite.com/get-car3.php?car_id=$car_id'>Sell this car!</a>".'<br>'; } echo "The below URL link is hardcoded".'<br>'; echo "<a href ='http://www.mywebsite.com/get-car3.php?car_id=6'>-Sell this car!</a>".'<br>'; ?> <?php include 'footer.php' ?>
  10. Hi Everyone, I'm trying to figure out how to have a dash or hyphen in between two words in my URL. I did this correctly in my longer URLS but for some reason I can't figure out what I'm doing wrong when it comes to my shorter URLS. To better explain, I've listed my examples below. Any help would be appreciated. Thanks URL words but no data is showing. http://whatsmyowncarworth.com/new-york Working http://whatsmyowncarworth.com/massachusetts // notice the - in between "cape code". I can't get that same -(dask aka hyphen) for new-york or rhode-island http://whatsmyowncarworth.com/massachusetts/cape-cod http://whatsmyowncarworth.com/vehicle-display.php What am I doing wrong here? RewriteEngine On RewriteRule ^([-a-zA-Z-]+)$ state.php?state=$1 [L] RewriteRule ^([-a-zA-Z-]+)/([-a-zA-Z-]+)$ city-breakdown.php?state=$1&city=$2 [L]
  11. Hey Guys, Thanks a lot for helping me out with .htaccess. It's working but for some reason my CSS isn't working? It seems the city pages aren't displaying properly. I'm not sure what the problem is, could it even be my CSS? or perhaps it's my .htaccess? What do you guys think? (state page is fine) http://whatsmyowncarworth.com/rhode_island (city pages aren't displaying my CSS) http://whatsmyowncarworth.com/rhode_island/cranston http://whatsmyowncarworth.com/rhode_island/cumberland http://whatsmyowncarworth.com/rhode_island/east_providence http://whatsmyowncarworth.com/rhode_island/east_greenwhich http://whatsmyowncarworth.com/rhode_island/exeter
  12. Hey Marcus, Thanks for the help. I did what you said and the URL links work now but the data isn't showing up on my website. Could this be because of the htaccess file? http://whatsmyowncar...om/rhode-island http://whatsmyowncarworth.com/new-york RewriteEngine On RewriteRule ^([-a-zA-Z_]+)$ state.php?state=$1 [L] RewriteRule ^([a-zA-Z_]+)/([a-zA-Z_]+)$ city-breakdown.php?state=$1&city=$2 [L]
  13. Hi, I have a question regarding .htaccess. I'm attempting to make pretty URLS. I'm almost half way there but I can't quite seem to figure how to add a "dash" - to certain keywords. On the below page http://whatsmyowncar...cle-display.php How would I turn http://whatsmyowncar...th.com/new york into http://whatsmyowncarworth.com/new-york Below is my .htaccess file. Any help would be appreciated. Thanks. RewriteEngine On RewriteRule ^([a-zA-Z_]+)$ state.php?state=$1 [L]
  14. Hi Everyone, I've figured out how to re write a url correctly to my website. The problem is no content is showing on the page. I want to take the below URL http://whatsmyowncar...te=rhode island and turn it into this one (I think I've accomplish that but on the below URL, the page is showing no data). I figred my .htacess was a bit off but I'm not sure how. What am I doing wrong here? http://whatsmyowncar...om/rhode-island RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]*)$ /state.php?s=&u=$1 [L,NC]
  15. Hi Everyone, I'm trying to figure out the correct syntax when it comes to displaying an image on my website. When I hard code the number in it works but when I add the variable $id it's not working. // Not working echo '<div align="center"><img src="photos'. $id . rand(1,3) . '.jpg" width="250" alt="Random Image" /></div></td>'; echo '<div align="center"><img src="photos'. $id .''. rand(1,3) . '.jpg" width="250" alt="Random Image"/></div></td>'; echo '<div align="center"><img src="photos'.$id. rand(1,3) . '.jpg" width="250" alt="Random Image" /></div></td>'; echo '<div align="center"><img src="photos/'.$id.'/'.echo rand(1,n);'.jpg" width="250" /></div></td>'; echo '<div align="center"><img src="photos/'. $id . rand(1,3) . '.jpg" width="250" alt="Random Image" /></div></td>'; //Works but only when I hard code the number 4 (but I can't have that because every photo is in a different folder. echo '<div align="center"><img src="photos'. '/4/' . rand(1,3) . '.jpg" width="250" alt="Random Image" /></div></td>'; Any help would be appreciated, thanks! Hey Everyone, I finally solved the problem. The correct syntax is echo '<div align="center"><img src="photos/'. $id .'/'. rand(1,3) . '.jpg" width="250" alt="Random Image"/></div></td>';
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.