ShawnCplus 456 Code Monkey Team Colleague

You're using a relative path "csv/unconvert_tester.csv" so MySQL seems to be placing it in a default location for outfiles. Just specify an absolute path (starting with /) to tell it the exact location.

ShawnCplus 456 Code Monkey Team Colleague

OPTIONALLY ENCLOSED BY '"' get rid of that completely unnecessary mysql_real_escape_string('"') BS

ShawnCplus 456 Code Monkey Team Colleague
$result = mysql_query($sql);
if (!$result) {
  die(mysql_error());
}

That'll tell you if the query is actually executing or not. And you don't have to surround variables with "" if that's the only thing in the statement. mysql_query($sql); or 'some string' . $variable are both fine and the preferred way to do it.

ShawnCplus 456 Code Monkey Team Colleague

Why are you using mysql_real_escape string for your quote but not for $table which is coming directly from POST?. Also what do you mean the file doesn't work, is the csv file empty or what?

ShawnCplus 456 Code Monkey Team Colleague

you're already in PHP, you don't need to do <?php echo Also, you're in double quotes so you must surround the $onrow["index"] with {} ie., {$onrow["index"]}

tulipputih commented: thanks for your explanation :).it helps me understanding php better +1
ShawnCplus 456 Code Monkey Team Colleague

heh, I said mysql_query, etc. You're still using mysqli

ShawnCplus 456 Code Monkey Team Colleague

K, then try the script using plain mysql_query functions. If that works then it's something wrong with mysqli.

ShawnCplus 456 Code Monkey Team Colleague

Stupid question, is MySQL actually running?

ShawnCplus 456 Code Monkey Team Colleague

Take that damn @ out from in front of the first line. @ suppresses errors so you can't see them.

ShawnCplus 456 Code Monkey Team Colleague

The AJAX response just has to send like a JSON response then you parse the response and set them in your success callback.

ShawnCplus 456 Code Monkey Team Colleague

You might want to show us some code, and use code tags when you do

ShawnCplus 456 Code Monkey Team Colleague
// if you're using XHTML
str_replace('<br />', "\n", $string);
// if you're using HTML
str_replace('<br>', "\n", $string);
ShawnCplus 456 Code Monkey Team Colleague

The tilde has no special meaning, it was just chosen as the delimiter so the slashes didn't have to be escaped. You can choose pretty much any delimiter.

$regex1 = '/http:\/\/www\.example.com\/blah/';
// vs
$regex2 = "#http://www\.example\.com/blah#';

I prefer to use / and # but it looks like the tilde was their choice.

ShawnCplus 456 Code Monkey Team Colleague

Well if you're trying to extract the username you can just do this.

$url = 'http://www.myspace.com/username';
$urlparts = explode('/', $url);
$username = end($urlparts);
ShawnCplus 456 Code Monkey Team Colleague

"/^(\d{1,7})\.(\d{1,2})$/" If you're testing a string you want to set the anchors "^" (beginning of string) and "$" (end of string) so you know that there is nothing else in between. "/(\d{1,7})\.(\d{1,2})/" will match 12345678.12 because it is matching, take a look at this.

without ^$
  __________
1|2345678.12|
  ----------
that's 7 numbers a decimal and 2 numbers, so a match
with anchors
 _______
|1234567|8.12
 -------
no match
ShawnCplus 456 Code Monkey Team Colleague

thanks for the advice

so using the first example:

if [0] had [a][c]

all i'd need to do to access an array and assign the contents to vars would be (using first example):


$avar = $somearray[0]['a'];
$bvar = $somearray[1]['b'];

echo $avar;
echo $bvar;

// Hello
// World

Precisely. If you want to get really deep into how arrays work take a look at the language documentation. http://php.net/arrays

ShawnCplus 456 Code Monkey Team Colleague

Or you could just write the method for (in your example) Person to change the name themselves. ie., person->setName() There is absolutely no need for a "superclass". Their true name is "god class" and it's referred to as an anti-pattern. They are the bane of good OOP principles. Don't make them. Just don't.

There is absolutely no reason you can't do

$person = new Person($somepersonid);
$person->setName('Tester');

