Jump to content

bouwob

Members
  • Posts

    16
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

bouwob's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok I was working of "protecting" a directory and was just going to use simple .htaccess protection. Problem is my server is no longer reading the htaccess file (was working befor, but no longer prompts for password). any ideas?
  2. so I have a table that has 7000 rows. part of the app only allows 100 rows to be chosen at a time. so i have page forward and page back links. The problem though is that if I hit back it always goes to the beginning of the table. How can I use limit to select the last 100 rows in a query? using desc is not applicable btw. tia
  3. thank you so much. I have been trying to figure that out for so long. cheers
  4. ok I have this at the top of every page if (!isset($_SESSION['user'])) { session_start(); $_SESSION['user'] = "4"; $_SESSION['browse'] = "4"; echo "ho"; } if (isset($_SESSION['user'])) { echo "hi"; $userid = $_SESSION['user']; } else $userid = ""; if (isset($_SESSION['browse'])) $browseid = $_SESSION['browse']; else $browseid = ""; echo $_SESSION['browse']."----".$_SESSION['user']; when I get to any page I get a printout of "hohi4----4 " and then I have a login page with this code if ($_POST["user"] != "UserName" && $_POST["password"] != "Password") { $query = "select username, userid from users where username = '".$_POST["user"]."' and password = '".$_POST["password"]."'"; $result = querydatabase ($query); while($row = mysql_fetch_assoc($result)) { $username = $row['username']; $userid = $row['userid']; } echo ($username == $_POST["user"]).$userid; if ($username == $_POST["user"]) { $_SESSION = array(); session_destroy(); session_start(); $_SESSION['browse'] = "5"; $_SESSION['user'] = $userid; $whatToDo = "display uname"; } } when I go to that page and login I get a print out of this "11hi5----1" ok everything up untill this point is working as intended. the problem is that when I then click a home link I get "hohi4----4 " when it should say "hi5----1". Are sessions directory sensitive? The home page does not have any other session code other than the 1st section of code I posted. The sessions are dieing when going from the login page to the home page. any ideas? if you go to http://www.nolanryancardmuseum.com/login/index.php you can play around with it. just hit submit to login tia
  5. I have this line while($row = mysql_fetch_row($result)) { echo "<tr><td>".@$row['year']."</td><td>".@$row['Make']." ".@$row['model']."</td><td>".@$row['number']."</td><td>".@$row['extra']."</td></tr>"; } [/php when I run the query that I am using to get the data here are a few of the results [code] CardID year Make number model extra filepath 2 1968 Topps 177 RC/J.Koosman RC 0 3 1968 Topps 177 Milton Bradley Jerry Koosman 0 but with the above line I am getting these messages Notice: Undefined index: Make in public_html/findcards/index.php on line 37 Notice: Undefined index: model in public_html/findcards/index.php on line 37 Notice: Undefined index: number in public_html/findcards/index.php on line 37 Notice: Undefined index: extra in public_html/findcards/index.php on line 37 now I can eliminate the messages with an @ but it isnt giving me any data. If I switch $row['year'] with $row[1] it works out fine. what is the deal? tia
  6. From what I have been reding I see there is no equilivent in php. Somebody talked about needing a framework tool to do something like this but that sounds like it would be alot more trouble than its worth. What I need Year, make, model year as a form select that when changed will query the db to grab all the possable makes for that year. so on and so forth. What is the php magic to achive this. Only need the postback part. Everything else I can hopefully figure out for myself. tia
  7. http://dev.mysql.com/doc/refman/5.0/en/counting-rows.html
  8. or better yet add group by MIN(),MAX(),COUNT(),...)
  9. If your looking for a subquery it would go something like this select * from table1 where table1.something in (select something from table2) You could also use joins but I like the setup of subqueries.
  10. if (preg_match('/([a-zA-Z]+DM)/', $pieces[3], $matches)) { foreach($matches as $match) { $dm = $dm.$match.","; echo $dm; } } B-series, 00, B18C5, Integra Type R USDM this is the data that comes in. but the variable prints out "USDM,USDM" when it should print out only 1. There could be more than 1 match though. such as B-series, 00, B18C5, Integra Type R JDM USDM EDM and that should make $dm = "JDM,USDM,EDM" any ideas tia
  11. I honestly have no idea. The page wont spit out anything. ran it in shell as well as web. no luck with either. How can I tell if I connect? I thought the die took care of that.
  12. ini_set('error_reporting', E_ALL); $fp = fopen('./car.txt','r') or die ("it wont open"); while (!feof($fp) ) { $line = fgets($fp); $fred = preg_replace('/(\S+)(\s\S+)(\s.+)(\s\S+)(\s\S)/','\\1,\\2,\\3,\\4,\\5',$line); $pieces = explode(",", $fred); echo $pieces[0].",".$pieces[1].",".$pieces[2].",".$pieces[3].",".$pieces[4]; $query = "insert into cars(year, make, model, zeroToSixty, querterMile) values ('".trim($pieces[0])."','".trim($pieces[1])."','".trim($pieces[2])."',".trim($pieces[3]).",".trim($pieces[4]).")"; echo $query; $result = querydatabase ($query) or die(echo mysql_error()); } fclose($fp); that seems to just take the text away? How should it be set?
  13. function querydatabase ($query) { $db_host = 'localhost'; $db_name = 'localhost'; $db_user = 'localhost'; $db_pass = 'localhost'; mysql_connect($db_host, $db_user, $db_pass); mysql_select_db($db_name); $result = mysql_query($query) or die(mysql_error()); mysql_close(); return $result; } $fp = fopen('./car.txt','r') or die ("it wont open"); while (!feof($fp) ) { $line = fgets($fp); $fred = preg_replace('/(\S+)(\s\S+)(\s.+)(\s\S+)(\s\S)/','\\1,\\2,\\3,\\4,\\5',$line); $pieces = explode(",", $fred); $query = "insert into cars(year, make, model, zeroToSixty, querterMile) values ('".trim($pieces[0])."','".trim($pieces[1])."','".trim($pieces[2])."',".trim($pieces[3]).",".trim($pieces[4]).")"; echo $query; $result = querydatabase ($query) or die(echo mysql_error()); } fclose($fp); runs once then stops. Never inserts data. I know the query is good so I must have something wrong somewhere. Are the dies in the right place? I am recieveing no errors. I know the query is good, what am I doing wrong
  14. bouwob

    preg troubles

    $fp = fopen('./car.txt','r') or die ("shit wont open"); $fp1 = fopen('./cars1.txt','w'); while (!feof($fp) ) { $line = fgets($fp); # 1988 Acura Legend Coupe L 9.6 17.2 echo preg_replace('^([0-9]{4})\s([a-zA-Z]+)\s(.+)([0-9]{1,2}\.[0-9]{1,2})\s([0-9]{1,2}\.[0-9]{1,2})$', '$1,$2,$3,$4,$5', $line) or die("Error querying database"); fwrite($fp1, preg_replace('^([0-9]{4})\s([a-zA-Z]+)\s(.+)([0-9]{1,2}\.[0-9]{1,2})\s([0-9]{1,2}\.[0-9]{1,2})$', '$1,$2,$3,$4,$5', $line)."\n"); } fclose($fp); fclose($fp1); these regexps are good. (awsome tool but the file does not write. The "dies" are not showing anything. (ps who do I print a trace and error with a die) What am I doing wrong? tia
×
×
  • 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.