samaru 145 a.k.a inscissor Team Colleague

There's an error in your SQL statement:

$sqlquery = "SELECT COUNT(usr_name) as FROM $Table WHERE usr_name ='$usr_name'";

The "as" statement assigns aliases to columns. In this case, your're not assigning an alias to the result that count(user_name) spits out. You need to put a name for a column's alias after the "as" but you skipped that and just wrote the "FROM."

Killer_Typo, check your PMs.

samaru 145 a.k.a inscissor Team Colleague

You're executing the sql statement but you're not retrieving anything. You have to fetch the results into something like an associative array, so you use mysql_fetch_assoc(). Try this:

$Table = 'user';
 $name = 'rootx';
 mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database");  //connecting to the database using the variable set
 @mysql_select_db("$DBName") or die("Unable to select database $DBName");		 //at connection to the databse select DBNAME (phpforms) or tell that it couldnt connect
 $sqlquery = "SELECT COUNT(user_name) as user_name FROM $Table WHERE user_name = '$name'";
 $results = mysql_query($sqlquery);
 $user_count = mysql_fetch_assoc($results);
 echo "current user name " . $_POST['usr_name'] . "<br />";
 echo "query returned " . $sqlquery . "<br />";
 echo "query returned " . $user_count['user_name'] . "<br />";

Also, don't retrieve form variables as $_POST[whatever], use the apostrophes like I did in the code.

Killer_Typo commented: Was very willing to help me find the answer that i needed. +13
samaru 145 a.k.a inscissor Team Colleague

You can't use relative file paths due to default security settings. Easiest way around this is to not use "../" - you have to either use absolute file paths or use #include virtual.

samaru 145 a.k.a inscissor Team Colleague

Finally, there's a book that will help you prepare for the MySQL certification exams. Learn more about it here:

http://www.amazon.com/exec/obidos/tg/detail/-/0672326329/qid=1087361084/sr=1-1/ref=sr_1_1/002-7750886-2407247?v=glance&s=books

samaru 145 a.k.a inscissor Team Colleague

Try:

select count(user_name) as usercount from $table where user_name = '$name'

Then extract the value 'usercount' from the recordset and if it's 0, none exists. If it's greater than 0, then it exists.

samaru 145 a.k.a inscissor Team Colleague

around the pizza

samaru 145 a.k.a inscissor Team Colleague

Apartment --> Hotel

samaru 145 a.k.a inscissor Team Colleague

I noticed that today too. Pretty interesting stuff. 10MB attachments. w00t!

samaru 145 a.k.a inscissor Team Colleague

Every day that I visit this forum the main directory listing has changed, along with the location of every other sub-forum and forum group.

[img]http://www.vehmic.com/upload/makeitstop.gif[/img]

LOL. Dani, sound familiar? :cool:

samaru 145 a.k.a inscissor Team Colleague

The directory you're uploading to has to have the appropriate security attributes. The most important is the -w attribute. A directory that I use, in one app I created, has the following: drwxrwxr-x - it's used for uploading stuff to.

samaru 145 a.k.a inscissor Team Colleague

srry for the double post, but i figured it out, i had accidently included $email twice, once removing the second $email it all worked out. thanks arizona web for the help, i wouldnt have thought to double check that if i hadnt seen the error that i got.

Glad you were able to figure it out, but please use the "edit" button to modify your post. It doesn't take very long. It's the second time, that I know of, that you double post. I don't want to be a bit**, but obey the rules.

samaru 145 a.k.a inscissor Team Colleague

No problem. Let us know if you need any more help/insight. :cool:

samaru 145 a.k.a inscissor Team Colleague

Access isn't a database

An Access database is a database. Anything that's used to store information in a structural way is a database. Whether it's flat (stored in a file), hierarchical, network, object, or the most, popular relational, it's a database; they're all forms of storing data.

What's better? Well, Access is designed to function as a desktop application for a single user to store information. It's possible, however, to have multiple connections to it, but I wouldn't recommend it. The more connections you have to it, the more it slows it down (more severe than MySQL), and the higher the chances of data corruption (you could have multiple people modify a field in the table at the same time, and information may be overwritten; so you'd have to have some sort of locking mechanism to prevent this). I only recommend Access for personal use because it provides tools for reporting and easy data retrieval and insertion.

If you're going to create an application where multiple users have to retrieve data, I suggest you go with MySQL. Because it's a database server, it's ready to deal with multiple users. It handles locking and data corruption. It's fast too. It has security features, among other things. Also, it's free for non-corporate use, unlike Access.

samaru 145 a.k.a inscissor Team Colleague

Yes! Sorry for the f-up. Also, Dani, is there something you can do about the horrible parsing job the code tags do? It's putting unnecessary spacing between code. Look at the code I posted before, where it says "NewWindow" - there's a spacing there.

