PDA

View Full Version : non-vb script help


ManagerJosh
11-28-2002, 09:17 PM
Could someone tell me what I did wrong? I suck at PHP and it shows really :rolleyes:

Parse error: parse error, unexpected T_STRING in /home/virtual/site3/fst/var/www/html/store/admin/includes/functions/general.php on line 785



// the $filename parameter is an array with the following elements:
// name, type, size, tmp_name
function tep_copy_uploaded_file($filename, $target) {

if (substr($target, -1) != '/') $target .= '/$manufacturers_data['manufacturers_directory']';

$target .= $filename['name'];

move_uploaded_file($filename['tmp_name'], $target);
}


I modified this and it gave me the error

if (substr($target, -1) != '/') $target .= '/$manufacturers_data['manufacturers_directory']';

NTLDR
11-28-2002, 09:38 PM
Try:

if (substr($target, -1) != '/') $target .= "/$manufacturers_data['manufacturers_directory']";

I expect it doesn't like the nested ' in the variable name ;)

ManagerJosh
11-28-2002, 10:49 PM
Originally posted by NTLDR
Try:

if (substr($target, -1) != '/') $target .= "/$manufacturers_data['manufacturers_directory']";

I expect it doesn't like the nested ' in the variable name ;)

I got

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/virtual/site3/fst/var/www/html/store/admin/includes/functions/general.php on line 782

with your recommended suggestion.

NTLDR
11-28-2002, 10:56 PM
Lets try with {}:

if (substr($target, "-1") != "/") {
$target .= "/$manufacturers_data['manufacturers_directory']";
}

If that doesn't work try:

$target2=substr($target, "-1");
if ($target2!= "/") {
$target .= "/$manufacturers_data['manufacturers_directory']";
}

ManagerJosh
11-28-2002, 11:07 PM
Originally posted by NTLDR
Lets try with {}:

if (substr($target, "-1") != "/") {
$target .= "/$manufacturers_data['manufacturers_directory']";
}

If that doesn't work try:

$target2=substr($target, "-1");
if ($target2!= "/") {
$target .= "/$manufacturers_data['manufacturers_directory']";
}


Neither works NTLDR.


Just to let you know the original is:


function tep_copy_uploaded_file($filename, $target) {

if (substr($target, -1) != '/') $target .= '/';

$target .= $filename['name'];

move_uploaded_file($filename['tmp_name'], $target);
}


Problem is that with that, it uploads a file to a directory and I'm hoping that variable I added (From data it is pulling from the MySQL) will allow me to upload to that directory I specified.

THe current directory it is uploading to is /images/

I'm hoping with that variable it uploads to: /images/$manufacturers_data['manufacturers_directory'] where $manufacturers_data['manufacturers_directory'] would be information it is obtaining from MySQL.

I think i might be overlooking something which may be why it isn't working.

ManagerJosh
11-28-2002, 11:12 PM
Here are the files just to give you an idea what I'm dealing with

-_-

NTLDR
11-28-2002, 11:23 PM
All I can think of is to make sure you add:

global $manufacturers_data;

After the function line which is need, other than that I can't think of anything else right now.

ManagerJosh
11-29-2002, 07:41 AM
in general.php and not another php script in the zip file I attached.

Perhaps I should ask for help to finish this script up cause I'm stumped really bad.

Should I ask in this forum or should I ask in the Help Me Finish Forum? I get the impression the Help Me Finish Forum is limited to vB hacks...though I might be wrong..

If a mod would point this thread in the right direction...

MUG
11-29-2002, 12:11 PM
You can't use quotes when dealing with arrays in double-quotes. Try:if (substr($target, -1) != '/') $target .= "/$manufacturers_data[manufacturers_directory]";

ManagerJosh
11-29-2002, 07:51 PM
Originally posted by MUG
You can't use quotes when dealing with arrays in double-quotes. Try:if (substr($target, -1) != '/') $target .= "/$manufacturers_data[manufacturers_directory]";

Wouldn't that affect my variable in the first place? Because my variable is:



$manufacturers_data['manufacturers_directory']



where i have specified earlier that:



$manufacturers_array = array(array('id' => '', 'text' => TEXT_NONE));
$manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name, manufacturers_directory from " . TABLE_MANUFACTURERS . " order by manufacturers_name");
while ($manufacturers = tep_db_fetch_array($manufacturers_query)) {
$manufacturers_array[] = array('id' => $manufacturers['manufacturers_id'],
'text' => $manufacturers['manufacturers_name']);
}

// Directory Code Hack
$manufacturers_data = tep_db_fetch_array($manufacturers_query);
// Directory Code Hack



Edited: your suggestion works MUG, but I wonder if it affects my variable...

ManagerJosh
11-29-2002, 08:03 PM
Okay it doesn't affect it but I think I'm just plain stupid here in PHP. Could someone help accomplish what I'm trying to do?

I've attached a ZIP file of the files I'm working on. What I want to do is this:

When I select something from the manufacturers drop down menu, it uploads an image file to that manufacturers specified directory in the table manufactuers, field manufactuers_directory

For some reason I can't make it work...then again my PHP knowledge sucks.

ManagerJosh
11-30-2002, 03:23 AM
Silence isn't very comforting FYI...

ManagerJosh
11-30-2002, 08:08 AM
<tr>
<td class="main"><?php echo TEXT_PRODUCTS_MANUFACTURER; ?></td>
<?php
// Begin Directory Code Hack

$manufacturer_directory_sql = tep_db_query("select * from " . TABLE_MANUFACTURERS . ");
while($r=@tep_db_fetch_array($manufacturer_directo ry_sql)) {
$manufacturers_array = $r["manufacturers_directory"];

?>
<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_pull_down_menu('manufacturers_id', $manufacturers_array, $pInfo->manufacturers_id); ?></td>
<?php
};
// End Directory Code Hack
?>
</tr>


Can't figure out what I did wrong here....

Parse error: parse error, unexpected '\"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/virtual/site3/fst/var/www/html/store/admin/categories.php on line 384

Line 384:

$manufacturers_array = $r["manufacturers_directory"];