I think you problem is that you don't have quotes around the $nt array indexes. This should fix your problem:
print'<option value="'.$nt['ugid'].'">'.$nt['ugname'].'';
I think you problem is that you don't have quotes around the $nt array indexes. This should fix your problem:
print'<option value="'.$nt['ugid'].'">'.$nt['ugname'].'';
Just a note on that. Sessions do use cookies. For a session to know which computer the session applies to, the session must either send a cookie to the client as proof of identity or have that identity code in the url. So in most cases it doesn't matter if the user doesn't have cookies enabled since without cookies there ain't sessions unless identity is sent via url.
I'm not sure that this is correct. Sessions and cookies are similar, but cookies are stored on the client whereas session data is stored on the server. If the client has cookies disabled, you can't use setcookie etc, but you can use session data. Sessions do not have to use cookies, they are separate but can interact with each other like any data. You do not need to use cookies, they can be handy to store data client side but are not necessary for many situations.
I'm not sure what you are trying to achieve by running the trigger as another user. I think this would cause you more headaches than it would solve.
"I'm not very confortable with that since I must open my main database to the user of the inserting application or even deleting information." -- using the trigger as another user could open your database up to anonymous use, if it is even possible.
Hi testing321 and welcome to DaniWeb :)
Hint 1: You can make use of certain String functions to work out the characters in the String, such as charAt(). Here is a link to the charAt function's documentation.
Hint 2: You can tell if a number is odd or even through the use of modulo arithmetic. For example, 5 % 2 = 1, which means it is odd. 8 % 2 = 0 which means it is even.
Hope this gives you a start. Try coding some yourself, post back with your code if you get stuck with specific questions.
imagedestroy() is used to free memory assigned to an image resource stream. I haven't tried it out, but I assume it can be used to free any image resource stream created by the GD package.
By tmp folder, are you referring to file upload tmp folder? If so, open the php.ini file and search for upload_tmp_dir. This is the setting that needs to be adjusted.
EDIT: Actually I just followed my own advice and found that the tmp directory for the upload_tmp_dir in my php.ini file is set to more than one setting, so it may need to be changed in more than one place in the ini file.
<?php include("html_mailer.php"); $obj = new html_mailer.php; $email = "xxx"; $age = "72"; $sex = "Male"; $obj = sendWelcomeHTMLMail($email, $age, $sex); ?>
This code contains incorrect syntax. See corrections below:
<?php
include("html_mailer.php");
$obj = new htmlMailer();
$email = "xxx";
$age = "72";
$sex = "Male";
$obj->sendWelcomeHTMLMail($email, $age, $sex);
?>
If you post it here I will be happy to take a look, as will others who may have other ideas than mine.
Upsilon is very close with that query. I will extend to give you the minimum value:
SELECT min(value) as value FROM table_name HAVING count(value) = 1
Without access to the website's database I'm thinking this would be very difficult to do. What you are essentially talking about may have legal ramifications also.
> Sorry about this, I really am at a loss with all this.
No need to apologise, that's why this forum is here :)
The foreign key in table t1 is definately referencing itself. And the field in question is also the PK of the table. This is very very very bad. What this says is "before you insert a new record, make sure that this record already exists!" Of course this is impossible.
My normal course of action here would be to drop the foreign key constraint from the table. Are you able to speak with whoever built the database to find out their intention with this foreign key? They might be able to tell you why they created it as they might have meant something else. Maybe they actually wanted to reference table t2's ID or something...
As I said earlier, backup the database, drop the constraint and see if this fixes your problem. Good luck :)
EDIT: And btw, table t2's FK constraint is ok.
Are you able to check the FK on that table? You can do this at the mysql prompt like so:
mysql > SHOW CREATE TABLE t1\G
For primary key, try to insert a new record with the same PK as an existing record. If you can't, then the PK is working.
For a foreign key, try to insert a new record where the FK doesn't equal a record for the referenced field. If you can't insert such a record, the FK is working.
EDIT: D'oh, urtrivedi beat me to it :P
So you are trying to insert to t1 and you get that error? I must admit I didn't think it was possible to have such a foreign key constraint as one that references itself. I think if that's the case then it would probably be best to drop the FK constraint from the table, just make sure you don't drop the primary key constraint if it is also the PK of the table.
EDIT: And remember to backup the database beforehand so you can go back if this is the wrong move!
A foreign key constraint is used to stop you from inserting data into the table without a corresponding record existing in another table. The ID field in the table you are inserting into must match the ID field of a record in the table t1.
Hi forzadraco,
Please use code tags when posting code as it makes it much more readable. If you have a question, please do not hijack an old thread, create a new one instead and clearly state what it is you are trying to do and any errors you are getting.
Thanks,
darkagn
Something like this should work:
SELECT a.id, a.prod_id1, b.description as desc1, a.prod_id2, c.description as desc2
FROM comp_items a
INNER JOIN products b ON a.prod_id1 = b.prod_id
INNER JOIN products c ON a.prod_id2 = c.prod_id
$tmp =$_REQUEST["check1"];
$tmp .= ",". $_REQUEST["check2"];
$tmp .= ",". $_REQUEST["check3"];
BTW, please use code tags.
i converted to timestamp,but the calcutions is still a problem...
Post your code so we can see what you have done?
Algorithm:
First, get the date that they joined and convert to timestamp (strtotime function)
Next, get todays date in timestamp format (time function)
Then subtract current time from joined time
Now, number of seconds in one day is 24 * 60 * 60. Use this figure to calculate the number of days since the person joined.
Next, convert the number of days to a string detailing years, months, weeks and days. You can do this using division and modulo arithmetic (%) quite easily.
Hope this helps :)
Oh, sorry I completely misunderstood your previous post. I think you need to query the users table (or whatever yours is called) to find out if the user posting the reply is admin user or not. Your code uses the admin status of the user that started the thread, you need to recheck the admin status each time a post is created, not when the thread is created.
Try ORDER BY RAND()
instead of NewID()
Change GROUP BY to ORDER BY in the second query. I think this will give you the result you are looking for.
Exactly. It doesn't really matter what format you write to when you save so long as you can read it back again when you load.
Yes. Your problem is that $row2 always equals 0. Your code says:
"If $row2 == 1 AND if $admin_user_level == 0, then don't let the topic be viewed."
Since $row2 always = 0, the topic can ALWAYS be viewed, regardless of the value of $admin_user_level.
Rules of boolean AND algebra:
T && T = T
T && F = F
F && T = F
F && F = F
EDIT: Since there is no column 'admin' in forum_replies table, I would remove all reference to $row2 in that if-statement and just have the if-statement check the value of $admin_user_level.
Given the results, I think that $admin_user_level is working correctly. So the problem is with the admin post ($row2) being equal to 0 instead of 1? The only time you will get the "You cannot view this topic!" message is when the user is not admin and $row2 = 1. When does $row2 = 1? That is, what does the admin column in the forum_replies table relate to?
Hi mdmarcial and welcome to DaniWeb :)
I've come up with seven entities / tables so far which are:
CLIENT{ClientID, Firstname, Lastname, StreetAddress, Suburb, State, Postcode, PhoneNumber}
PROJECT{ProjectNumber, Description, Startdate, Duedate, Pricetype, Quotedprice, FinalPrice, Status, DateCompleted}
STAFF{StaffID, Firstname, Lastname, Contact#, BillingRate, Position}
PROJECT MANAGER (because each project is assigned to each project manager who also issues the invoice; I'm not quite certain if I should put the manager as a staff as well but according to the context, PM isnt a staff - pls comment)
SERVICE TYPE {ServiceNumber, Description, StartDate, DueDate, PlannedPrice, ActualPrice, ServiceStatus, DateCompleted,HoursBilledinQuarted} (again, not quite sure if HoursBilledinQuarted should be here or in Project)
BONUS (I dont know which entities should I put in bonus, or should this just be part of STAFF Entitiy? However, not all staff can be eligible for the bonus)
MYOB {MyobInvoice#, InvoiceDate, InvoiceTotal
Ok, that looks like a good start. A few comments however:
I would have a STAFF_TYPE table that is referenced by the STAFF table to keep track of the bonus target and bonus earned for each type of technical staff member.
I think that PROJECT MANAGER should be a (boolean) column in the STAFF table rather than a separate table, but I could be wrong.
I think that your "SERVICE TYPE" table should actually be two tables, one to list all available services and one to link between that table and the PROJECTS table to indicate what services have …
Does anyone know if this was an intended change?
$A = $row['foo'];
Here 'foo' must match the column name in the table you are trying to access. Try outputting $A to see if it is correctly being assigned:
$A = $row['foo'];
echo $A;
// ...
if($row2['admin'] == 1 && $admin_user_level == 0)
I can't see anywhere in your code where $admin_user_level is set. Is it possible that this is not correctly being set for the user?
Try this immeadiately before that line:
echo "POST_ADMIN: " . $row2['admin'] . "<br>";
echo "ADMIN_USER: $admin_user_level<br>";
and see what happens...
table
is the name of the table in the database. $database
in your example will contain a result set of rows from the database according to the query passed into the mysql_query
function. It should probably be named $result instead of $database to give you a clearer understanding of what is happening.
Try to think of a database being like a filing cabinet. The tables in the database are the files in the filing cabinet and store the actual data.
EDIT: To actually connect to the database in php, check out the mysql_connect function. Once connected you run SQL queries using the mysql_query function and interrogate the result with the mysql_fetch_* functions.
Not 100% sure what you are asking here, but couldn't you just read/write from/to a File when you load/save the design?
I just ran a test on what you see. The first half of the page should be custom tailored to you, but it simply hasn't picked up on enough yet, and therefore you have some default blog entries that happen to be farther down for filler.
However, you'll notice that it includes quite a few Java and PHP threads (which you visit quite often). Additionally, it knew to include both this thread as well as the one you started about the member info in the posts changing.
Basically it's not going to be perfect, but the idea is that it will be more likely than not that there are going to be at least a few things on the homepage that you'll find interesting ... and perhaps that you might consider checking out the homepage on a regular basis from now on as part of your regular DaniWeb browsing habits.
All good points. It certainly is an improvement and I like the fact that it picks up forum posts that I may be interested in. Truth be told I don't really remember the old home page, but I think it just had the most recent blog posts? And that wasn't very interesting to me so I tended to just jump straight to the forums once the menu system loaded up. Now I might take the time to read the first entries to see where to go to first and that is a huge plus.
Nice work :)
I think for this purpose you will want to use regular expressions.
Check out the API for the java.util.regex package.
Nice Dani :)
I especially like the fact that the quick forum index contains links to the three forums I reply to the most.
I notice that the main section of the screen lists the latest forum posts and blog posts, but I don't usually visit the blogs. How was this list generated? Is it standard across the board or should it represent what I like?
Certainly this page is an improvement on the old home page, nice work :)
Yes, possible. Use date_add function.
The date_add function is only for PHP version 5.3 or greater. Since 5.3 is due for general release later this year, I assume frenchwr cannot access that function.
What you need to do is use the date and strtotime functions to parse a date for seven days time. Check out this thread in the PHP forum where peter_nichol explains how to use these functions in conjunction with daylight savings. If you still have questions, repost and we will try to help :)
Much love and respect to all my friends on DaniWeb. :)
628
Ah, I think your final </table> tag needs to go outside the final } brace. Because it is inside that brace, it is part of the loop, so will close the table after the first row.
So your loop code is equivalently:
echo "<tr>";
echo "<td><h1>" . $row[1] . " </td> </h1> ";
echo "<td>" . $row[1] . "</td> <br> " ;
$imagea= $row[3];
$imageb= $row[4];
$imagec= $row[5];
$imaged= $row[6];
echo "</tr>";
Sorry, just reformatting so I can see what is going on, will reply again in a sec after I have looked at it...
Can you post code from results.php where you include pictures.php please? I am mostly interested in any difference between the first time and second time they are included (as one works and the other doesn't). I am fairly certain that the image swapping function must be called to actually be executed, so you must be doing that the first time correctly but then not for subsequent attempts (I think!)
Is pictures.php a class file? If not then you don't need to create an object, all of the php code that isn't inside a function (called inline code) will be run when the file is included. Code inside functions or outside php (such as the javascript you posted earlier) will be run if called in the inline code.
If the code in the pictures.php file IS in a class, then yes, you will need to create a new object, but it depends on the name of the class (as opposed to the file). For example, if the pictures.php file contains the following line:
class PictureManager
then results.php would need to create a new PictureManager object like so:
$pictures = new PictureManager();
However from what you posted earier I am assuming your code is not in a class.
Hi all,
Not sure if this is intentional, but it seems that the member info displayed in the top right corner of the title bar for posts has lost miscellaneous information such as Location. I have attached an example of one of my posts, normally it displays my location as well as post count, rep alt power etc.
If it is a deliberate change it is certainly not critical, just thought I'd report it in case it wasn't. FYI I am using Firefox in Vista 64-bit if this helps.
Regards,
darkagn
So basically result.php includes pictures.php once which includes images.php multiple times? Or is pictures.php included multiple times and it includes images.php once? This might help identify where the problem lies...
Ok, I have to admit that javascript is not my strong suit, but I will try to help. Does the changeImage function get called by pictures.php? What gets passed to the function when it is called? It doesn't appear that the parameter is actually used in the function though, so I might be barking up the wrong tree...
xmgx,
You have already been banned once from this forum for such offensive language. I must ask, do you really want to be here if you react like this to people that disagree with you (and nicely I might add)?
Hi frenchwr and welcome to DaniWeb :)
This link will be useful for you, it is the reference manual for MySQL 5.1.
Are you storing the variables in PHP? PHP has a mysql_fetch_array function, which is why I thought this. Or are you working with another language, or purely in MySQL?
It is perfectly feasible to use the include function more than once. Any inline code in the included file will be run as though the included file were run. This can sometimes cause unpredictable results and requires certain amount of care, particularly with variables.
Maybe post some of the code in the images.php file so we can see what is being included? We may be able to give you some pointers...
On to the programming, I can come back and give you some more help tomorrow. For now, you might want to consider that "cents" can be much greater than 200. It looks like your code in the add method will not work if cents is > 200. (Lets say you had 0 dollars, 200 cents. Your code would convert that to 1 dollar, 100 cents - but it should convert it to 2 dollars.)
Actually, because javaman is only adding two Money objects, it is impossible to get to 200 cents (assuming that each Money object has a maximum of 99 cents).
However, the minus methods are still wrong. As I said in the last thread, what happens if you have $5.20 minus $1.90?
You have two choices. The easiest way is to set the $CONF array to global in the functions that use it. Like so:
function foo()
{
global $CONF;
// do something here with $CONF
}
function bar()
{
global $CONF;
// do something else here with $CONF
}
However, for this method to work you need to include one of the php files in the other. So from your description, index.php would need to include the config.php file. This may not be feasible though, which brings me to method two.
Instead of storing your config options in $CONF, you can store everything in the superglobal $_SESSION. This allows you to pass variables between pages like so:
// config.php
$_SESSION['sql_user'] = $CONF['sql_user'];
// index.php
if( isset( $_SESSION['sql_user'] ))
{
$user = $_SESSION['sql_user'];
}
else
{
$user = $me; // for example
}
Another way would be to pass by $_GET, but this is less secure as the variables are passed in the url of the page.
HTH,
d