You could make the database access inside the Person constructor, it doesn't have to be in the GUI. I'm not entirely sure where you're getting this mindset.

ShawnCplus 456 Code Monkey Team Colleague
$somearray = array(
  array('a' => 'Hello'),
  array('b' => 'World')
);

echo $somearray[0]['a'] . ' ' . $somearray[1]['b'];
// Hello World
ShawnCplus 456 Code Monkey Team Colleague

I did actually try a variation on the code, as I realized I was checking the wrong variable it should be checking the radio group, so I altered the code slightly

if ($radio='seasons')
{
include('includes/seasons.php');  /* seasons show */
}

if ($radio='products')
{
include('includes/products.php');
}
   ?>

of course its actually showing BOTH currently, mostly likely because i should be using double equals im guessing

Yes, == is a test, = is an assignment. $var = "string" in a condition will always be true.

ShawnCplus 456 Code Monkey Team Colleague

Well that depends on what you want to test. If you want to test for boolean true you'd say

if ($somevariable)

If you wanted to test if the variable was equal to the string "true" then you'd use your way.

ShawnCplus 456 Code Monkey Team Colleague

Was there a question or were you just showing us the code?

ShawnCplus 456 Code Monkey Team Colleague

http://php.net/isset
If Google is your friend, the PHP manual is your best friend

ShawnCplus 456 Code Monkey Team Colleague

Firstly, toss an echo at the top of your php file to make sure you're even touching that file. Based on your HTML file you may not, type = "submit" those spaces may or may not be killing the submit button.

ShawnCplus 456 Code Monkey Team Colleague

remove the "ini " before ImageCreateFromJpeg on line 17

ShawnCplus 456 Code Monkey Team Colleague

Store the result in the session, it's that easy

ShawnCplus 456 Code Monkey Team Colleague

Yeah, in the MySQL manual there are in-depth explanations, go take a peek.

ShawnCplus 456 Code Monkey Team Colleague

Have you tried the AUTOINCREMENT property on the field in the database? Go take a look at the MySQL manual

ShawnCplus 456 Code Monkey Team Colleague

If you want everything accept for letters and numbers you can use

$pattern = '/[^a-z0-9]/i';

If you are specific about \/:"?<*>| then it's this

$pattern = '#[\/:"\?<\*>|]#';
OmniX commented: Thanks for the solution. +3
ShawnCplus 456 Code Monkey Team Colleague

Read the FAQ.

ShawnCplus 456 Code Monkey Team Colleague
<?php echo nl2br($whatever) ?>
<?php echo nl2br(substr($whatever)) ?>
ShawnCplus 456 Code Monkey Team Colleague

There's a lot, go read the manual. http://php.net

ShawnCplus 456 Code Monkey Team Colleague

Well it'd be enter operation, enter first number, enter second number -> switch(operation) { calculate answer } -> output answer -> done

EDIT: This is my 1000th post, wooo!

ShawnCplus 456 Code Monkey Team Colleague

Ok, then yeah, follow the instructions. And you only have to worry about dividing BY zero, it doesn't matter if numerator is zero, only check the denominator (secondNum in this case)

ShawnCplus 456 Code Monkey Team Colleague

why would you have to swap for subtraction? Also, you're not checking to make sure that you're not dividing by zero in your division section

ShawnCplus 456 Code Monkey Team Colleague

As a side note, do you notice that you have a lot of repetitive code? That usually means it can be taken out and put in one place. Everything inside the if/else blocks does exactly the same thing except the answer = part. So take out the cout/cin, drop it above and then use a switch statement. Take a look in your book for the switch statement syntax.

ShawnCplus 456 Code Monkey Team Colleague

Ya can't just put braces in random spots and expect it to work :)

//Ch6AppE08.cpp
//Displays the answer to arithmetic problems
//Created/revised by Greg Schader on 6/22/2009

#include <iostream>

using std::cout;
using std::cin;
using std::endl;

