php-windows Digest 21 May 2008 18:20:43 -0000 Issue 3475

Topics (messages 28902 through 28903):

Re: php-windows Digest 19 May 2008 13:39:11 -0000 Issue 3474
        28902 by: sandeep khokher

If Question!
        28903 by: Matthew Gonzales

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
hi anton

you can try utf8_encode function of php .it worked for me in a similar
situation.

Cheers.................


---------- Forwarded message ----------
From:  <[EMAIL PROTECTED]>
Date: Tue, May 20, 2008 at 1:39 AM
Subject: php-windows Digest 19 May 2008 13:39:11 -0000 Issue 3474
To: [EMAIL PROTECTED]



php-windows Digest 19 May 2008 13:39:11 -0000 Issue 3474

Topics (messages 28901 through 28901):

Working with Excel csv retrieved data (using fgetcsv) and unknown characters
       28901 by: Anton Heuschen

Administrivia:

To subscribe to the digest, e-mail:
       [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
       [EMAIL PROTECTED]

To post to the list, e-mail:
       [EMAIL PROTECTED]


----------------------------------------------------------------------


---------- Forwarded message ----------
From: "Anton Heuschen" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Date: Mon, 19 May 2008 15:39:06 +0200
Subject: Working with Excel csv retrieved data (using fgetcsv) and
unknown characters
This is run on an XP box with WAMP install:

I have a script that downloads a Excel CSV file and then uses fgetscv to
retrieve lines, the strange thing is that in Firefox I get symbols (black
triangle with question mark in it) and in IE its basically spaces. So if I
echo these values (or print_r array result, my text string has spaces), Ive
tried opening it in Notepad etc to see what characters or codes these spaces
are, but it shows nothing. Ive opened it in PSPad and its shows only as
unknown characters (square blocks).

Im suspecting it might be tabs ?

Is there a way to remove any "unknown" characters from a line retrieved with
fgetsv ?


the getscv line used:

$handle = fopen($local_file, "r");
   while(($data = @fgetcsv($handle,1000,",")) !== FALSE)
   {

if I print out (print_r) this $data I get something like :

_�2�0�0�8�0�4�0�3� �1�4�2�0�5�1�0�0�Array
(
   [0] => ÿþE�v�e�n�t�:� �A�B�C�-�0�0�0�1�8�

   [1] => �2�
   [2] => �3�



There should be no question mark symbols but should rather look like:

_20080403 14205100Array
(
   [0] => ÿþEvent: ACC-10018
   [1] => 2

   [2] => 3




-- 
Regards
Sandeep Khokher

--- End Message ---
--- Begin Message ---
Hello,

So I am trying to create a web app using some if statement logic. Right now I am having some trouble getting a particular piece of the code to work. (Highlighted in red below) I am trying to produce the user profile and if the user does not have a profile a form will display asking the user to create one. I can not get the highlighted if statement to work. What am I doing wrong.

<?php

//Start the session
session_start();

//Include profile form file
include "profile_form.php";
include "login_form.php";

// Open a connection to the DB
$conn = mysql_connect('localhost', 'root', 'mg7448') or die(mysql_error());
mysql_select_db('newsprofs', $conn);

//Set session_id variable
$session_id = $_SESSION['user_id'];

//Check to see if the user is trying to update profile
if (isset($_GET['try']))
{
//User is trying to update profile. Make sure form is filled out correctly if ((!$_POST['fname']) || (!$_POST['lname']) || (!$_POST['company']) || (!$_POST['title']) || (!$_POST['degree']) || (!$_POST[
       'school']))
       {
           //Left fields blank on the form
           $msg = '<h5>Please fill out all fields of the form!</h5>';
//Display User profile form
           $print_form = $profile_form;
}
       else
       {
           //Form is filled out correctly. Insert into database
           //Create variables for the sql string
           $fname = $_POST['fname'];
           $lname = $_POST['lname'];
           $company = $_POST['company'];
           $title = $_POST['title'];
           $degree = $_POST['degree'];
           $school = $_POST['school'];
//Cerate query $insert_profile = "insert into profiles (user_id, fname, lname, company, title, degree, school) values ('" . $session_id . "', '" . $fname ."', '" . $lname . "', '" . $company . "', '" . $title . "', '" . $degree . "', '" . $school . "')" ; $insert_results = mysql_query($insert_profile, $conn) or die(mysql_error()); //Show success message $msg = '<h5>You have updated your profile succesfully!</h5><br />
                   <a href="profile.php">Return to profile page</a>';
}
}


//Check to see if the user is logged in
elseif(isset($_SESSION['user_id']))
{

   // User is logged in!
$query = "SELECT username FROM users WHERE id = '" . $session_id . "' LIMIT 1";
   $results = mysql_query ($query,$conn) or die(mysql_error());
//Save username
   list($username) = mysql_fetch_row($results);
// Log in message
   $msg= '<h3>Welcome! '. $username . '</h3>';
// Display User menu
   $menu = '<a herf="profile.php">My Account</a><br />
           <a href="/login/logout.php">Log Out</a>';
//Check to see if user has a profile $profile = "select fname, lname, company, title, degree, school from profiles where user_id = '" . $session_id . "' ";
   $profile_results = mysql_query($profile, $conn)
   or die (mysql_error());
//Collect data for profile
   //Find what the user_id is
       while ($profile_id = mysql_fetch_array($profile_results))
       {
           $fname = $profile_id['fname'];
           $lname = $profile_id['lname'];
           $company = $profile_id['company'];
           $title = $profile_id['title'];
           $degree = $profile_id['degree'];
           $school = $profile_id['school'];
//Add Profile to display block
           $display_block = '
           <tr>
               <td class="heading">First Name:</td>
               <td class="input-cell"> ' . $fname . '</td>
           </tr>
           <tr>
               <td class="heading">Last Name:</td>
               <td class="input-cell">' . $lname . '</td>
           </tr>
           <tr>
               <td class="heading">Company:</td>
               <td class="input-cell">' . $company . '</td>
           </tr>
           <tr>
               <td class="heading">Title:</td>
               <td class="input-cell">' . $title . '</td>
           </tr>
           <tr>
               <td class="heading">Degree:</td>
               <td class="input-cell">' . $degree . '</td>
           </tr>
           <tr>
               <td class="heading">School:</td>
               <td class="input-cell">' . $school . '</td>
           </tr>';
       }
//If username is empty display error message
   if (empty($username))
{ //Display error message $msg = '<h5>An error has occured trying to retrieve your user profile. Please contact the webmaster. You have been logged out
       to protect your data.</h5><br />
       <a href="index.php">Return to Home Page to login</a>';
} //If profile is not there display form to submit profile
   elseif ($profile_results <= 0)
   {
       //Display notify message
$notify_msg = '<h5>You have not created a profile yet! Please do so by filling out the form below!</h5>'; //Display User profile form
       $print_form = $profile_form;
} }

//User is not logged in display message and direct user to return to index page
else
{
// User not logged in $msg = '<h5>You must be logged in to see your profile. Please return to the <a href="index.php">Home Page</a> to login!</h5>';
}


//


?>
--
Matthew Gonzales
IT Professional Specialist
Enterprise Information Technology Services
University of Georgia
Email: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
Phone: (706)542-9538

--- End Message ---

Reply via email to