samaru 145 a.k.a inscissor Team Colleague

Thank you. I feel silly now!

(Who the hell ever looks at the stuff at bottom of page? )

Absolutely no one. :cool: Any book on web usability will tell you this. The only thing people look for at the bottom of each page is copyright information. I don't think people would expect staff info on the bottom. :p

samaru 145 a.k.a inscissor Team Colleague

awesome --> Anime

samaru 145 a.k.a inscissor Team Colleague

truck driver to do this job

That's nothing. An old professor had a student that went from mining coal to mining data from databases. Hell of a jump, I gotta say.

samaru 145 a.k.a inscissor Team Colleague

I get the feeling that it's just some pathetic plug. A person with only one post putting up a URL for people to visit? Hmm, let's delete the URL.

samaru 145 a.k.a inscissor Team Colleague

What i like to do with form submissions...

First off, you never want to put your SQL login info directly in your script instead make a file like db.cnnt.php

Yeah I agree. I usually set aside a separate php file where I include global variables and settings. Here I include the passwords. However, I think Killer_Typo is doing this now because it's only an example to show how to get data from forms and do stuff with it.

samaru 145 a.k.a inscissor Team Colleague

Are you just trying to open up a new window when something is pressed? Why not try the TARGET="_BLANK" method (insert this in your "A HREF" tag)?

Or the following method:

<script language="javascript">
<!--
 
function popupNewWindow(page) { 
window.open(page, "AddTask", "width=570,height=560,location=no,scrollbars=yes,menubars=yes");
}
 
-->
</script>
 
<a href="javascript:popupNewWindow('somepage.htm')">Click insert new</a>

Not sure if this is what you want.

samaru 145 a.k.a inscissor Team Colleague

This would be good material for the Careers Forum. Off it goes.

ajelliott commented: Thank you for your suggestions and support. +4
samaru 145 a.k.a inscissor Team Colleague

That sounds fine. Maintaining it as an array gives you a lot of flexivity. You can manipulate it easily with the PHP array functions.

samaru 145 a.k.a inscissor Team Colleague

Glad you were able to help yourself, but remember, don't double post. If you need help with displaying the data, give us a holler.

samaru 145 a.k.a inscissor Team Colleague

wow thanks that fixed it, but im not sure if i got the output i am supposed to get. though i plan on working on this a little more. thanks for the help i didnt even notice that. maybe from now i should just try to work with my variables in lowercase.

Glad you were able to get it working! Yeah, I usually keep my variables lower case. The only place I use capital letters are in classes.

i plan on posting it in the snipits area.

Yes, definitely. I'm sure people will find it helpful! :cool:

samaru 145 a.k.a inscissor Team Colleague

From what I remember, QBASIC was not only a programming language but a software environment as well - and therefore it ran somewhat like an interpreter? Meaning that you couldn't write a program in it that would be able to stand alone. The code had to be executed from within the QBASIC software program.

You could start linking your own EXEs starting QB 4.5, I believe. Or at least that's the first version I had when I started creating my own. Executables were large, so I assumed it just attached the interpreter and libraries you used for you program to the executable. It's impossible to create an OS in VB because it relies on the Windows OS. As far as QBASIC, I think you might be able to, but most of your program would be composed of assembly calls. It'd still be a very limited program still.

samaru 145 a.k.a inscissor Team Colleague

You defined the variable "$Table" with a capital T, yet you try to interpolate it in the querystring with a lower case "t." PHP is case sensitive for user defined variables.

samaru 145 a.k.a inscissor Team Colleague

The Geek's Lounge is usually reserved for social talk on non-tech issues. Your post will get better responses if sent to the hardware forum. Off it goes.

samaru 145 a.k.a inscissor Team Colleague

Given that the data is stored in an array, what type of structure should I use for storing it?

Didn't you say you wanted it in a comma delimited string? So your structure would be a string. All you would need to do is loop through the array, and as you're looping, append\concatenate the adjacent strings in the array. Fortunately, you could also use the implode() function, so you'll have something like this:

$values = $_POST['value']; // getting value array from form variable
$delimited_values = implode(",", $values);
echo $delimited_values;
samaru 145 a.k.a inscissor Team Colleague

I think you might've downloaded something for linux, or maybe the source code. There's a link here http://www.php.net/downloads.php that says "PHP 4.3.7 installer" under "Windows Binaries" - download that. I assume you're using windows because you mentioned ".exe." Once you click on that link, you can download the exe from any one of the mirrors. You'll need a web server before installation. Also, you'll need a database server, like MySQL, if you want to setup a forum on your computer.

If you just want a free forum, register for a free one here: http://invisionfree.com/

samaru 145 a.k.a inscissor Team Colleague

