Jump to content

lead_zepplin

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Everything posted by lead_zepplin

  1. it was a syntax problem. one thing I noticed jdavidbakr did that I didn't, was in the line mysql_query("UPDATE $tabletofix SET ID='$c' WHERE ID='$id'") or die(mysql_error()); '$id' should have been '$id[0]'. it started working. however, after doing that, adding one more row starts it at the next ID number. I should have known it wouldn't reset the auto-index counter. so the solution, after all, was to truncate the table and reload the data, if I wanted to start again from 1.
  2. that was the first thing I tried. mysql_query("DELETE * FROM tbl") and re-INSERT the data from a file. thanks to auto-increment, it went like this: (original data) 934 935 936 .... 3565 3566 3577 (after delete, make sure the data really is gone) table empty (after importing it all back in) 3578 3579 3580 ... maybe there is a way to delete the data, reset the auto-increment index to 1, then import the data? the other columns don't contain unique values. can't use any of them as a primary key. the code you provided does exactly what my sample code does. the ID column is SMALLINT UNSIGNED, with a maximum value of 65535. I didn't want to use up too much table space with INT. I thought it would be sloppy to just let the numbers keep running as big as they can get. using INT might turn out to be the solution to the problem, but I'd rather re-index them.
  3. I have several tables in a database. one gets large numbers of rows deleted and inserted, and since the index column (ID) is auto-indexed (as it needs to be) the ID numbers are getting much too large much too fast. I need to re-number the rows. the ID doesn't correspond to the rest of the data in a row in any way, ID is not cross-referenced to any other tables, and the database can be taken offline from input/output while doing this. so that's not a problem. but getting it done is a problem. the only way I've found so far is to drop the table and recreate it. I had other ideas, such as simply running a script to re-number the rows. <?php ...connect... $tables = mysql_query("SHOW TABLES"); while ($table = mysql_fetch_assoc($tables)) { foreach ($table as $db => $tabletofix) { $result=mysql_query("SELECT ID FROM $tabletofix") or die(mysql_error()); $c=1; while($id=mysql_fetch_array($result)) { mysql_query("UPDATE $tabletofixx SET ID='$c' WHERE ID='$id'") or die(mysql_error()); $c++; } $c=1; } } mysql_close(); die; ?> a clumsy script like this should get the job done. this one doesn't work. what needs to be changed to get it working?
  4. I am acutely aware of the differences. the app is written to be capable of using either. I already tested the MySQL part of the code, now I am trying to test the MSSQL part of the code. reading data tests part of that.
  5. I'm writing a web app that uses either MySQL or MSSQL databases. I have a MySQL database of my own to test connection and program functionality, but I can't set up a MSSQL database on my server to test. I don't want to go through setting one up on my local computer and putting the app on the web and testing it that way, because I would have to change the code to specify a connection to a specific file on my hard drive. that's too much hassle and the code wouldn't be the same as the finished product which connects to a normal server (full blown MSSQL, not SQL lite or express or whatever) and given a url instead of url+filepath/filename or whatever other hoops I would have to jump through. does anybody know of a test MSSQL database to connect to? simply connecting and reading data is good enough for now, no need to write or create tables. I can't find anything like that on google. for example, the Northwind example database from M$ is very popular. perhaps somewhere it's on a server available to be connected to anonymously?
  6. that was it. I didn't think it was necessary to include on every page. tyvm
  7. I have my php pages set up like this: 1. log in with login.php 2. that sends you to main.php 3. in main.php, there are links to page-a.php, page-b.php, page-c.php, etc. when you type in a password at login.php, it passes your input to main.php. the correct password is hardcoded in main.php. if it matches, a session variable is set, which should be able to be used on page-a.php, page-b.php, page-c.php, etc. to verify that whoever accesses those pages has gone through the login process. if the session variable doesn't match (or null) the user is redirected to the login page. also the session variable is checked (recursively) when accessing main.php, just like the other pages. the problem is, it's as if each page starts over. the session variable does not make it beyond the page that sets it. it should be passed on to the next page but it's not. I used an echo statement in page-a.php to verify and rem'd out the rest of the code. no echo because session value is null, page goes on to load the html. without the code rem'd out it redirects the user to login.php. code: LOGIN.PHP <? session_start(); if(isset($_SESSION['aaa'])) unset($_SESSION['aaa']); ?> <html> <head> <title>title</title> </head> <body> <table width="400" align="center" border="0" bordercolor="#000099" bordercolordark="#000066" bordercolorlight="#6666FF"> <tr bgcolor="#B0C4DE"> <td> <form action="main.php" method="POST"> <p align="center"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif" color="#FFFFFF"><br> Password</font></strong> <input name="pwfield" type="password" value size="20" maxlength=20> <input type="submit" value="Login"></p> </form> </td></tr></table> </body></html> MAIN.PHP <? if ($_SESSION['aaa']!="abcdef") { $password="twinkies"; if ($_POST["pwfield"]==$password) $_SESSION['aaa']="abcdef"; // successful login else {header("Location: login.php"); exit();} } ?> <html> <head> <title>title</title> </head> <body> <a href="page-a.php">Page A</a> <a href="page-b.php">Page B</a> <a href="page-c.php">Page C</a> </body></html> PAGE-A.PHP <? echo $_SESSION['aaa']; //if ($_SESSION['aaa']!="abcdef") //header("Location: login.php"); //exit(); ?> <html> <head> <title>title</title> </head> <body> ...
×
×
  • 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.