hielo 65 Veteran Poster
<%
On Error Resume Next
Dim sConnection, objConn , objRS

sConnection = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost; DATABASE=Your_Mysql_DB; UID=mysql_username;PASSWORD=mysql_password; OPTION=3"

Set objConn = Server.CreateObject("ADODB.Connection")

objConn.Open(sConnection) 
If Err.Number <> 0 Then
    Response.Redirect "maintenance.asp"
    Response.End
Else
    'continue coding here
    '...

    objConn.close
    Set objConn=Nothing
End If

%>
hielo 65 Veteran Poster

and next to each row I have a submit button that when pressed will send out an email to all the users

Did you mean that if you click on the "Send Mail" button for a row, an email should be sent only for the person on that row? What you wrote leads me to believe that no matter which row button I click, EVERYBODY will be emailed! If this is what you actually intended, then why not use a single button?

My guess is you meant "Email only the person in the current row", in which case what you need:
a. ONE form per row since each different row will send an email just for that particular person.

b. In addition to the button, each row/form needs to send/pass a unique identifier via a hidden field so you know which person you are trying to email. From what you posted, user_id IS unique, so that is enough.

c. In process.php your update query just needs to take the current value stored in the `user_email_sent` and add one to it. You do NOT need to update it from some php variable. You can do it directly via sql

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Hielo</title>
</head>
<body>
<?php
//connect to the db and select the db here first
//...

