Jump to content

dstoltz

New Members
  • Posts

    9
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

dstoltz's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have an older website done in Classic ASP, and many pages hit a Microsoft SQL server for database functionality. We are starting to move forward with the planning for the redesign, and I wanted to get opinions on moving forward with changing the ASP to PHP, and keeping the MS SQL database. I know PHP can be used with MS SQL, but I don't know if there are any "gotch'as", or things to be aware of. Yes, we could use MySQL, but I'm much more familiar with MS SQL, and know how to support it from an administrative and development standpoint. The server will be Windows Server 2012 (I don't have a choice with this), and I would either run WAMP on it for PHP functionality, or just install PHP....I like the ease of WAMP for enabling certain PHP features, so I'm leaning towards that...but again, opinions please! Thanks for any thoughts and advice!
  2. mjdamato, No sweat - I agree with your fishing analogy. But so you know, I was combing the manual and online sites, but for some reason this solution eluded me. Sometimes even with the answer in front of you, it's not understood. This is why I like forums, because you get a friendly explanation, rather than technical jargon. I'll try and research my questions more thoroughly before posting. Thanks
  3. Thanks for the reply.. BTW, I have been reading the manual, and web sites, and forums, trying to figure this out. Sorry I'm a PHP beginner... I didn't know this forum was only for expert level questions only... Sorry if that seems like a smart-butt response, but your comment of "reading the manual is too much work" ticked me off, considering I tried fixing this for hours. But thanks for your answer.
  4. Hi All, I'm coming from a Classic ASP world, so I'm trying to understand this... After I excute a loop like this: while($row = mysql_fetch_object($result)){ ... ... } I can no longer echo results from that object, like: echo $row->lname; I equate this to looping through a recordset in ASP. Once your past the last record, you are at EOF. If you want to "go back" to the starting record, you have to do: RecordsetName.MoveFirst() Is there a way to do this kind of thing with my result object in PHP? If so, how? Sorry if this is a dumb question. Thanks!
  5. I have this querystring: $q = sprintf("SELECT * FROM employees WHERE fname LIKE %s OR lname LIKE %s OR badge = %s OR ssn = %s ORDER BY lname",GetSQLValueString($ename,"text"),GetSQLValueString($ename,"text"),GetSQLValueString($ebadge,"int"),GetSQLValueString($essn,"int")); Which results in: SELECT * FROM employees WHERE fname LIKE 'd' OR lname LIKE 'd' OR badge = 0 OR ssn = 0 ORDER BY lname I want to use a wildcard for the 1st two, like this: SELECT * FROM employees WHERE fname LIKE 'd%' OR lname LIKE 'd%' OR badge = 0 OR ssn = 0 ORDER BY lname How do I modify the QueryString to do this? I know I can do it in the function call like this: GetSQLValueString($ename.'%',"text") But I was thinking it would be better to do it by the %s parameter, but this doesn't work: ...WHERE fname LIKE %s\% OR ... Any ideas? Thanks!
  6. Ok, I adjusted the code to: $result = mysql_query($q); it works...thanks!
  7. Wow that was quick, thanks! Ok - so I instead updated this line: $cnx = new mysqli("localhost","user","password","database"); to: $cnx = mysql_connect("localhost","user","password","database"); Which seems to work, but now it errors on this line: $result = $cnx->query($q); with: Fatal error: Call to a member function query() on a non-object in D:\WAMP\www\eho\default.php on line 19 Now what am I doing wrong? geeez....
  8. Hi Folks - I'm kinda new to PHP, and just started using WAMP. I'm having problems with mysql_real_escape_string.... I know you need a connection established first before using this, and I think I have a connection properly set up. The problem happens when calling the function "GetSQLValueString" to clean up the strings for the query. This line in the function seems to be the trigger: $theValue = mysql_real_escape_string($theValue); I keep getting: Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'SYSTEM'@'localhost' (using password: NO) in D:\WAMP\www\includes\dbx.php on line 24 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in D:\WAMP\www\includes\dbx.php on line 24 See below for my code and the function it calls...any ideas what I'm doing wrong? <?php // Include the database functions include('../includes/dbx.php'); if (isset($_POST['myForm'])){ if($_POST["myForm"]==1){ $ename = $_POST["ename"]; $ebadge = $_POST["ebadge"]; $essn = $_POST["essn"]; if($ename==""){$ename="none";} if($ebadge==""){$ebadge=0;} if($essn==""){$essn=0;} // Check to see if the user is already in the EHO system $cnx = new mysqli("localhost","user","password","database"); $q = sprintf("SELECT * FROM employees WHERE fname LIKE %s OR lname LIKE %s OR badge = %s OR ssn = %s ORDER BY lname",GetSQLValueString($ename,"text"),GetSQLValueString($ename,"text"),GetSQLValueString($ebadge,"int"),GetSQLValueString($essn,"int")); echo $q; $result = $cnx->query($q); $row = mysqli_fetch_assoc($result); //echo $row['fname']; $num_results = $result->num_rows; } } ?> The PHP function is below: function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = mysql_real_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; }
×
×
  • 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.