That is what I thought it was, Ijust wanted to know that I am not the only one who thinks that way. I guess I should get them to switch us to Linux/Apache?

Well, all I can tell you is that I've had a lot of problems with IIS and PHP regarding sessions. If it's not going to be a hassle switching over, I would recommend it. PHP is made to shine on Linux running Apache. Then again, you could have other apps depending on IIS, so I would consider that as well. If you do decide to run on IIS, make sure you have the newest version with all the patches.

samaru 145 a.k.a inscissor Team Colleague

It's up to Dani to decide. She decides what the prize will be.

samaru 145 a.k.a inscissor Team Colleague

he had marshmellows

samaru 145 a.k.a inscissor Team Colleague

We really need a competition, I would be glad to participate. Incissor your idea for magazine covers sounds cool. what was that last thing you said?
Whats it mean?

Glad you liked my idea! I still think we should do it. Oh, and as far as that expression, it's French and its literal meaning is "it's the life." In English, it's used to say, "ah... that's life I guess, what are you gonna do."

samaru 145 a.k.a inscissor Team Colleague

Tools Using to Build Site:

all the tools that Come with MX2004 W/ Flash.

Are you using some sort of application server? I would assume you're using ColdFusion MX because a developer version comes with the MX 2004 CD. If you're not, and are using something like PHP, read this to give you an idea:

http://moskalyuk.com/php/yourownsearchengine.htm

Also look at: http://www.hansanderson.com/php/search/

Writing a search engine can take a lot of work depending on your requirements, so I suggest you just take one from hotscripts.com to save time. If you are using ColdFusion, you can use the Verity engine that comes with it, and you won't have to write much code. It would also be faster than if you had written it yourself in ColdFusion too.

Killer_Typo, please use the "edit" button and don't double post. Thanks!

samaru 145 a.k.a inscissor Team Colleague

I agree that it doesn't make that much sence, but the question was if it was possible to compile PHP.

Yup, I know. I was only throwing in my two cents on how I thought it didn't make much sense. I know that almost nothing is impossible because I'm always surprised that someone, somewhere, has done it.

samaru 145 a.k.a inscissor Team Colleague

Thanks Inscissor,

To be honest, I don't do much work with forms, which is why I wasn't sure how to handle this. I really appreciate the help, though.

Were you able to figure it out? I do this all the time, so it's no sweat. I'll give you code if you want.

samaru 145 a.k.a inscissor Team Colleague

You can connect to a MySQL Database server without a problem. MyODBC makes it easy. Take a look at http://www.devarticles.com/c/a/ASP/Using-MyODBC-To-Access-Your-MySQL-Database-Via-ASP/ for a good tutorial. Let me know if you need help setting it up or with code.

WebHoststalk, don't double post.

samaru 145 a.k.a inscissor Team Colleague

Well, your problem seems to stem from how you're creating the checkboxes in the loop. First of all, here:

echo "<input type=checkbox value=\"".$act_row['action_id']."\"> ";

you don't create a name for the checkbox, so how are you going to retrieve it? The way it's usually done is you give the checkbox a name with open and closed bracks, like this: values[]

So when you pass this over, it'll pass it over as an array. So this is all you have to do:

<?php 
	$sql2 = "SELECT * FROM tbl_action"; 
	$result = mysql_query($sql2); 
			 
	while($act_row = mysql_fetch_array($result)) { 
	echo "<input type=checkbox name="values[]" value=\"".$act_row['action_id']."\"> "; 
	if(strstr($myrow['spy_action'], $act_row['action_id'])) 
		   echo "checked>"; 
	echo ucwords($act_row['action_name'])."<br>"; 
	} 
?>

So when you submit this, it'll submit an array of the values of only the ones that got checked. So you loop through this array, in this case being values[]. Also, when you're retrieving this form variable, retrieve it as $_POST and not $_POST']. I'm sure you can do the rest. Anything else, let me know.

samaru 145 a.k.a inscissor Team Colleague

I'm pretty sure it's a bug\quirk with PHP and IIS. I had a problem with IIS expiring sessions. I tried several ways to expire sessions under IIS and nothing. It would work under an Apache server though. I asked about a million people what could be wrong and no one knew.

samaru 145 a.k.a inscissor Team Colleague

All you have to do is run a select statement looking for the value you just inserted. This goes right after your insert statement.

Here's some pseudo code:
 
1. insert into table(field1) values('value')
2. y = select count(field1) from table where field1 = 'value'
3. if (y == 1)
	  just one exists
   elseif( y > 1)
	  multiple exist

If you need more help let us know.

samaru 145 a.k.a inscissor Team Colleague

I don't think I understand you correctly. All you want to do is check multiple checkboxes, put those checked values in a comma delimited string, and insert it in some table?

samaru 145 a.k.a inscissor Team Colleague

