
Hangwire
Members-
Posts
41 -
Joined
-
Last visited
Profile Information
-
Gender
Male
-
Location
Bulgaria
Hangwire's Achievements

Member (2/5)
0
Reputation
-
Thank you all for your replies. Your feedback has been very helpful, and I'm going to re-do the entire project.
-
Thank you for your reply! Nah, I'm absolutely sure I didn't add them. This is the code of every php script in the whole project: Add-To-Database script: <?php $cocode = $_POST['cocode']; $coname = $_POST['coname']; mysql_connect ("pdb1.myhostingcompany.com", "countries", "*********") or die ('Error: '. mysql_error()); mysql_select_db ("countries") $query="INSERT INTO countries (cocode, coname) VALUES ('".$cocode."', '".$coname."')"; mysql_query($query) or die ('Error updating database'); echo " <html> <body> <center> Success! Country added. </center> </body> </html> " ; ?> Search-In-Database script: <?php mysql_connect ("pdb1.myhostingcompany.com", "countries","**********") or die (mysql_error()); mysql_select_db ("countries"); $term = $_POST['term']; $sql = mysql_query("select * FROM countries WHERE cocode = '$term'"); $num_rows = mysql_num_rows($sql); if ($num_rows == 0) { echo "No results found."; exit; } while ($row = mysql_fetch_array($sql)){ echo '<br/> Code: '.$row['cocode']; echo '<br/> Country: '.$row['coname']; echo '<br/><br/>'; } ?> I've searched the entire database for those names and couldn't find a thing. I've examined the entries for numbers 380, 401 and 403, everything looks normal. I can extract the database into an .sql, but I think that's a bit redundant. If anyone wants it, I can send it to them. Thank you for your time.
-
Hello everybody, An year ago while learning php I made a basic function to insert rows in a database and then a function to read from that database. Tl;dr I made a barcode reader. You enter the first three or two digits from the barcode of a product and you get what country it's produced in. A month ago I tried it out just by accident because some of my friends were wondering about where a product was made and my tool came to mind. When I enter 380 (Code for Bulgaria), Bulgaria pops up along with a line under it that says Jesus. When I enter 401 (One of the codes for Germany), Germany comes up along with three names - Leah, Nathaniel and Robert. 403 is another code for Germany. When I enter that, along with Germany comes up Destiny. I honestly have no explanation for this except that it's maybe some kind of SQL insert hack and someone tried to be funny. You can all test this out here: http://training.nbrain.net/searchform.html Thanks.
-
Display certain page if no results from query?
Hangwire replied to Hangwire's topic in PHP Coding Help
Thank you, I presume I can insert html code in the area between the comas? -
Hello all. I'm using this code to go through the database and output certain user-defined numbers <?php mysql_connect ("pdb1.awardspace.com", "anastasov_db","moscow1945") or die (mysql_error()); mysql_select_db ("anastasov_db"); $term = $_POST['term']; $sql = mysql_query("select * FROM countries WHERE cocode = '$term'"); while ($row = mysql_fetch_array($sql)){ echo '<br/> Code: '.$row['cocode']; echo '<br/> Country: '.$row['coname']; echo '<br/><br/>'; } ?> Now how would I go about making a page that appears if the script can't find any results in the database? Thank you in advance
-
My bad, removed the wildcards at $term, it works fine now. Thanks everyone!
-
$sql = mysql_query("select * FROM countries WHERE cocode = '%$term%'"); This is the change I made, but now it doesn't give any output at all.
-
Hello all. First of all, if this isn't the right place for this topic, please excuse me and may the moderators/admins move it where it should belong. Second, I'm trying to make a mysql search - Everything works, but if say, a user searches for 34 it displays all numbers that have the number 34 in them. I want the results to be exact - if a user searches for 34, to display only 34, not 334, 5034 or 3401 (like it happens now). Here's the code: <?php mysql_connect ("**************", "*******","*****") or die (mysql_error()); mysql_select_db ("********"); $term = $_POST['term']; $sql = mysql_query("select * FROM countries WHERE cocode LIKE '%$term%'"); while ($row = mysql_fetch_array($sql)){ echo '<br/> Code: '.$row['cocode']; echo '<br/> Country: '.$row['coname']; echo '<br/><br/>'; } ?> If you have any questions, you're welcome to ask them in the thread. Thank you in advance
-
Thank you for your time, I fixed it myself. It was a very stupid error on my behalf, in the html input form I put the of it as "password", but $_POST was looking for "pass". Fixed it and everything works like a charm.
-
PHP Function problem - article not found.
Hangwire replied to Hangwire's topic in Apache HTTP Server
1) Wont bump, but there's another rule - All users must be courteous to others. 2) As I said in the first post, it was actually very late so... excuse me, in every post after the first one I presumed I had already mentioned it was concerning apache - didn't do that, but I gave an actual link, so it should have been pretty obvious. Either way, my mistake. Thank you so much for your help, I edited the directory and it's working like a charm! All the best! -
Be a little more specific, what error does it exactly output?
-
I don't want to create a thread about another simple problem, but here it is... <?php $name = $_POST['name']; $pass = $_POST['pass']; // $ip = $_SERVER['ip']; mysql_connect ("localhost", "root", "****") or die ('Error: '. mysql_error()); mysql_select_db ("data"); $query="INSERT INTO data (name, pass) VALUES ('".$name."', '".$pass."')"; mysql_query($query) or die ('Error updating database'); In this case, the script only writes the name in the database, but not the pass. The database fields are identical, both being varchar's. So, what gives?
-
PHP Function problem - article not found.
Hangwire replied to Hangwire's topic in Apache HTTP Server
Not at all what I had in mind. I expect to see a reply in a good tone, just as I always refer to anybody else on this site. But when somebody is condescending... People should know more than just scripting languages. Let's go back on topic, though. Any ideas? -
PHP Function problem - article not found.
Hangwire replied to Hangwire's topic in Apache HTTP Server
It's an apache error! That's the whole point! How can a php script output an "Object not found!" error from apache?! And, to Dan: 1) You know, there is more than 1 timezone on this planet. 2) Have you ever worked with apache, or do I need to be dead specific about everything? 3) Thank you. -
Thank you, worked like a charm