$query = "SELECT * FROM `tbl_users` order by `user_name` asc";
$result = mysql_query($query) or die(mysql_error());
echo "<table border='1'>";
echo "<tr><th>Name</th><th>Email</th><th>Email Sent</th><th>Send Email</th></tr>";
	
	while($row =
hielo 65 Veteran Poster

in my loop i am calling $total

Not sure what kind of loop you have(for, while,...), but for illustration purposes, the code below uses a while

//initialize the variable outside the loop
$total=0;

//assuming I am retrieving data from a DB query result
//where one of the columns in the recordset is named "amount"
while( $row=mysql_fetch_assoc($rs) )
{
   //update the total within the while
   $total += $row['amount'];
}
echo $total;
hielo 65 Veteran Poster

You are welcome!

hielo 65 Veteran Poster

You are welcome!

hielo 65 Veteran Poster

You are welcome!

hielo 65 Veteran Poster

On your original post you are infact missing a space to the left of the WHERE keyword. My suggestions would be to use "&" instead of "+" symbol to concatenate the strings and enclose the table/fieldnames in brackets.

On another note, with regards to:

UPDATE passwrd

Are you sure your TABLE is named passwrd? To clarify, if you had the following:
Table: Person
Fields: password, username

then it should be:

Dim ssql As String = "UPDATE [Person] SET [password] ='" & TextBox1.Text & "' WHERE [username]='" & TextBox2.Text & "'"
hielo 65 Veteran Poster

Assuming you are using the plugin described here:
http://www.ohloh.net/p/jquery-session

it says:

Know Issue- Vars are lost in the page is open in another window or tab. - Objects with functions can't be stored - Window.name is lost - Only Strings can be stored

Does this apply to you? Do you have a sample page that I can see?

hielo 65 Veteran Poster

how to keep it from being a pop up?

For that, you should NOT be using window.open(). Instead, just assign the url to location.href:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<title>Rotate Marketing</title>

<!-- 
IMPORTANT: Notice that I am importing "cookies.js". Go to:
http://www.quirksmode.org/js/cookies.html

scroll down to the section titled "The Scripts" and grab those three functions.
save them to a file named cookies.js and import them into your page similarly to
the way I am doing below
 -->
<script src="cookies.js" type="text/javascript"></script>

<script type="text/javascript">

      <!--
 
      var Win;

      var page_index = 0;

      var page = new Array();
      page[ page.length ] = "http://www.homebiz.usaloe.com";
      page[ page.length ] = "http://www.makethatmoney.usaloe.com";
      page[ page.length ] = "";
      page[ page.length ] = "";
      page[ page.length ] = "";
      page[ page.length ] = "";
      page[ page.length ] = "";
      page[ page.length ] = "";

      var next_page = function(){

      	//page_index = (( page_index === 8 ) ? 0 : page_index );
		page_index=++page_index % page.length;
      	if ( typeof Win !== "undefined" ) {

      		/* Win.location.href = page[ page_index ]; */
		location.href=page[ page_index ];
		createCookie("lastPage",page_index,30);
      	}
		

      };

      

      window.onload = function() {
	 page_index=readCookie("lastPage");
	 if(!page_index)
	 {
	 	page_index=0;
	 }
	 else
	 {
	 	page_index=++page_index % page.length;
	 }
	 createCookie("lastPage",page_index,30);
      	/* Win = window.open( page[ page_index ], 'Win', 'resize=yes,toolbar=yes, status=yes,scrollbars=yes, screenX=0,screenY=0, width=1000, height=666' ); */
	location.href=page[ page_index ];

      timer = setInterval( "next_page()", 10000000 );

      };

      

      // -->

</script>
</head>
<body>
</body>
</html>
hielo 65 Veteran Poster
preg_match('/user=([-0-9]+)/',$str,$m);

That won't work as desired. It will allow entries such as:
90-345

I believe the poster intends that hyphen to be "OPTIONAL and only at the beginning of the numeric substring, in which case he needs:

preg_match('/user=([-]?\d+)/',$str,$m);

where [-]? indicates an optional hyphen, and \d+ indicates one or more digits

It must be stated that the WON can also be PUSH or LOSS.

in that case search for any of those possible three values:

$str = "<td>102</td><td>Over 196.5</td><td>500</td><td>WON</td><td>+500</td>";

preg_match('\b(WON|PUSH|LOSS)\b',$str,$m);
echo $m[1];//this will echo the actual match
hielo 65 Veteran Poster
$str = '<div class="right"><a id="ctl111_contestProfileLink" href="http://contests.covers.com/Sportscontests/profile.aspx?user=265839&amp;sportid=0">Picks History</a></div>';

preg_match('#user=(\d+)#',$str,$m);
echo "User is: " . $m[1];
hielo 65 Veteran Poster

i have a page where listing of items is done...
it also have searching feature with pagination...

when i submit searching then its working fine.

where is this page you are referring to?

hielo 65 Veteran Poster

Thanks Graphix, your solution with a bit of tweaking works 100%.

did you bother to try what I gave you? On my post testArray is the only array you need. At the end, it is a two dimensional array like you requested. No need to over complicate things like you did. If you prefer to name your array, "finalArray", than that's exactly all you need to do - rename every instance of testArray to finalArray:

var testString = "1,Jeremy,130,80;2,Lauren,370,300;3,Jeancarlos,200,200;4,Luke,330,70;5,Bloom,392,108";
var finalArray = testString.split(";");

for(var i = 0, limit=finalArray.length; i < limit; i++)
{
	finalArray[i] = finalArray[i].split(",");
}

//PRINT finalArray
for (var x = 0; x < finalArray.length; x++)
{
	for (var y = 0; y < finalArray[x].length; y++)
	{
		document.write("<br /> " + finalArray[x][y]);
	}
}
hielo 65 Veteran Poster
$connection=mysql_connect("localhost","username","password") or die(mysql_error());

mysql_select_db("databasename") or die( mysql_error());

$result = mysql_query("Select field1,field2,... from Table") or die(mysql_error());

if( !mysql_num_rows($result) )
{
 echo "No records  found";
}
else
{
  $row=mysql_fetch_assoc($result);

  /* here $fieldNames is an array that contains the field names of the records returned by your query */
  $fieldNames = array_keys($row);
echo "<table border='1'> ";
echo "<tr><th>" . implode( "</th><th>", $fieldNames) . "</th></tr>";
do{
  echo "<tr><td>" . implode("</td><td>", array_values($row) ) . "</td></tr>";
 }
 while( $row=mysql_fetch_assoc($result) );
echo "</table>";
}
hielo 65 Veteran Poster

I was trying to do this all locally

I would expect your php.ini file to have the following defined within the Data Handling section:

variables_order = "EGPCS"

If it is commented out, uncomment it. Otherwise, I am not sure what's going on with your server, but if this is due Monday, my suggestion would be to use your school's server for the development.

hielo 65 Veteran Poster

what do you see when you change it to $_REQUEST: echo "<pre>Server received:" . print_r( $_REQUEST,true) . "</pre>";

hielo 65 Veteran Poster

Undefined index: searchtype

That would typically happen when the form field "does not exist", which is typically due to a spelling error. If your form field has <input type='text' name='searchType'...> (notice the uppercase 'T') then you will need the exact spelling on your results.php $searchtype=$_POST['searchType']; If you are still having problems put this at the top or results.php: echo "<pre>Server received:" . print_r( $_POST,true) . "</pre>"; it should reveal what exactly the server receives. If you don't see anything, then instead of $_POST, try $_REQUEST.

hielo 65 Veteran Poster

Go to:
http://www.quirksmode.org/js/cookies.html

scroll to the section titled "The scripts". Grab the three functions in that section and save them to a file named cookies.js. It should be clear how to use those functions.

hielo 65 Veteran Poster

I am still receiving the error I posted originally.

are you saying that the "result" you get is actually the PHP code you wrote to do the searching? If that is the case, then your server is not configured to execute php. You need to search online for tutorials to install php on whatever server you are using.

hielo 65 Veteran Poster

line 29 of your original register.php you have:

...WHERE username = 'username'");

You need to use the variable named $username. Instead, you are using a literal value. So if the user typed "secret" as the password, the line SHOULD execute:

...WHERE username = 'secret'");

but instead, it is ALWAYS executing:

...WHERE username = 'username'");

So, I suggest you change it to: $sql = mysql_query("SELECT username FROM usersystem WHERE username = '$username'") or die(mysql_error()); You also have problems on line 31 of register.php: if (mysql_num_rows($s>0))... If you look closer at line 29, $sql will contain the "result" of your SELECT query. So on line 31 you need to use that result to find the number of rows. The problem is that on line 29 your variable is named $sql, but on line 31, you are using $s which is a non-existent variable. Furthermore, the syntax is wrong. The greater than than zero expression should be OUTSIDE the inner closing parenthesis: if ( mysql_num_rows($s) > 0 )... Line 34 of config.php: $sql = mysql_query("SELECT * FROM usersystem WHERE username = 'username' AND password = 'password' LIMIT 1") has the same problem as line 29 of register.php. You need to dereference (extract the value of) the variables, NOT use literal values. So change it to: $sql = mysql_query("SELECT * FROM usersystem WHERE username = '$username' AND password = '$password' LIMIT 1",$dbConnection) NOTICE that I added a second parameter - $dbConnection. Since you said:

...Not sure how to do the first option as i …

hielo 65 Veteran Poster
var testString = "1,Jeremy,130,80;2,Lauren,370,300;3,Jeancarlos,200,200;4,Luke,330,70;5,Bloom,392,108";
var testArray = testString.split(";");

for(var i = 0, limit=testArray.length; i < limit; i++)
{
	testArray[i] = testArray[i].split(",");
}
hielo 65 Veteran Poster
hielo 65 Veteran Poster

how to escape passing value through url during pagination

you need to use the urlencode() function immediately before you create the pagination links:
http://us3.php.net/manual/en/function.urlencode.php

it there any way to use pagination without using pasing parameter in url

what you can do is see if your search box field is NOT empty. When it is NOT empty you update a session variable on your search script. Then at the point of searching your db, instead of searching based on the value of your search box (or search param querystring), you search based on what you have in your session variable.

hielo 65 Veteran Poster

Absolutely no good I'm afraid

Yes of course. Major oversight on my part. Good catch Airshow.
As pointed out, it should have been:

if (form.radChoice[0].checked ){...}
      else if (form.radChoice[1].checked ){...}
hielo 65 Veteran Poster

that javascript wasn't waiting for a response from the web service

I know, that's why I wanted to see your js implementation of saveUpdateCodes(). My guess is you are sending an asynchronous request be do not have a callback function to determine the completion of the request.

Alternatively you can execute a synchronous request.

hielo 65 Veteran Poster

On my previous post change line 53: if(!page_index) to: if(null===page_index) if you are having difficulty figuring out the path to your cookie.js file, then try typing the full path in the browser's address bar - ex:
http://www.yoursite.com/scripts/cookies.js

If you see the browser trying to download the js file OR if the browser shows you the content of cookies.js, then that IS the correct path. Once you figure out what is that full path, then use that full path as the src attribute of the script tag.

hielo 65 Veteran Poster
function user_login ($username, $password)
{
   //take the username AND prevent SQL injections
   $username = mysql_real_escape_string($username);
 ...
}

The problem is that you are connecting to the database OUTSIDE of your user_login() function, but inside the function you are using mysql-related functions. These mysql-related functions need to "see" the opened connection to the db. However, once you call the function, the connection to the db ("stored" in the $db variable) is NOT "visible" within the function. So, what you need to do is:
a. change the function so it accepts the connection as the third parameter. function user_login ($username, $password,$conn){...} and when you call the function make sure you pass the variable that holds a reference to the connection (in your case the $db variable): user_login('peter','secret',$db) OR
b. declare the $db variable global within your function:

function user_login ($username, $password)
{
  global $db;
   //take the username AND prevent SQL injections
   $username = mysql_real_escape_string($username);
 ...
}
hielo 65 Veteran Poster

window.load(function(){...});

are you actually using window.load??? Perhaps you meant window.onload? Other than that, I don't see the need to use window.onload directly. If on line 1 you set up a window.onload call and then later on line 100 you do so again, you may be overwriting the "scheduled" event from line 1. jquery handles these types of problems for you internally. So, instead of using window.onload, you can keep using $(function(){...}) as many times as you need and jquery will handle any potential "collisions".

hielo 65 Veteran Poster

when you have more than one form element with the same name (in your case you have two radio buttons named radChoice) you then need to treat it as an array.

So in your case, on what you posted instead of:

if (form.radChoice.value == "S"){...}

you needed:

if (form.radChoice[0].value == "S"){...}

similarly, the other check should have been:

else if (form.radChoice[1].value == "N"){...}
hielo 65 Veteran Poster

The problem is that the page does not reload a different URL when you refresh the page

that's because on every reload, the code executes again from the top, like it is the very first time it is executing. You need to "maintain" state across refreshes. For this you will need to use cookies.

Refer to the code below. Pay special attention to the HTML comment that starts with IMPORTANT...

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<title>Rotate Marketing</title>

<!-- 
IMPORTANT: Notice that I am importing "cookies.js". Go to:
http://www.quirksmode.org/js/cookies.html

scroll down to the section titled "The Scripts" and grab those three functions.
save them to a file named cookies.js and import them into your page similarly to
the way I am doing below
 -->
<script src="cookies.js" type="text/javascript"></script>

<script type="text/javascript">

      <!--
 
      var Win;

      var page_index = 0;

      var page = new Array();
      page[ page.length ] = "http://www.homebiz.usaloe.com";
      page[ page.length ] = "http://www.makethatmoney.usaloe.com";
      page[ page.length ] = "";
      page[ page.length ] = "";
      page[ page.length ] = "";
      page[ page.length ] = "";
      page[ page.length ] = "";
      page[ page.length ] = "";

      var next_page = function(){

      	//page_index = (( page_index === 8 ) ? 0 : page_index );
		page_index=++page_index % page.length;
      	if ( typeof Win !== "undefined" ) {

      		Win.location.href = page[ page_index ];
			createCookie("lastPage",page_index,30);
      	}
		

      };

      

      window.onload = function() {
	 page_index=readCookie("lastPage");
	 if(!page_index)
	 {
	 	page_index=0;
	 }
	 else
	 {
	 	page_index=++page_index % page.length;
	 }
jreddick82 commented: Great bit of help. Thank you +0
hielo 65 Veteran Poster

Where is your implementation for saveUpdateCodes? My guess is that your bug is in that function.

hielo 65 Veteran Poster

on line 17 of your original post, change:

<?

to:

<?php

Alternatively, you can enable short tags in your php.ini file. You will need to change:
short_open_tag = Off

to:
short_open_tag = On

hielo 65 Veteran Poster

sorry, the for clause should be

for( var i=0, limit=document.images.length-1; i < limit; ++i)
...
hielo 65 Veteran Poster
var siblings=[]
for( var i=0, limit=document.images.length-1; ++i)
{
 if( document.images[i].parentNode===document.images[i+1].parentNode)
 siblings[siblings.length]=i;
}
alert( siblings.join("\n") );
hielo 65 Veteran Poster

humbug, thanks for the reply. Hopefully icandothat can shed some light on the source of pertaining code. Take care.

hielo 65 Veteran Poster

you are welcome. Take care.

hielo 65 Veteran Poster

i am sorry i had to remove double quotes too :

Yes you do. If you leave the double quotes, you are NOT assigning a function reference. You are assigning a string. In the future, instead of replying with a condescending response ("please try before posting a solution") do make an effort to read what what ACTUALLY suggested. Clearly I did NOT suggest those quotes.

But, how will you pass a parameter to that function if it requires any?

In that case you use an anonymous function and call your function from within the anonymous function: btn.onclick = function(){doSomething("This is the param you are passing");};

serkan sendur commented: this guy is smart +3
hielo 65 Veteran Poster

>>please try before posting a solution.
I've done that time and time again. What I suggested works. But just to humor you, I tested it and it still works. So YOU must be doing something wrong on your end. You need to assign a function reference, NOT a string. Whatever work around you came up with, it's not the ideal solution.

hielo 65 Veteran Poster

>>is this feasible?
yes. make an ajax request to the "main" page and if you get the "main" page then redirect. If you are not familiar with ajax, refer to the following:
http://w3schools.com/ajax/ajax_intro.asp

On another note, if I went to your site and it's "closed", I would just leave - well, I would actually go to your competitor!

I doubt anybody (except probably the site owner) is just waiting around, refreshing the browser until you open. :)

hielo 65 Veteran Poster

should be:

btn.onclick = doSomething;
hielo 65 Veteran Poster

>>i was putzing around with this same piece of code and didn't see that either
out of curiosity, where did you guys get that code from?

>>thanks.
you are welcome.

hielo 65 Veteran Poster
case 10:
				     //1. use mysql_real_escape_string to avoid sql injection attacks
					//2. if you actually meant to assign values, you do NOT need an if
					$uid=mysql_real_escape_string($_GET['u']);
					$pid=mysql_real_escape_string($_GET['p']);
					$t=mysql_real_escape_string($_GET['ti']);
					$type=mysql_real_escape_string($_GET['typ']);

					//you can check if at least one of the values were empty as follows
					if( empty($uid) || empty($pid) || empty($t) || !empty($type) )
					{
						print "At least one parameter was empty: $uid  $pid $t $type  ";
					} 
					
					
					$query1="select * from album";
					$result1=mysql_query($query1);
					if(mysql_num_rows($result1)>0)
					{
						$i=1;
						print "<table width='1000px' cellspacing='10px' cellpadding='10px' align='center'><tr><td colspan='4' class='h1'>Click on an image to delete it..</td></tr><tr>";
						while($row1=mysql_fetch_array($result1))
						{
							
							$query3="select * from users where id = '$row1[login]'";
							$result3=mysql_query($query3);
							$row3=mysql_fetch_array($result3);							
							
							if($row3[type]==1)
							$query2="select * from artist where login = $row1[login]";
							else
							$query2="select * from listener where login = $row1[login]";
							
							$result2=mysql_query($query2);
														
							
							while($row2=mysql_fetch_array($result2))
							{
								print "<td><table class='ranprof'>";		
								print "<tr><td align='center'><a href='../album/$row1[image_thumb]' target='_blank'><img src='../album/timthumb.php?src=../album/"; print "$row1[image_thumb]&h=110&w=110&zc=1' border='0px' align='absmiddle' title='Click to view large picture'></a></td></tr>";																						
								print "<tr><td class='h2'><small>Uploaded by:</small><a href='profile.php?id=$row2[login]' target='_blank'>$row2[fname] $row2[lname]</a></td></tr>";
								print "<tr><td align='center' class='h2'><a href='index.php?u=$row1[login]&cat=10&p=$row1[id]&ti=$row1[image_thumb]&typ=$row3[type]'><img src='i/del_ico.png' width='15px' height='15px' border='0px'/>&nbsp;&nbsp;Delete</a></td></tr>";
								print "</table></td>";

								
								if($i%4==0)
								print "</tr><tr>";
								$i++;								
							}
						}
						print "</tr><tr><td colspan='4'><div id='FullPic'><div id='fullPic'></div></div></td></tr></table>";
					}
					else
					{
						print "<i>NO images uploaded.</i>";
					}
					break;
hielo 65 Veteran Poster

you are welcome

hielo 65 Veteran Poster

once the page has finished loading, if you call document.write you "destroy" the current document, and a new document will be created containing the new content you are writing. In your case, the "cellClicked" function exists in the original/old document (before document.write is executed), but since you call document.write via setUpPage after the page has finished loading:

<body onload="setUpPage()">

you "destroyed" your cellClicked function. Thus, instead of what you have, try:

...
<body>
<script type="text/javascript">setUpPage ()</script>
</body>
...

so that document.write is executed before the original document finishes loading.

VernonDozier commented: Thank you. +11
hielo 65 Veteran Poster

glad to help. Take care.

humbug commented: Good help :) +4
hielo 65 Veteran Poster