How much memory do you have on the server? I have two servers, one with 128MB, and another with 512MB, and it runs fine. I don't know off hand if there's a PHP restriction on array sizes, but I know it must depend on your memory. Also, if you're trying to initialize a large array, consider using array_fill():

$array1 = array_fill(0, 160000, $value1);

samaru 145 a.k.a inscissor Team Colleague

It is possible to compile PHP code into a standalone application. I've seen a media-database that was written in PHP, but all I had to to is run an EXE file.

I googled a bit and this is what I found:
--quote from website http://www.roadsend.com/home/index.php?SMC=1&pageID=compiler --
Compile Stand Alone Applications

PCC allows you to compile your PHP source into stand alone applications. No interpreter is required. Your source is compiled into an optimized machine executable program. The program is distributable with or without the source code and cannot be decompiled back into it's original PHP source. Distribution (or sale) of your compiled programs is royalty free.

Yes, I've heard of this, but it doesn't make sense to start an application from scratch using PHP. I guess if you already had plenty of code, APIs and what not that you wanted to reuse, you could utilize PHP. However, It doesn't make sense to me creating a server or a desktop application using a language that was designed for the web.

samaru 145 a.k.a inscissor Team Colleague

Have you looked at the function fopen() under php.net? Plenty of examples there. If you need any more help, let us know.

samaru 145 a.k.a inscissor Team Colleague

crumble --> cookie

samaru 145 a.k.a inscissor Team Colleague

humility --> fun

samaru 145 a.k.a inscissor Team Colleague

the cheese mountain

samaru 145 a.k.a inscissor Team Colleague

A CSC degree is worth a lot. From what I've read, it's not so much as what you learned from it (well, it does matter in a way) but what matters is that you had the intelligence, persistence and determination to actually complete it. It's a task that is sometimes daunting. A CSC degree is something you HAVE to actually be in for a few years to actually get it... not like a certification where you can pick up a book and take the exam within one week if you really cram.

I can understand why CSC courses are so mathematically involved. "Computer Science" is a "science" (hence the name) and one of the best ways to prove experiments, theories, etc. is through the use of mathematics. I don't have a problem with that. In college, they teach you other material besides programming because they want to prepare you for ANY computer related position... not in using computers/software, but creating computers and software. I don't have a problem with this either.

What I DO have a problem with are the methods for teaching the material. What, just because you're learning something technical, does it have to boring? Not interesting? I highly doubt it. I think it comes down to just keeping a pathetic level of prestige... most college think that because other colleges teach it in a dry-boring fashion, they have to teach it that way too (hence relying on overpriced hardcover academic books). At least at the …

samaru 145 a.k.a inscissor Team Colleague

Yeah, why DID YOU become a CSC major? My reason is I got tricked. In high school they make you think that because you know how to use Windows, can write a few scripts, know some networking and can take apart/put together a computer, that you should go ahead with computer science.


HOW WRONG.

Ask computer science majors how often they do that in class. You'll get a nice laugh. Also, I don't know about your computer science classes (whom ever is in High School currently), in my high school they brainwash you into thinking computer science is all programming. My 3 years of computer science in high school all consisted of QBASIC, Pascal, Visual Basic, and C++. All we did was cover programming and algorithms. In college you'll realize that there's more than programming in computer science. THAT's what I didn't know back in high school. Stuff like Networks, Encryption, Databases, Artificial Intelligence, 3D Programming, Web Development, Servers, computer architecture, operating systems (theory behind it), compiler construction, computer mathematics, robotics, the list goes on. Of course the hardcore techies will have a better idea of what to expect, but others will not. Also very little is stressed into "real world" programming in the business world (what tools they use, methods). It really is a shame.

samaru 145 a.k.a inscissor Team Colleague

I am trying to find out code or way of making sure noone can right click and save images on the website..there must be a way..I am working on Dreamweaver - so I am not very code literate...any suggestions??

Are you trying to protect the images from your web site? It's impossible. Whatever trick you try to pull, as long as I can see it, I can take a screenshot of the entire window, crop it in a graphics program, and then I have it.

If you're trying to avoid hotlinking (so others don't use the images off your server and drain your bandwidth), then configure your web server to do so. Just tell us the server you use.

If you want to give the user a hard time saving the images by right clicking and saving, use the methods from this URL. Keep in mind though that experienced web designers/developers/power users, know how to get around these. They also know about the screen capture method:

http://www.htmlite.com/faq010.php

Other ways include having a Flash file that displays the image or using some sort of server script to display the image. The server script could point to the image, and in your <img> tag, you would have the path to the server script page, not the image's path. So it would look something like this:

<img src="someimage.php?id=323">

That way, a person wouldn't know the path to the image to hotlink. Also, try avoiding the …