int main()
{ 

  //Define variables
  char function = ' ';
  int firstNum = 0;
  int secondNum = 0;
  int answer = 0;

  //Enter variables and perform operation
  cout << "Enter the letter of the operation you wish to perform: ";
  cin >> function;

  if (toupper(function) != 'A' && toupper(function) != 'S' && toupper(function) != 'D' && toupper(function) != 'M') {
    cout << "That letter is not valid." << endl;
  } else {
    if (toupper(function) == 'A') {
      cout << "Enter the first number of the operation: ";
      cin >> firstNum;
      cout << "Enter the second number of the operation: ";
      cin >> secondNum;

      answer = firstNum + secondNum;

      cout << "Answer of operation is: " << answer << endl;
    } else if (toupper(function) == 'S') {
      cout << "Enter the first number of the operation: ";
      cin >> firstNum;
      cout << "Enter the second number of the operation: ";
      cin >> secondNum;

      answer = firstNum - secondNum;

      cout << "Answer of operation is: " << answer << endl;
    } else if (toupper(function) == 'M') {
      cout << "Enter the first number of the operation: ";
      cin >> firstNum;
      cout << "Enter the second number of the operation: ";
      cin >> secondNum;

      answer = firstNum * secondNum;

      cout << "Answer of operation is: " << …
ShawnCplus 456 Code Monkey Team Colleague

When you fix something don't just say it didn't work and wait for another answer, post the updated code

ShawnCplus 456 Code Monkey Team Colleague

Don't forget the braces around your inner if and else statements, take a look in your book on why to do this (if it explains it)

ShawnCplus 456 Code Monkey Team Colleague

You could try using $_SERVER['HTTP_REFERER'] but I'm not 100% sure on that.

ShawnCplus 456 Code Monkey Team Colleague

You have to encode the brackets < >, otherwise they're interpreted as HTML tags and wont display to the browser.

ShawnCplus 456 Code Monkey Team Colleague

If 'desc' is a FULLTEXT field instead of a VARCHAR field then you have to use MATCH <field> AGAINST ('<string>') instead of LIKE IIRC

ShawnCplus 456 Code Monkey Team Colleague
<a href="blah" title="This is your title">some link</a>

You answered your own question

ShawnCplus 456 Code Monkey Team Colleague

div matches a div tag, p matches any p tag under a div and * matches anything under the p tag. It's called CASCADING Stylesheets for a reason.

ShawnCplus 456 Code Monkey Team Colleague

As always make sure that $looky is what you think it is by var_dump ing it. Also, manually look in the database to make sure that record is actually there.

ShawnCplus 456 Code Monkey Team Colleague
ShawnCplus 456 Code Monkey Team Colleague

ECMA-48 SGR sequences are used for (somewhat) portable termal color. http://en.wikipedia.org/wiki/ANSI_escape_code#graphics

ShawnCplus 456 Code Monkey Team Colleague

So if those errors you got are EXACTLY the errors you got then you need to trim() the $fname variable. It looks like it's ending in a carriage return.

ShawnCplus 456 Code Monkey Team Colleague
ShawnCplus 456 Code Monkey Team Colleague

echo $fname to make sure it's actually the value you think it is, also b as far as I know is not a valid fopen flag. http://php.net/fopen

ShawnCplus 456 Code Monkey Team Colleague

A) Invert that $_SESSION['username'] condition to just exit or something if it's not present instead of wrapping ALL of your code in an if
B) Use a bit more meaningful variable names than ij.
C) Assuming that $row has exactly 11 fields

// replace
      $index[$ij] = $row[0];
      $sdate[$ij] = $row[1];
      $sbranch[$ij] = $row[2];
      $svendor[$ij] = $row[3];
      $spo[$ij] = $row[4];
      $swriter[$ij] = $row[5];
      $sinv2[$ij] = $row[6];
      $sinvtotal[$ij] = $row[7];
      $spototal[$ij] = $row[8];
      $sinvduedate[$ij] = $row[9];
      $varience[$ij] = $row[10];
 // with
$vars = array('index', 'sdate', 'sbranch', 'svendor', 'spo', 'swriter', 'sinv2', 'sinvtotal', 'spototal', 'sinvduedate', 'variance');
  for($inc = 0; $inc < 11; $inc++) {
    $$vars[$inc] = $row[$inc];
  }

D) You're not ending your form tag, you're just opening another one

HITMANOF44th commented: a kick in the right direction +1