Jump to content

s0c0

Members
  • Posts

    422
  • Joined

  • Last visited

    Never

Everything posted by s0c0

  1. Another thing I found is sessions seem to work better if you carry the session using an fqdn or ip.  I experienced problems for instance when going from localhost/page1.php to localhost/page2.php, once I changed the link to mylocalip/*.php everything worked better.
  2. ....so I decided to use sessions instead!
  3. Not sure if I tried that, but I will. Perhaps this is some Suse specific stuff since it defaulted to this. In that case I may try the suse users list.
  4. How often does any IP really change though? comcast its once or twice a year, dsl it's eveyr few days. I think you are okay with the cookie.
  5. I recently upgraded all the way from Suse 10 to Suse 10.2. It seems the default for the version of PHP5 I installed from yast disables error reporting to the browser. I would like it enabled but I cannot figure out how to do this! Can someone help me out please. It is very annoying having to check a log file vs clicking refresh on the browser to debug an app. Let me know if you'd like me to post the php.ini file.
  6. Americans read right to left?  Maybe Bush, but not me.  ;D
  7. How many people really mess with their cookies though? I can't even think of time where I felt the urge to set my cookie to never expire.
  8. I am writing your standard login and insert, read etc... from a mysql database web app. When storing a users login name for queries and the like should I be using cookies or sessions? This is what I read: Since the information my app will be storing is nothing financial or anything serious and if things went well it would be nice to have a cluster of servers should I then be using cookies? For now I will continue writing using sessions, but please do let me know if I should make the switch as it will only take a few minutes of find and replace.
  9. Thankfully I'm persistent and don't give up easily.  I figured out the problem myself. It looks like PHP5 wants to see double quotes and not single quotes for $_SESSION[]. Good: [quote]$_SESSION["user"][/quote] Bad: [quote]$_SESSION['user'][/quote]
  10. Do I need to put the php code in before the html header?  That's what it looks like based on this sticky thread http://www.phpfreaks.com/forums/index.php/topic,37442.0.html The problem with that is I use a loop to draw the html tables based on what the query returns.  I don't think I can put <?php ?> then html followed by more <?php ?> can I?
  11. Are you logged in as root?  If you're logged in as root you should have no problem, otherwise add the user to the mysql.users table with the proper permissions.
  12. For starters that link isn't going to work for anyone but you. Either replace localhost with a FQDN or an IP Address so we can actually see the site.
  13. Which should i use for performing mysql queries etc... via php mysql or the newer mysqli connector.  The book I'm reading tells me to use mysqli, but I read otherwise on the web.  The book is PHP and MySQL web devevlopment by Luke Welling and Laura Thomson. Also is InnoDB better than MyISAM.  I know MyISAM can't do fk-pk relations, so what is it good for?
  14. argh, think of the load even a moderately busy site would put on the server IF a php mp3 player were possible, which I don't think it is, but then again i don't know all that much about php.
  15. Google xspf mp3 player it's an os flash based mp3 player.  Very easy to add to a website (let me know if you need help) and uses the os xspf playlist format.  If that's not to your liking there is one called flam and probably a bunch on sourceforge.net.  You won't find a php based mp3 player since php is server-side.  You instead want a client side player that pulls its mp3's of your server. Now with xspf you will need to generate the playlist from whats stored in your sql db.  I'll assume you have track, artist, file link ( I hope your not storing the mp3 in your mysql db).  To do this programitcally you will need loop through each row  returned and append to xspf file in the proper format. I am not sure what some of the other ones look like.  I think some have direct mysql integration, but i'll leverage the os one.  Ping me if you need help.  I'm working on something very similiar.
  16. I added that to the auth.php page right before the redirect but it made no difference.  I've actually commented out the redirect in place of a link that echo's on to auth.php so I can echo the $_SESSION['user'] array which works.  I don't get it, I'm following the instructions in this book to a T as far as I can see.
  17. I am building a login page, once the user has authenticated against the mysql databse the user is taken to a page with whatever they are storing in the mysql table.  The login page should pass the username using the $_SESSION['user'] array to the next page.  Instead I get the following error: [quote]Undefined index: user in /srv/www/htdocs/mymusic.php on line 10[/quote] Here is the form code on the first page login.php: [code] <form method="post" action="auth.php"> <table> <tr> <td>Username</td><td><input name="username" type="text"></td></tr> <tr> <td>Password</td><td><input name="password" type="text"></td></tr> <tr> <td>&nbsp;</td> <td><input type="Submit" value="Login" /></td></tr> </html> [/code] Here is the code on the second page auth.php: [code] <?php $username = $_POST['username']; $password = $_POST['password']; $con = mysqli_connect('localhost', 'www', 'somepass', 'music'); /* connect to database */         if (!$con){       die('Could not connect: ' . mysql_error()); /* report connection error on failure */         } $con->select_db("music"); /* select database */ $auth_query = "Select * FROM users WHERE username='". $username. "' and password='" .$password. "'"; /* auth query to ivault.users */ $auth = mysqli_query($con, $auth_query); $row = mysqli_fetch_row($auth); $count = $row[0];         if ($row > 0){ /*  login success */                 $_SESSION['user'] = $username; /* create session cookie */                 header("Location: http://192.168.1.134/mymusic.php"); /* browser redirect */         }         else { /* Login failure */                 echo "We're sorry ". $username ." but we were unable to log you in using password ". $password .". Please try again</p>";                 echo "<a href=\"http://192.168.1.134/login.php\">Retry login</a>";         } mysqli_close($con); /* close connection */ exit; ?> [/code] At this point I can comment out the http redirect and echo $_SESSION['user'] to the auth.php page and the correct username is there.  But when I uncomment it and it redirects to the mypage.php page is when I get the error.  Here is the php code for mypage.php: [code] <?php session_start(); $mypage_user = $_SESSION['user']; echo "<p>Thank you for logging in ". $mypage_user ."</p>"; echo"<p><a href=\"upload.php\">Add a Song</a></p>"; $db = mysqli_connect('localhost', 'www', 'layer3', 'music'); /* connect to database */ if (mysqli_connect_errno()) { echo 'Error: Could not connect to the database.'; exit; } ?> [/code] Any help would be awesome as I am stumped.  The auto start session value in php5.ini is set to 0 and I can't see anything else in there that should be causing this. Bonus unrelated question:  Should I be using mysqli or plain mysql php connector?
  18. IDIOT!  Where is the emoticon with the sign that just says stupid.  Thanks for helping me debug that lol.
  19. I get this error: [quote] Fatal error: Call to undefined function mysqi_query() in /srv/www/htdocs/adduser.php on line 14 [/quote] When attempting to run this query against my mysql database: [quote] mysqi_query($con, "CREATE TABLE chris (id MEDIUMINT(9) auto_increment primary key, track VARCHAR(50) not null, artist VARCHAR(50) not null, album VARCHAR(50), year SMALLINT(4), genre VARCHAR(50), filelink VARCHAR(150), playlist VARCHAR(50))"); [/quote] The mysqli connection is working as I am able to perform a query which inserts into a table.  Why am I unable to create a new table in the same database?  I have created a special user for queries against this db and create_priv is on in the mysql.user table.  Even when I try with root I get the same error!  Any ideas?  Let me know if more information is needed.
×
×
  • 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.