Jump to content

code worked under php4, but not with php5, need help please.


worksite

Recommended Posts

 

firstly, thankyou for taking the time to read this, and i hope

that someone can point out what the problem is, and how to fix it.

 

the website worked fine under php4, but changing to a new hosting site which has php5 on it, resulted in it not working.

 

i have almost completed the site with help and guidance from a friend, but he is very busy at present,

and i can not wait weeks, before he is freed up to assist me, in completing the site upgrade.

 

..so any help would be very much appreciated.

 

in brief:- it should show a list of up to 4 workers selected; by either directly

adding them in the section or from selecting them from, some search results.

 

the problem is:- it will add the first worker id, ok.

 

but any other id added to the list, simply changes the first id added,

to the new one ( added or selected ), so there is only 1 worker id on the page every time.

 

it is not adding up....

 

this is the section of the index file out side the folder, which is used along with, the search worker file.

 

( meaning first folder has in it, this index file, and another folder containing the files used in this section

, which is where the search worker file is located )

 

hope i have not confused you to much; once again thankyou in advance.

 

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

 

// add to selected workers cookies for worker search

if ($add) {

if (substr($add, 0, 1) == 'W') {

$add = substr($add, 1);

}

 

// check if user exists and has paid

$sql = "SELECT * FROM workers WHERE id = $add";

$q->query($dbc, $sql);

$found = $q->numrows();

 

$selectedWorkers = count($workers);

 

// check for duplicates

$dupe = 0;

for ($i = 0; $i < $selectedWorkers; $i++) {

if ($workers[$i] == $add) $dupe = 1;

}

 

if ($selectedWorkers < 4 && $found > 0 && !$dupe) {

setcookie("workers[$selectedWorkers]", $add);

$workers[$selectedWorkers] = $add;

}

}

 

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

this here is part of the search worker file below.

 

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

 

<form action="?action=searchWorkers" method="POST">

<tr>

<td height=35 colspan=3 align=center valign=top class="body">

Worker ID: <input type=text name="add" value="W" size=10 class="form80">

<input type=submit value="Add">

</td>

</tr>

</form>

<tr>

<td colspan=2 class="body">

<b>Selected workers</b> - up to 4

</td>

</tr>

<tr>

<td colspan=2 height=1>

<table width=298 border=0 cellpadding=0 cellspacing=0>

<tr>

<td height=1 background="images/bg000000.gif"><img src="images/spacer.gif" width=1 height=1></td>

</tr>

</table>

</td>

</tr>

<form action="?action=contact" method="POST">

<?php

if (count($workers) == 0) {

?>

<tr>

<td colspan=2 class="body">

No workers selected.

</td>

</tr>

<?php

/////////////////////////////////////////////////////////////////

// if user has selected workers to contact

/////////////////////////////////////////////////////////////////

 

} else {

for ($i = 0; $i < count($workers); $i++) {

$sql = "SELECT firstName FROM workers WHERE id = ".$workers[$i];

$q->query($dbc, $sql);

list($name) = $q->getrow();

 

?>

<tr>

<td class="body">

<input type="hidden" name="worker<?php echo $i; ?>" value="<?php echo $workers[$i]; ?>">

<a href='<?php echo "?action=viewWorker&id=$workers[$i]&back=searchWorkers&offset=$offset&orderby=$orderby$searchParams"; ?>'>W<?php echo $workers[$i]." - $name</a>"; ?>

</td>

<td class="body" align=right>

[<a href="<?php echo "?action=searchWorkers&remove=$i&offset=$offset&orderby=$orderby$searchParams"; ?>">remove</a>]

</td>

</tr>

<?php

}

?>

<tr>

<td colspan=2 align=center><input type="submit" value="Next >>"></td>

</tr>

<?php

}

?>

</form>

 

I really don't have the fortitude to read through all your code :) but you might try adding the line...

 

error_reporting(E_NOTICE);

 

to the top, it will tell you pretty much ANYTHING that is odd or wrong with your code.. it will even tell you if some function/way of doing things is depreciated.. that might help you find your problem.

thankyou genericnumber1, for your reply.

 

i turned  on error_reporting(E_NOTICE);

 

and got this:- Notice: Undefined variable: workers in -------.

 

i have tried the following:-

 

$workers = $_REQUEST['workers'];// gives a Notice: Undefined index: workers in -----, and will not change to next id added.

 

$workers = $_REQUEST[''];// gives a Notice: Undefined index: in -----.

 

$workers = $_REQUEST["workers"];// will not add next id at all, but there is no NOTICE.

 

$workers = ('workers');// throughs a Ww- for the id, not even selected yet!!!. but the notice of undefined worker is not there.

 

$workers = ('');// Notice: Uninitialized string offset: 0 on line ------

 

this:- $selectedWorkers = count($workers); appears to be the problem,

as ' workers ' is also the name of a table in the database; if this is even relevant, i do not know.

 

regards worksite.

regards

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.