try the following instead: on[B]before[/B]unload=db_refreshfeed;
ko ko commented: Nice answered hielo. thz guy +2
try the following instead: on[B]before[/B]unload=db_refreshfeed;
On my previous post, this: <%@page contentType="text/xml" %>
should have been: <%@page contentType="text/javascript" %>
Like I said, to "connect" all you have to do in your jsp, as you are serving it, you need to send: <script src="test.jsp"></script>
when the browser "sees" that script tag it will make a SEPARATE request to your server to fetch test.jsp. In test.jsp you must send the appropriate mime-type (text/javascript) BEFORE you even begin sending the first line of "PURE js code". By "PURE js code" I meant that your test.jsp may NOT enclose your js code in SCRIPT
tags.
Are you sure that the content sent by phpsqlajax_genxml.php is VALID XML?
Did you sent the correct Content-Type?
you should also check for newlines and carriage returns:
function tr(input)
{
var start=-1, end=input.length;
while( --end>start && (input.charAt(end)==" " || input.charAt(end)=="\n" || input.charAt(end)=="\r") ){}
++end;
while( ++start<end && (input.charAt(start)==" " || input.charAt(start)=="\n" || input.charAt(start)=="\r")){}
return input.substring(start,end);
}
can't you just install any of those packages (the one you prefer) and then reverse-engineer the db design since that is all you want. You should be able to generate a diagram using MySQL workbench:
http://dev.mysql.com/downloads/workbench/
Load you page via the browser. Now look at the browser's source code. Are you seeing all the expected item ids? How are you sending/printing your first block of code. It looks incomplete, so I am wondering if you are using an echo (or print) WITH double quote delimiters.
OK, then use a variable (stop) to iterate the string from right to left. Stop once you find a non-space.
Repeat the above, but iterating from left to right.
then use the substring() method to return the trimmed string.
function tr(str)
{
return String(str).replace(/(^\s+|\s+$)/g,'');
}
If you query for ALL the fields, you can use a while
to iterate through all the records. Then if you need to generate another "report" later on in the page you can use mysql_data_seek($result, 0);
to "reset" the $result so it points back to the initial/first row WITHOUT having to requery the db
I think this is what you are after:
select cfp_Id, P.proposal_id, P.institution_Name, sum(P.Task_Good_Idea + P.Task_Involve_Youth + P.Task_Involve_Partnerships + P.Task_Exploit_Digital_Medium + P.Task_Value_For_Money + P.Task_Theme + P.Task_Skills_Development + P.Task_LOC_Curriculum) as Task_Good_Idea
from proposals P
WHERE P.proposal_ID >=931
group by P.proposal_ID
having (Task_Good_Idea >= 25) and (cfp_Id = 22)
order by P.proposal_id desc
...and dhe data will be automaticly inserted into the column info.author_id
NO - No "automatic" insertion will take place. YOU have to insert it in BOTH tables explicitly. With the design I gave you (if you enforce referential integrity), you may at any time provide an entry in Author and NOT enter it Info, BUT you may NEVER enter a value in Info UNLESS it first exists in Author. Thus, you must FIRST enter the value in Author and THEN you may enter it in Info.
question two:how can I get two or three reports
Considering that you asked a very vague question, here's the best answer I can furnish:
First You get report One
Then report Two
THEN report Three :)
Seriously, you need to be very explicit. You should be able to retrieve whatever data you need from the design above in a single query, BUT if you need to populate three different sections of a web page, you just need to do so from the result set. Meaning, you don't have to forcibly execute three separate queries.
To Select ALL the data:
SELECT a.firstName,a.lastName,p.name,p.country,b.title,b.year,b.quantity,b.type,i.*
FROM (((Author a
INNER JOIN Info i ON a.id=i.Author_id)
INNER JOIN Book b ON b.id=i.Book_id)
INNER JOIN Publisher p ON p.id=i.Publisher_id)
To select info about a specific Author (based on his/her id):
SELECT a.firstName,a.lastName,p.name,p.country,b.title,b.year,b.quantity,b.type,i.*
FROM (((Author a
INNER JOIN Info i ON a.id=i.Author_id)
INNER JOIN Book b ON b.id=i.Book_id)
INNER JOIN Publisher p ON p.id=i.Publisher_id)
WHERE a.id=3
Or …
look at the HTML of the link above. You will notice that the information you want is in a <TABLE>
.
So, from the tool I referred you to, you need to use: $html->find('table', SOME_INDEX)
Now, I ask you, starting from the top, is THAT table (the one that contains the information you want) the FIRST table in the document? The SECOND? etc.
Whatever your answer is you need to subtract one and replace SOME_INDEX with the number you get (after subtracting one).
The reason for that is that find() will return an array, so the first table will be at index 0, the second table at index 1, etc.
Once you have the right table print it's innertext:
echo $html->find('table', YOU_FIGURE_OUT_THE_NUMBER_THAT_GOES_HERE)->innertext;
From the markup, it seems that all the info you want is within <B> tags, so you can refine your search further:
$data = $html->find('table', YOU_FIGURE_OUT_THE_NUMBER_THAT_GOES_HERE)->find('b')->innertext;
//now use a foreach to see what is in $data
If I understand you correctly, this is what you currently have:
--------
|Author| 1---------------+
-------- |
id |
name *
second name -------- --------
year | Book | 1---------1 | Info |
-------- --------
* id id
| bookname type
----------- | Author_id year
|Publisher| 1---------------+ Publisher_id author
-----------
id
publisher name
quantity
country
Now consider a book that has multiple authors!
Try this instead:
--------
|Author| 1---------------+
-------- |
id |
firstName *
lastName -------- --------
| Info | *----------1 | Book |
-------- --------
* Author_id id
| Publisher_id title
----------- | Book_id year
|Publisher| 1---------------+ quantity
----------- type
id
name
country
for purposes of authenticating only, I would have:
$pwd=getpassword($_POST['email'],....);
//then compare that against the posted password:
if( md5($_POST['email']) == $pwd )
{
//successful
}
I purchased some software recently ...
What software did you buy?
Instead of ...VALUES('9/30/2010',...)
use ...VALUES(STR_TO_DATE('9/30/2010','%m/%d/%Y'),....)
MySQL will save the date in yyyy-mm-dd format. So when you retrieve the date you will need to use DATE_FORMAT to change it back to mm/dd/yyyy SELECT DATE_FORMAT(`date`,'%m/%d/%Y') as `date` FROM Table...
As for your other problem, it sounds like you are using an integer data type for your field. Try using decimal instead.
assuming you are POSTing from a form with <input name='homesCopy'> try:
<?php
$doc = new DomDocument();
$file = "spice.xml";
$doc->load($file);
$xPath = new DomXPath($doc);
$homesCopy = $xPath->query("//sections/homesCopy/banners")->item(0);
if( isset($_POST['homesCopy']) ){
$homesCopy->firstChild->nodeValue=$_POST['homesCopy'];
$doc->save($file);
}
echo $homesCopy->nodeValue;
?>
First, I am using a java web application, not a php application.
Second, I am not really familiar with asp and I dont know whether I am able to have a asp file in a java web application (Im using servlets)
The concepts I discussed earlier still apply. The only thing that is different is your server-side technology. I am not a JSP developer but from what I see at:
http://www.roseindia.net/jsp/ContentTypeAttribute.shtml
the last code block on my previous post would be:
<%@page contentType="text/xml" %>
var MyClientSideVar ='<%= Session("MySessionVar")%>';
alert(MyClientSideVar);
and in your html file you would link to you jsp page (instead of the asp I was referencing as an example):
<script src="test.jsp"></script>
Third, I suppose ajax would be a good way to send data, do you agree that ajax would be much suitable than using sessions
With session you would "retrieve/recall" data, not SEND. So yes, use ajax if you are sending ajax to the server. But if all you are doing is retrieving data, then both will work. If you are using ajax to retrieve data, typically you would send the ajax request after the page has finished loading. IF you use Session, you can have that session info as the page is loading (since you are serving dynamic content).
My issue is this code work properly on my pc but whenever copied on other pc its not working.
On your working pc, when you load your page, what URL are you entering in the address bar? IF you are entering "http://localhost/...", then the problem is that when you go to another PC, THAT OTHER pc does NOT have a local web server running.
so, if I wanted to store a string named "first" in my session, should I place first instead of hello?
Correct
How flexible will chosing this design be if I wanted to to send this string (first) to an html file? Am I able to achieve this?
I don't understand what exactly you are trying to achive, BUT Session variables are NOT accessible from static pages. Most web servers would treat file named test.html as static page. You would need to use DYNAMIC pages - test.php or test.asp (depending on what you have on the server).
The reason why I did not use <%> is because I am trying to have this in my js file, which is in a different file than my html
The Session variable will NOT be retrievable from a javascript file - ex: test.js
Again, you would need to use server-side script.
What you can do is INSTEAD of serving a test.js:
<script src="test.js"></script>
You can serve directly from an ASP page, BUT the asp page MUST serve the proper MIME type for a javascript file:
<script src="test.asp"></script>
Then in test.asp you send the correct ContentType as well as the "raw" javascript code (without any SCRIPT tags):
<%
Response.ContentType="text/javascript"
%>
var MyClientSideVar ='<%= Session("MySessionVar")%>';
alert(MyClientSideVar);
Line 8 of your FIRST block of code should be: $password = [B]md5([/B] mysql_real_escape_string($password) [B])[/B];
. I have been able to pull the content out of the CDATA field with
How do you know which banner you are editing at any given time? I was expecting to see each banner node with a unique id attribute so that when you edit, you would know which node to update. Where's your attempted update code?
assuming you are using ASP AND the value stored in the session is a string, then WRAP the value you are assigning to the javascript variable in apostrophes:
<%
Session("MySession")="Hello"
%>
<script>
var MyClientSideVar ='<%= Session("MySessionVar")%>[B]'[/B];
alert(MyClientSideVar);
</script>
there is no elseif
in javascript. You need a space between the else and the if!
On line 18 of your FIRST block of code you have: $_SESSION['sername'] = $username;
I suspect you meant: $_SESSION['username'] = $username;
On line 9 of your FIRST block of code You need to use the values stored in the VARIABLES $email and $password. You incorrectly have a literal string: $sql = mysql_query("SELECT * FROM usersystem WHERE username = '[B]username[/B]' AND password = '[B]password[/B]' LIMIT 1");
You need to prefix those with a dollar sign: $sql = mysql_query("SELECT * FROM usersystem WHERE username = '[B]$username[/B]' AND password = '[B]$password[/B]' LIMIT 1");
The sample problem exists on line 15 of your SECOND block of code.
Also, on line 17 of your SECOND block of code you have to apply the condition check AFTER you have called the function - WRONG: If (mysql_num_rows($sql>0[B])[/B])
CORRECT: If (mysql_num_rows($sql[B])[/B] >0 )
Try:
<?php
if( isset($_POST['selectedBox']) && !empty($_POST['selectedBox']) )
{
$total=0;
foreach($_POST['selectedBox'] as $index=>$value)
{
echo 'Checked Item '. $index;
$total += $value;
}
if( 3==count($_POST['selectedBox']) )
{
echo 'you get 75 bonus points for selecting all';
$total +=75;
}
echo 'Your total is' . $total;
}
?>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>">
<input type='checkbox' name='selectedBox[1]' value='25'/>
<input type='checkbox' name='selectedBox[2]' value='30'/>
<input type='checkbox' name='selectedBox[3]' value='40'/>
<input type='submit' name='Submit' value='Submit' />
</form>
Dumping data for table `sec_tblusers`
Is the data shown on that dump already encrypted? If yes, what code did you use to encode it? It would help to see the definition of DataLayer and Password Classes to see what methods they have available and what they are actually doing.
I have an upload form where the uploaded picture is displayed.
Once you upload the picture, what code are you exactly executing? Are you:
a. emitting an <IMG>
tag with the path to the newly uploaded image
b. redirecting to the newly uploaded image
c. Other???
If you are doing a or b, instead of pointing to image.gif, try pointing to image.gif?cb=XXX
where X is some random number - You can use the time()
function to guarantee that it will be different every time:
header( 'Location: http://www.example.com/image.gif?cb=' . time() );
Read the manual:
http://us.php.net/manual/en/mysqli.real-connect.php
The second example clearly shows you: parent::init()
in php just use strtotime():
echo date('Y-m-d', strtotime("now -30 days") );
In your case INSTEAD of now you would use whatever date you have.
my apologies. There's an error in the if clause. It should be: if( isset($_GET['action']) && $_GET['action']=='d' && isset($_GET['id']) && isset($_SESSION[B]['varukorg'][/B][ $_GET['id'] ]) )
This: onunload=db_refreshfeed[B]()[/B]
should NOT have the parenthesis. You need to assign a function reference, NOT call the function since your function is NOT returning a function. Also try using onbeforeunload instead.
Lastly, be sure both pages are on the same domain.
Line 4 of my FIRST post above has: $rows=$html->find('div[id=yfi_quote_summary_data] table tr');
which states: "within <div id='yfi_quote_summary_data'> locate all TABLE elements and within that every TR".
So you need to look at the markup you are working with and decide/determine what portions of HTML you are interested in. Look at the examples posted at the simplehtmldom page.
newweb, whenever you post code, please use the CODE "button" on the editor.
The following should work. Be sure to COPY AND PASTE:
<?php
session_start();
$_SESSION["varukorg"][] = array(
"artikel" => $_SESSION['art'],
"produkt" => $_SESSION['product'],
"antal" => $_SESSION['qte'],
"pris" => $_SESSION['price'],
"image_cart" => $_SESSION['image']
);
if( isset($_GET['action']) && $_GET['action']=='d' && isset($_GET['id']) && isset($_SESSION[ $_GET['id'] ]) )
{
unset($_SESSION['varukorg'][ $_GET['id'] ]);
}
foreach($_SESSION['varukorg'] as $index=>$cart)
{
echo "<p>" . $cart['artikel'] . "</p>";
echo "<p>" . $cart['produkt'] . "</p>";
echo "<p>" . $cart['antal'] . "</p>";
echo "<p>" . $cart['pris'] . "</p>";
echo "<p><a href='#'><img src='/images/produkter/{$cart['image_cart']}' width='100' height='100'/></a></p>";
echo sprintf("<p><a href='%s?id=%s&action=d'>delete</a></p>",$_SERVER['PHP_SELF'],$index);
}
?>
There correct syntax for the foreach that you posted originally should be:
foreach($_SESSION['varukorg'] as $index=>$cart)
{
echo "<p>" . $cart['artikel'] . "</p>";
echo "<p>" . $cart['produkt'] . "</p>";
echo "<p>" . $cart['antal'] . "</p>";
echo "<p>" . $cart['pris'] . "</p>";
echo "<p><a href='#'><img src='/images/produkter/{$cart['image_cart']}' width='100' height='100'/></a></p>";
echo sprintf("<p><a href='%s?id=%s&action=d'>delete</a></p>",$_SERVER['PHP_SELF'],$index);
}
On line 115 you missed a closing ">" for your checkbox. <td><input type="checkbox" name="delFriends[]" value="<?php echo $rows['receiver_username'];?>" [B]>[/B]</td></tr>
Also, line 23 is wrong. The name of your element is NOT "delFriends". Use the exact name you gave the element
I may still not unset the data from the Session arrays...
What does that mean? Have your resolved the problem? If not, on the page where you are setting/initializing the $_SESSION, you MUST call session_start() first (preferable at the very start or your file).
Glad to help.
Regards,
Hielo
PS: Don't forget to mark the thread as solved.
BTW: on my Nov 12th, 2010, 15:03 post I thought I got rid of siteList everywhere but I missed one: location.href = siteList.options[sIndex].value;
should be: location.href = [B]this[/B].options[sIndex].value;
You can use:
echo $item["label"] . ": " . $item["value"] . "<br />" ;
OR:
echo "{$item['label']} : {$item['value']} <br />" ;
(the {} forces the engine to evaluate a variable that is wrapped/embedded in a string.)
In the future, please put you wrap your code in CODE tags (look for the word CODE wrapped in square brackets at the top of the editor).
My code looks like I am putting it on the allSelect
Exactly! It IS the SELECT list/element that ACTUALLY changes so it will trigger the onchange event.
... instead of each of the URL's within the lists
You probably meant "instead of each of the OPTION's", but the onchange does NOT go on the OPTION tags. Think about it. When you change from Google to Yahoo, the VALUE of the Google option REMAINS http://www.google.com. You simply selected a new item - Yahoo. So the SELECT now has a value that equals the value of the new selected/chosen item (namely http://yahoo.com).
That is the problem. Your index page already sent <body>....
by the time you call header()
. So you cannot include your login in the middle of your index.php page. You need to do so right at the beginning:
try:
<?php
include'database_conn.php';//connect to the database
$form='';
if(isset($_COOKIE['ID_my_site']))//checks if there is a login cookie
{
$username = $_COOKIE['ID_my_site'];//if there is a cookie it logs you in and directs you to the page
$pass = $_COOKIE['Key_my_site'];
$check = mysql_query("SELECT * FROM users WHERE email = '$email'")or die(mysql_error());
while($info = mysql_fetch_assoc( $check ))
{
if ($pass == $info['password'])
{
header("Location: account.php");
exit;
}
}
}
if (isset($_POST['submit'])) {//runs if form has been submitted
if(!isset($_POST['email']) || !isset($_POST['pass']) || empty($_POST['email']) || empty($_POST['pass']) ) {//makes sure the user has filled the form in
die('You did not fill in a required field.');
}
if (!get_magic_quotes_gpc()) {
$_POST['email'] = addslashes($_POST['email']);//checks the form against the database
}
$check = mysql_query("SELECT * FROM users WHERE email = '".$_POST['email']."'") or die(mysql_error());//gives error is user doesnt exsist
$check2 = mysql_num_rows($check);
if ($check2 == 0) {
die('That user does not exist in our database. <a href="register.php">Click Here to Register</a>');
}
while($info = mysql_fetch_assoc( $check ))
{
$_POST['pass'] = stripslashes($_POST['pass']);
$info['password'] = stripslashes($info['password']);
$_POST['pass'] = md5($_POST['pass']);
if ($_POST['pass'] != $info['password']) {//gives error if the password is wrong
die('Incorrect password, please try again.');
}
else {
$_POST['email'] = stripslashes($_POST['email']);//if login is ok we add a cookie
$hour = time() + 3600;
setcookie(ID_my_site, $_POST['email'], $hour);
setcookie(Key_my_site, $_POST['pass'], $hour);
header("Location: account.php");//else redirect them to account area …
do you have a link to your page? IF not, paste your page's HTML source code.
The problem is that you were processing the images separately. One foreach for the thumbnails and one for the large images. You need to do both at once since you need two per record/row.
Based on your post, my guess is that in your HTML markup you have something SIMILAR to:
<div>Image 1:
Thumbnail:<input type="file" name="small_tn_[]">
Large Image:<input type="file" name="large_image_[]">
</div>
<div>Image 2:
Thumbnail:<input type="file" name="small_tn_[]">
Large Image:<input type="file" name="large_image_[]">
</div>
OR:
<div>Image 1:
Thumbnail:<input type="file" name="small_tn_[0]">
Large Image:<input type="file" name="large_image_[0]">
</div>
<div>Image 2:
Thumbnail:<input type="file" name="small_tn_[1]">
Large Image:<input type="file" name="large_image_[1]">
</div>
When you upload the images, then: $_FILES['small_tn_']['name'][0]
will have the name of the first Thumbnail $_FILES['small_tn_']['name'][1]
will have the name of the second Thumbnail $_FILES['large_image_']['name'][0]
will have the name of the first Large Image $_FILES['large_image_']['name'][1]
will have the name of the second Large Image
If you look closer, the thumbnails are "connected/related" to the large image via the index. The zero in the thumbnail corresponds to the zero in the large image.
Likewise, the one in the thumbnail corresponds with the one in the large image.
That's why you need to use the $key
in the foreach. On every iteration it will increment (starting from zero).
Thus, using $key
, on lines 8 and 9 of my post I can get the "related" images.
try:
<td><textarea name="text" id="text" rows="26" cols="61" ><?php echo preg_replace('#<br\s*/?>#i', "\n", html_entity_decode($edit_servicedesc2));?></textarea> </td>
try:
if( isset($_POST['btnSubmit']) )
{
//.........
foreach ( $_FILES['small_tn_']['name'] as $key=>$value1 )
{
$smallImage=$_FILES['small_tn_']['name'][$key];
$largeImage=$_FILES['large_image_']['name'][$key];
$sql_small_tn = sprintf("INSERT INTO `overlay`(`small_tn`,`large_img`) VALUES ('%s','%s')",$smallImage, $largeImage );
$db->query($sql_small_tn);
}
}
try:
foreach($_SESSION['varukorg'] as $index=>$cart)
{
echo "<p>" . $cart['art'] . "</p>";
echo "<p>" . $cart['product'] . "</p>";
echo "<p>" . $cart['qte'] . "</p>";
echo "<p>" . $cart['price'] . "</p>";
echo "<p><a href=#><img src=\"/images/produkter/ $cart['image_cart'] \" width=100 height=100/></a></p>";
echo sprintf("<p><a href='%s?id=%s&action=d'>delete</a></p>",$_SERVER['PHP_SELF'],$index);
}
so when you click on the Delete button, it will send the id of the item to be deleted. So start your page with:
<?php
session_start();
if( isset($_GET['action']) && $_GET['action']=='d' && isset($_GET['id']) && isset($_SESSION[ $_GET['id'] ]) )
{
unset($_SESSION[ $_GET['id'] ]);
}
In your init() function I don't see the need for allSelect.push(allSelect[i]);
. If you have 10 select lists and only three have list of links all these three have class="optionLinks"
then yes, I can see/understand why you have the if
check/clause. However, the body of the if clause should simply attach the onchange event to the "current" (depending on the iteration) SELECT
right away.
if (allselect[i].className == "optionLinks")
{
allSelect[i].onchange = loadLink;
}
Having said that, here's what's wrong with what you have in init()
:
a. the body of your if clause is NOT enclosed in braces. So only the first if statement if executed when the if condition is true. But the statement that follows allSelect[i].onchange = loadLink;
will execute for ALL selects. If I am not mistaken, the purpose of the if (allselect[i].className == "optionLinks")
statement was to pick and choose specific SELECT
list to attach the onchange
event to, but that is NOT what you are doing. You are attaching it to EVERY select list in your page. I suspect you had the intention of executing both statements within the if, but forgot to enclose them in braces. This type of mistake is easily avoided if you always put braces around the statements you intend to execute within an if - even it is a single statement.
b. Assuming allSelects currently has:
allSelects[0] ==> <SELECT class="optionLinks" id="Select1">...</SELECT>
allSelects[1] ==> <SELECT class="optionLinks" id="Select5">...</SELECT>
allSelects[2] ==> <SELECT class="optionLinks" id="Select12">...</SELECT>
(where "==>" means …
(my apologies for the double post - I'm having connectivity issues and didn't realize it posted the first time)
javascript is case sensitive. To clarify, var greeting="...";
is different from: var Greeting="...";
In your case you declared and initialized a variable named allSelect (with uppercase "S"), but in the for you are using ... < all[b]s[/b]elect.length
(notice the lowercase "s"). The same problem exists in if (all[B]s[/B]elect[i].className
javascript is case sensitive. To clarify, var greeting="...";
is different from: var Greeting="...";
In your case you declared and initialized a variable named allSelect (with uppercase "S"), but in the for you are using ... < all[b]s[/b]elect.length
(notice the lowercase "s"). The same problem exists in if (all[B]s[/B]elect[i].className