Jump to content

optimaximal

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

optimaximal's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. In the If statement, is there a simple way to look at a string and find a particular word, much like the SQL LIKE '%%' function, or will I have to do a bit of string comparison?
  2. Thanks for the help. Can someone debug this? Im sure it's pretty clear what i'm trying too do, although i'm getting the dreaded PHP white-screen-of-nothingness. I'm sure it's my syntax, but hey, any ideas welcome. Let me know if i've integrated the code right. <?php // Add what we need. require('connection.php'); include('header.php'); ?> </style></head> <body> <?php if (isset ($_POST['submit'])) { if ($_POST['audit_passsecure'] == '1') { $str = '{$_POST['audit_passpassword']}'; $first_letters = substr($str, 0, 2); $encrypt = str_pad($first_letters, strlen($str), "*"); } // Define the query. $query = "INSERT INTO audit_passwords (audit_passlocation,audit_passname,audit_passusername,audit_passpassword,audit_passdescr,audit_passsecure) VALUES ('{$_POST['audit_passlocation']}','{$_POST['audit_passname']}','{$_POST['audit_passusername']}', '$encrypt','{$_POST['audit_passdescr']}','{$_POST['audit_passsecure']}'); "; // Execute the query. if (@mysql_query ($query)) { ?> <p> Password Added to Database<br /> Click <a href="password_add.php">here</a> to add another.<br /> Click <a href="index.php">here</a> to return home. </p> <?php } else { print "<p>Could not add the entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>"; } mysql_close(); } else { ?> <form action="password_add.php" method="post"> <table width="100%" border="0"> <tr> <td width="200" valign="top">What is the Password For:</td> <td><input type="text" name="audit_passname" size="25" maxsize="6" /></td> </tr> <tr> <td width="200" valign="top">Password Location (i.e. Web Address)</td> <td><input type="text" name="audit_passlocation" size="25" maxsize="6" /></td> </tr> <tr> <td width="200" valign="top">Attached Username:</td> <td><input type="text" name="audit_passusername" size="25" maxsize="40" /></td> </tr> </tr> <tr> <td width="200" valign="top">Attached Password:</td> <td><input type="password" name="audit_passpassword" size="25" maxsize="40" /></td> </tr> <tr> <td width="200" valign="top">Additional Notes:</td> <td><textarea name="audit_passdescr" cols="40" rows="5" wrap="physical"></textarea></td> </tr> <tr> <td width="200" valign="top">Secure Password</td> <td><select name="audit_ltype"> <option value="0" selected>No</option> <option value="1">Yes</option> </select></td> </tr> </table> <br> <input type="submit" name="submit" value="Submit" /><input name="Reset" type="reset" value="Reset" /> </form> <?php } ?> </body> </html>
  3. Hi all, Can anyone give me a little nudge in the right direction about how I can take a string and replace all but the first 2 characters with asterisks? Im sure I should be using the strreplace function, as well as possibly left or something, but I'm having a brain fart. All help appreciated.
  4. Hiya all, first thread and all... Basically, I'm pulling data from my company's customer database (running on MSSQL - SQL Server) for the purpose of mailings in order to create a web-based printable label system (don't ask :)). The problem i'm facing is the SQL Server uses the CHAR(13) ASCII code (aka. a carriage return) and I need a way to grab this in PHP so that I can use the str_replace function to replace it with a form of carriage return that a web browser can understand (i.e. <br>). Here's the code - [code]$connection_string = 'DRIVER={SQL Server};SERVER=########;DATABASE=######'; $user = '######'; $pass = '######'; $connection = odbc_connect( $connection_string, $user, $pass ); $sqlquery="SELECT top 10 title, full_name, house, address, postcode, customer FROM cust ORDER BY NEWID();"; $process=odbc_exec($connection, $sqlquery); //Finally, you extract all of the companies from the Customers table and display them onscreen in a list. Once the entire list has been displayed, the connection to the database is closed: while(odbc_fetch_row($process)){ $Title = odbc_result($process, 1); $Name = odbc_result($process, 2); $House = odbc_result($process, 3); $Address = odbc_result($process, 4); //Replace Carriage Return $Address2 = str_replace("NEED THIS VALUE", "<br>", "$Address"); $Postcode = odbc_result($process, 5); $custnum = odbc_result($process, 6); echo "<span class='small'>$custnum</span><p>$Title $Name<br>$House $Address2<br>$Postcode<p><hr>"; } odbc_close($connection);[/code]
  5. This won't work in MSSQL (LIMIT is for MySQL and Oracle only & RAND isn't supported by MSSQL). A function that [b]will[/b] work is - "SELECT TOP 10 * FROM `tablename` ORDER BY NEWID();"
×
×
  • 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.