Jump to content

HuggieBear

Members
  • Posts

    1,899
  • Joined

  • Last visited

Everything posted by HuggieBear

  1. Allow them to use .htaccess to log in to the central database and once authenticated, pass the username to your database using the $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW'] within PHP. Regards Huggie
  2. OK, I used the file you provided with the following SQL... [color=blue]INSERT INTO cc (email) SELECT DISTINCT email FROM bb[/color] ...and it worked fine.  There's nothing wrong with that code. Regards Huggie
  3. PHP can be used to execute system calls, so if your USB device has a command line interface, you can call it using PHP by using the [url=http://uk.php.net/manual/en/function.system.php]system()[/url], [url=http://uk.php.net/manual/en/function.exec.php]exec()[/url] or [url=http://uk.php.net/manual/en/function.shell-exec.php]shell_exec()[/url] commands. Regards Huggie
  4. Oh yeah, sorry, I missed out your result resource.  That's copying and pasting for you :) Regards Huggie
  5. Tom, Does the user need to know the time?  I'm assuming you're inserting this into a database of some type, in which case just use a timestamp field in the database for when the row is inserted and then when you display the record format it accordingly. Regards Huggie
  6. Can you produce a data dump of the new table you've created in phpMyAdmin and then post it here. Regards Huggie
  7. You're using the wrong function... [color=red]mysql_affected_rows()[/color] only works after INSERT, UPDATE, REPLACE or DELETE statements.  For SELECT statements you want to use [color=blue]mysql_num_rows()[/color] Use this: [code]<?php // Connect to db @mysql_connect("mysql.aacapartsandsupplies.com", "admin", "******") or die("Cannot connect to DB!"); // Select db @mysql_select_db("tokens") or die("Cannot select DB!"); // Run query $sql = "SELECT username FROM user WHERE username='$username' and passwd=sha1('$passwd')"; $r = mysql_query($sql); if(!$r){   $err=mysql_error();   echo $err;   exit(); } // Check if user exists if(mysql_num_rows() == 0){   echo "no such login in the system. please try again.";   exit(); } else{   echo "successfully logged into system.";   // present information to the user } ?>[/code] Regards Huggie
  8. OK, that's because $youritemidrow isn't an array.  You'll need to use a while loop to loop through $youritemsrow. If you're not sure how then let me know. Regards Huggie
  9. The code looks fine to me.  What happens if you execute it in phpMyAdmin? Regards Huggie
  10. The delete syntax looks like this... [color=blue]DELETE FROM table_name WHERE column_name = condition[/color] So try this: [code]<?php include('../config.php'); $sql = "DELETE FROM player WHERE player_id = '".$_GET['player_id']."'"; $result = mysql_query($sql); echo "Billede er slette. <a href='player_edit.php?player_id=".$_GET['player_id']."'>klik her for at vende tilbage.</a>"; ?>[/code] This will delete the whole row.  If you just want to change the value of one column, then use an update statement... [code=php:0]$sql = "UPDATE player SET picture = null WHERE player_id = '".$_GET['player_id']."'";[/code] Regards Huggie
  11. I've posted the following in the Installation forum: http://www.phpfreaks.com/forums/index.php/topic,121128.0.html Now I know that cross topic posting isn't usually allowed, but I do need 'PHP help', this forum gets a lot more views than the Installation board and doing a search I can see that people requesting files in this forum have been helped rather than shunned, hence the post. I've googled for the file and I can't locate it anywhere on the web. Regards Huggie
  12. I see what you mean, that's certainly why it's not uploading it.  I think I'll look into this a bit further for you tomorrow when I get to work, as I had a similar problem myself. Regards Huggie
  13. If you echo out $_FILES['upload']['type'] have you definitely copied down the file type correctly? Regards Huggie
  14. [quote author=kenrbnsn link=topic=121536.msg499878#msg499878 date=1168277783] PHP doesn't allow variable names that begin with numbers. [/quote] Now I feel stupid, I was in coding mode, making sure everything was syntactically correct, I completely glossed over that fact.  :-X Regards Huggie
  15. [quote author=joebudden link=topic=121527.msg499859#msg499859 date=1168273172] I see what ur sayin Huggie, but cant this just be done on the page??? [/quote] Now you've posted your code, I can see you're using sum() to get the total size currently in use, so just use the code that I provided, only select one column, not the second one that I added. Regards Huggie
  16. OK, so lets say the list in your database looks like this... 1,2,4,8,16,32 Would you want it like this: $1 = 1 $2 = 2 $3 = 4 $4 = 8 $5 = 16 $6 = 32 Or this: $1 = 1 $2 = 2 $4 = 4 $8 = 8 $16 = 16 $32 = 32 If I've read it right and it's the latter, then give this a try... [code]<?php // Select csv's from database $sql = "SELECT column_name FROM table_name"; $result = mysql_query($sql); $row = mysql_fetch_array($result, MYSQL_ASSOC); // Put each element into an array keyed on number $values = explode(",", $row['column_name']); // Make a variable out of each value forach ($values as $k => $v){   $$v = $v; } ?>[/code] All you need to do is replace my query with yours and change [code=php:0]$row['column_name'][/code] to the name of yor column. Regards Huggie Regards Huggie
  17. This is because the header.php gets included/required as if it were in the same directory as the file calling it. Regards Huggie
  18. [quote author=Fearsoldier link=topic=121531.msg499847#msg499847 date=1168272457] Before inserting the information use a select query, call the values you want to check and then compare them with the variables you already have defined. [/quote] A query is a good idea, but a comparison isn't.  A row count would be easier in this situation... Example: A user enters their email address (unique column in the database)... [code]<?php $sql = "SELECT * FROM member_details WHERE email = '$user_entered_email_address'"; $result = mysql_query($sql); if (mysql_num_rows($result) > 0){   // Sorry, the row exists, maybe display the form again } else {   // The row doesn't exist, maybe put your insert code in here } ?>[/code] Regards Huggie
  19. [quote author=joebudden link=topic=121527.msg499842#msg499842 date=1168272220] there is no column "dbEmployeeCurrent" ----    Huggie [/quote] No, but if you want to check if a user is going over their quota, you must have the running total of what they're using stored somewhere right? Huggie
  20. Maybe php doesn't like the data types.  You could try this: [code]<?php // Get the limit from the database $query = "SELECT dbEmployeeQuota AS quota, dbEmployeeCurrent AS current FROM employee WHERE dbEmployeeId='".$_SESSION['sessEmployee']['id']."'"; $equota = mysql_query($query); $row = mysql_fetch_array($equota, MYSQL_ASSOC); $quota = intval($row['quota']); $current = intval($row['current']); // does the file exceed that users file storage limit $fsize = intval($_FILES['frmFile']['size']); if (($fsize + $current) >= $quota){   echo "Error, this file will exceed your total file size   echo "<p>" . '<a href="viewuploads.php">' . "View Uploads" . "</a></p>";   return; //a return here terminates the execution of this page. } ?>[/code] Notice that I've included the current quota in the sql query to the database, as I'm assuming this is where you're storing the information.  You just need to alter the column name to the one in your db table Regards Huggie
  21. How about showing us your upload code so we can check it for errors? Regards Huggie
  22. My advice would be to try this code.  I've added a few comments too. [code]<?php // Start the session session_start(); // Check that the user is authenticated if (!isset($_SESSION['userid']) or $_SESSION['userid'] ==''){   exit('You must be signed in to do that'); } $username = $_SESSION['username']; // While trouble shooting, dump the variable to check values are OK echo "<pre>"; print_r($_FILES); echo "</pre>"; // Make sure the file that's uploaded is either .gif or .jpg if (eregi('^image/p?jpeg(;.*)?$', $_FILES['upload']['type']) OR eregi('^image/gif(;.*)?$', $_FILES['upload']['type'])){   // Decide what the extension is going to be   if (eregi('^image/p?jpeg(;.*)?$', $_FILES['upload']['type'])) {       $extension = '.jpg';   }   else {       $extension = '.gif';   }   // Compose the new file name   $filename = 'avatars/' . $username . $extension;   // Check the file's been uploaded   if (is_uploaded_file($_FILES['upload']['tmp_name'])){       // Copy it to its new location       if (copy($_FILES['upload']['tmp_name'], $filename)){         echo 'Avatar uploaded succesfully';       }       else {         echo 'Unable to copy avatar to its new location';       }   }   else {       echo 'Avatar could not be uploaded';   } } else {   echo "You must upload a .gif or .jpeg file";   exit; } ?>[/code]
  23. You need to change all instances of [code=php:0]$_FILES['upload'][/code] to [code=php:0]$_FILES['uploadedfile'][/code] as that's the field name in your form. So this: [code=php:0]if (eregi('^image/p?jpeg(;.*)?$', $_FILES['upload']['type']){[/code] Would look like this: [code=php:0]if (eregi('^image/p?jpeg(;.*)?$', $_FILES['uploadedfile']['type']){[/code] Regards Huggie
  24. Alternatively, does anyone have a copy they can send me, I guess it would need to be compiled on a SPARC Solaris 10 box.  If anyone can help by sending me this I'd really appreciate it. Regards Huggie
  25. It's still not valid... That query now looks like this: SELECT COUNT(*) AS total FROM news_stories WHERE select * from news_stories where section like '%$section%' AND unix_timestamp(published) <= unix_timestamp(NOW()) AND ( headline LIKE '%$searchstring%' OR story_text LIKE '%$searchstring%' ) Order by id Asc Try this... [code] <?php $search_query = "SELECT * FROM news_stories WHERE section LIKE '%$section%' AND unix_timestamp(published) <= unix_timestamp(NOW()) AND ( headline LIKE '%$searchstring%' OR story_text LIKE '%$searchstring%' ) ORDER BY id"; $result = mysql_query($search_query); $result_count = mysql_num_rows($result); ?>[/code] Regards Huggie
×
×
  • 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.