Jump to content

MCP

Members
  • Posts

    60
  • Joined

  • Last visited

    Never

Everything posted by MCP

  1. [code] if (strlen($_POST['password'])==0){   mysql_query("some query that doesn't do password update"); } else {   mysql_query("some query that does a password update"); } [/code] that's the way most sites do it, I gather.
  2. what corbin said, except that there is a built in function [url=http://www.php.net/nl2br]nl2br[/url] which will do just that
  3. [quote]I've seen a file "encrypted" like that before, it's not as easy as it looks to "decrypt" it again, at least not if it is the same way it's done.[/quote] If you have a sample, I'd like to have a look at it -- sounds kind of interesting!
  4. [quote author=corbin link=topic=120607.msg494976#msg494976 date=1167700661] There has to be  backup to do that htough which makes another step [/quote] backup? I don't think so... The database will handle everything without any sort of "backup". Whatever it does behind the scenes is not important -- there's no additional steps from a user point of view. ProjectFear -- what sort of tests are you performing on your data?
  5. From a DB theory point of view, I believe the preferred method would be roughly: ----- start transaction delete old table insert new rows into the table if error then rollback transaction else commit transaction -----
  6. wisewood has it from his first post. From the snippet provided, it's just base64 encoded (hardly call that 'encrypted'!). You just need to base64_decode those. As previously mentioned, replace the "eval" with "echo"/"print", and you'll see the code in your page. I decoded the JF9YP... part, and it comes out to "$_X=base64_deco", so it looks like he may have base64 encoded it a couple times -- but it's hard to tell without seeing more of the encoded string. See for yourself using [url=http://makcoder.sourceforge.net/demo/base64.php]http://makcoder.sourceforge.net/demo/base64.php[/url]. The original opinionatedgeek.com site didn't work for me earlier on another base64 encoded string, but this one did, and worked for decoding your snippet above. So, I'd suggest you either try to do the eval -> echo/print replacement, post the code, or PM one of the people who offered their help (count me in)... Good luck!
  7. This should allow you to do handle anything in the fields: [code=php:0] $customer_id = str_replace("'","''",$customer_id); $customer_lname = str_replace("'","''",$customer_lname); $customer_fname = str_replace("'","''",$customer_fname); $customer_address = str_replace("'","''",$customer_address); $customer_city = str_replace("'","''",$customer_city); $customer_state = str_replace("'","''",$customer_state); $customer_zip = str_replace("'","''",$customer_zip); $customer_phone = str_replace("'","''",$customer_phone); $alt_phone = str_replace("'","''",$alt_phone); $admin_user = str_replace("'","''",$admin_user); $computer_problem = str_replace("'","''",$computer_problem); $trc_store = str_replace("'","''",$trc_store); $customer_passwd = str_replace("'","''",$customer_passwd); $date_in = str_replace("'","''",$date_in); $date_completed = str_replace("'","''",$date_completed); $customer_call_1 = str_replace("'","''",$customer_call_1); $customer_call_2 = str_replace("'","''",$customer_call_2); $work_completed = str_replace("'","''",$work_completed); $work_completed_1 = str_replace("'","''",$work_completed_1); $work_completed_2 = str_replace("'","''",$work_completed_2); $tech_assigned = str_replace("'","''",$tech_assigned); $reason_for_call_1 = str_replace("'","''",$reason_for_call_1); $reason_for_call_2 = str_replace("'","''",$reason_for_call_2); $query = "Insert into pc_completed values ('$customer_id', '$customer_lname', '$customer_fname', '$customer_address', '$customer_city', '$customer_state', '$customer_zip', '$customer_phone', '$alt_phone', '$admin_user', '$computer_problem', '$trc_store', '$customer_passwd', '$date_in', '$date_completed', '$customer_call_1', '$customer_call_2', '$work_completed', '$work_completed_1', '$work_completed_2', '$tech_assigned', '$reason_for_call_1', '$reason_for_call_2')"; [/code]
  8. Hello Round, try [code]select stu_id, aos_code from stmaos where stu_id in (select stu_id from studetails where issues is null)[/code] null is special in that you use [i]issues is null[/i] or [i]issues is not null[/i] instead of the regular operator. i'm kind of surprised that [i]= null[/i] worked, but that might have something to do with db settings and such.. also, when using "in" you don't need to specify "distinct", as you might with a join. all the statement will check to see if the value is present. a distinct (i think) might cause it to actually figure out the distinct values, and then check. Not sure, but definitely not needed..
  9. You shall have to describe what happens that is not what you expect. It's hard to diagnose with "it doesn't work". We're here to help, but can't if we don't have enough info! Also, it's mssql_num_rows, as opposed to mssql_numrows.. Cheers MCP
  10. What's the error message? What's $stcode ? Is it always equal to "stcode"? It seems as thought that's the case with your login header thing.
  11. it will treat 'stu no' as a string, which probably isn't equal to any of your student ids use square brackets instead: [stu no] On another note, I always wondered why it was 'bad practice' to use spaces? Other than a bit more typing for the SQL Coder... it's certainly more legible than CamelCode or less annoying than_using_underscores...
  12. You're in the MSSQL forum, not the MySQL forum, by the way. I think it's all about parentheses or rather operator precedence. Try: SELECT * FROM table WHERE B='0' AND C>'3' AND (A='1' OR A='2') ORDER BY C DESC
  13. It definitely should.. what do you get when you put a var_dump($row); or print_r($row); in the while loop? what's the value of mssql_num_fields($result)?
  14. Nope, you don't need to worry about that.. ASP uses the adodb object to interact with MS SQL. Then, you have to tell adodb which driver/provider to use.. Alternatives to SQLOLEDB are the jet engine to access ms excel or ms access files. That's all asp stuff though. For PHP, just use the mssql_<function_name> functions to access MS SQL. Literally, for the code you have below, if it works with the mysql_ functions, it will work with the mssql_ functions. Exceptions: different SQL syntax, column names restricted to 30 characters when you retrieve column name information (through mssql_fetch_field for example)... that's it from what I can remember
  15. MS SQL has same functions... literally you just need to replace mysql_<function> with mssql_<function>. The other thing you have to worry about is differences in SQL syntax. For example MySQL uses "select * from table limit [...]", whereas MS SQL uses "select top [...] * from table".
  16. you will probably either want to do an eval() on your email field (will need just a little more than eval-ing it, but it's a direction) -- but this can be risky. otherwise, you can do a str_replace("{username}",$username,$email); type of code for each replacement value.
  17. Yep, you need to reconfigure with gd support. your config line has --without-gd
  18. Your do_login function doesn't know about $db. To let it know that it needs to reference the $db you created in the global scope, add the line [code=php:0] global $db; [/code] as the first line in your do_login function. Otherwise, it will look in the local scope (variables defined in your function), and try to use it. Since you didn't define $db in your local scope, it doesn't know it's an object, so it throws up.
  19. I think you just need to add all the fields to the group by. try this: [code] SELECT BlogPost.BlogPostID, ImgSrc, PostTitle, PostText, BlogPost.DateTime, Category, Deleted, User.Name, COUNT(BlogPostComment.BlogCommentID) AS CommentCount FROM BlogPost JOIN User USING (userID) RIGHT JOIN BlogPostComment ON BlogPost.BlogPostID = BlogPostComment.BlogPostID WHERE BlogPost.Deleted = '0' GROUP BY BlogPost.BlogPostID, ImgSrc, PostTitle, PostText, BlogPost.DateTime, Category, Deleted, User.Name [/code]
  20. Can you just define it first? Like in your css put in display:block, and then it would be block? If you don't ever define it, it doesn't have a value, hence undefined. I agree with you that it seems logical that it should have an initial value if you don't explicitly set it in CSS (i.e. should be block (or actually inline should be the default, IIRC)). It just seems that it's not the case, so you'll have to modify your code to assume that undefined == 'block' or 'inline'.
  21. when you connect, set new_link to be true (see [url=http://ca3.php.net/manual/en/function.mssql-connect.php]http://ca3.php.net/manual/en/function.mssql-connect.php[/url]). for example [code=php:0] <?php   $c1=mssql_connect("localhost","user","pass",true);   mssql_selectdb("database1",$c1);   $c2=mssql_connect("localhost","user","pass",true);   mssql_selectdb("database1",$c2);   $q1=mssql_query("select 'whatever1'",$c1);   $q2=mssql_query("select 'whatever2'",$c2); ?> [/code] Just be sure to qualify all of your selectdb and query function calls with the proper connection resource.
  22. [quote author=Round link=topic=111893.msg454202#msg454202 date=1161244502] Thanks jvrothjr, So do I amend the code as follows?:- [code]<img src="http://www.collegeurl.ac.uk/qlpics/substr(($student_id),4,12).bmp" width="100">[/code] as i'm assuming <%=mid.....%> is asp specific. or would it be:- [code]<img src="http://www.collegeurl.ac.uk/qlpics/<?php substr(($student_id),4,12) ?>.bmp" width="100">[/code] Many Thanks [/quote] either [code]<img src="http://www.collegeurl.ac.uk/qlpics/<?=substr($student_id,4,12) ?>.bmp" width="100">[/code] or [code]<img src="http://www.collegeurl.ac.uk/qlpics/<?php echo substr($student_id,4,12); ?>.bmp" width="100">[/code] but I'm not 100% sure on the first one, but for suer the second
  23. [quote author=corbin link=topic=111971.msg454102#msg454102 date=1161221819] Ive been tryin for the past 20 minutes or so to figure out how to somehow get mssql to run a query that a. selects amount from user_item where item_type is 57 b. selects amount from user_warehouse where item_type is 57 c. adds them together and treats them as colum x d.  ORDER BY x DESC My problem is i cannot figure out how to structure a sql query that does what i desire. Any help will be appreciated :P [/quote] [code] select item_type, sum(amount) as x from (   select item_type, amount from user_item   union all   select item_type, amount from user_warehouse ) user_stuff group by item_type order by sum(amount) desc [/code] that should get you started
  24. assuming your links are like this: [code]<a href="http://www.google.com">Google</a>[/code] then you can use a combination of charindex and substr to first locate the position of the first ">" (I don't think that ">" is a valid URL character), and the take everything after that and sort on that. You wouldn't need to strip the "</a>", since it's pretty will immaterial (at the end and always the same). so something like: order by substr(make,charindex(">",make),len(make))  -- this is untested and from memory, and most assuredly syntactically wrong
  25. [quote author=joelhop link=topic=111313.msg451015#msg451015 date=1160673647] [code] <?php require_once 'Database.php'; $db = Database::connect('Database_Name'); $variable = 26; $db->query('pSomeStoredProcedure $variable, 1'); ?> [/code] [/quote] Yup, do this instead: [code] <?php require_once 'Database.php'; $db = Database::connect('Database_Name'); $variable = 26; $db->query("pSomeStoredProcedure $variable, 1"); ?> [/code] The only difference is single quotes versus double quotes in the query line. Basically, PHP will not convert variables if the string is enclosed in single quotes, but will for double quotes.
×
×
  • 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.