did you change:

...=new this.ajaxRequest();

to

...=new ajaxRequest();

everywhere?

Do you have URL? Most likely you are having a synchronization problem since you are submitting ajax request using the same variable without making sure that any previous request has completed.

hielo 65 Veteran Poster

try:

...
function loadURL(url)
{
mygetrequest=new ajaxRequest();
...
}
hielo 65 Veteran Poster

set the time limit on your script to zero so that your script doesn't timeout.
http://us.php.net/set_time_limit

hielo 65 Veteran Poster

>>Notice how line 24 of my code includes "GET" and not "POST"? That's the call I used to (successfully) send a GET request (as the English above clearly states).
Yes, I can see that, but it is NOT clear if you were doing this:

send_to_host('humbot.freewebhostingpro.com','POST','/index.php?a=5','');

which is NOT the correct way to call it. The parameters should not be appended to the uri. Instead you need:

send_to_host('humbot.freewebhostingpro.com','POST','/index.php','a=5');

On another note, the source of the problem is:

fputs($fp, "Content-type: application/x-www-form- urlencoded\r\n");

there should be NO space between the hyphen and urlencoded. It should be:

fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
humbug commented: That last bit of info was my problem. Cheers +4
hielo 65 Veteran Poster

LOL - Yes, of course, RegExp() :)