coldasice
Dec 21 2007, 11:21 PM
QUOTE <?php session_start(); include "database.php"; include "edit.inc.php"; if (!$_SESSION["valid_user"]) { // User not logged in, redirect to login page Header("Location: main.php"); } if(isset($_POST['submit'])){
$email = $_POST['email']; $msn = $_POST['msn']; $info = $_POST['info'];
$updateemail = "UPDATE users SET email = '$email', msn = '$msn', info = '$info' WHERE username = '$username'";
mysql_query($updateemail) or die("culd not edit your info"); echo "info updated"; } // Display logout link echo "<p><a href=\"member.php\">Click here to go back to info page!</a></p>";
echo "$email"; echo "$msn"; echo "$info";
$username = $_SESSION["username"];
$query = mysql_query("SELECT * FROM users WHERE username='$username'");
$all = mysql_fetch_array($query);
$email = $all['email']; $msn = $all['msn']; $info = $all['info'];
echo " <table width=\"100%\" border=0 cellpadding=1 cellspacing=0> <form name=login action='$PHP_SELF' method=post> <tr>
<td width=80>Email: </td> <td width='160'><input tabindex=1 type=text name=username value='$email' style='width:150;'></td> </tr> <tr> <td>MSN: </td> <td><input type=text name=password value='$msn' style='width:150'></td> </tr> <tr> <td>Info: </td> <td><textarea rows=\"10\" cols=\"45\" name=\"'info'\" id=\"'info'\">$info</textarea></td> </tr> "; echo " </tr> <tr> <td> <td colspan=\"3\"> <table border=0 cellspacing=0 cellpadding=0 width=100%> <tr> <td width=50%> <input type=\"submit\" name=\"submit\" id=\"submit\" value=\"submit\" /> </form> </table> "; ?
Reply
sonesay
Dec 21 2007, 11:27 PM
try moving $username above before your update query like this CODE $username = $_SESSION["username"];
$updateemail = "UPDATE users SET email = '$email', msn = '$msn', info = '$info' WHERE username = '$username'";
Reply
coldasice
Dec 21 2007, 11:34 PM
QUOTE(sonesay @ Dec 22 2007, 12:27 AM)  try moving $username above before your update query like this CODE $username = $_SESSION["username"];
$updateemail = "UPDATE users SET email = '$email', msn = '$msn', info = '$info' WHERE username = '$username'"; this just delete the whole row in my user name  so all go blank
Reply
sonesay
Dec 21 2007, 11:36 PM
QUOTE(coldasice @ Dec 22 2007, 12:34 PM)  this just delete the whole row in my user name  so all go blank  post your other code too include "database.php"; include "edit.inc.php"; and also include your database table layout
Reply
coldasice
Dec 21 2007, 11:43 PM
CODE <?
/** * Connect to the mysql database. */ $conn = mysql_connect("localhost", "root", "cold") or die(mysql_error()); mysql_select_db('new', $conn) or die(mysql_error());
?> thats my database.. inc is not a script i was just testing out to see what happened if i made the last part a function ;=) basilcy the same it deletes all ;O
Reply
sonesay
Dec 21 2007, 11:46 PM
try this CODE $username = $_SESSION["username"];
if(isset($_POST['submit'])){
$email = $_POST['email']; $msn = $_POST['msn']; $info = $_POST['info']; $updateemail = "UPDATE users SET email = '$email', msn = '$msn', info = '$info' WHERE username = '$username'"; mysql_query($updateemail) or die("culd not edit your info"); echo "info updated"; } // Display logout link echo "<p><a href=\"member.php\">Click here to go back to info page!</a></p>";
echo "$email"; echo "$msn"; echo "$info";
$username = $_SESSION["username"]; before the if statement
Reply
coldasice
Dec 21 2007, 11:51 PM
QUOTE(sonesay @ Dec 22 2007, 12:46 AM)  try this CODE $username = $_SESSION["username"];
if(isset($_POST['submit'])){
$email = $_POST['email']; $msn = $_POST['msn']; $info = $_POST['info']; $updateemail = "UPDATE users SET email = '$email', msn = '$msn', info = '$info' WHERE username = '$username'"; mysql_query($updateemail) or die("culd not edit your info"); echo "info updated"; } // Display logout link echo "<p><a href=\"member.php\">Click here to go back to info page!</a></p>";
echo "$email"; echo "$msn"; echo "$info";
$username = $_SESSION["username"]; before the if statement still dont work  it still deletes the whole username row ;/
Reply
sonesay
Dec 22 2007, 12:01 AM
what do you mean delete? I only see an update statement and a select statement for displaying. If you get empty fields maybe the mysql database table is empty. maybe try move the echo after the query is done CODE
$username = $_SESSION["username"];
$query = mysql_query("SELECT * FROM users WHERE username='$username'");
$all = mysql_fetch_array($query);
$email = $all['email']; $msn = $all['msn']; $info = $all['info'];
echo "$email"; echo "$msn"; echo "$info";
Reply
coldasice
Dec 22 2007, 12:13 AM
QUOTE(sonesay @ Dec 22 2007, 01:01 AM)  what do you mean delete? I only see an update statement and a select statement for displaying. If you get empty fields maybe the mysql database table is empty. maybe try move the echo after the query is done CODE
$username = $_SESSION["username"];
$query = mysql_query("SELECT * FROM users WHERE username='$username'");
$all = mysql_fetch_array($query);
$email = $all['email']; $msn = $all['msn']; $info = $all['info'];
echo "$email"; echo "$msn"; echo "$info";
well as far as i register.. the update querry dont do *BLEEP*....... and i moved echo.. dosnt work ;O
Reply
sonesay
Dec 22 2007, 12:20 AM
the query update looks ok to me. The only reasons it wont update is if there is no record to update, If there is error because of wrong field names etc the error should return. I would check and make sure $username is assigned when used in your query, and check your database it self. say if you want to update user 'bob' check if 'bob' exist in users and 'bob' is assigned properly to $username before doing query, maybe output it just to test on the screen. I cant think of any other reasons why it will not work if its not givng back any errors. Also try to remember to assign your variables before attempting to use it. It wont work if you try and use $username and you actually assign it futher down the code because it will be blank when you are calling it before.
Reply
coldasice
Dec 22 2007, 01:27 AM
QUOTE(jlhaslip @ Dec 22 2007, 02:18 AM)  CODE $username = $_SESSION["username"]; have you tried single quotes here? Basic debugging would suggest that you display (print) the data in the query before and after the query, along with the results of the query after the select. This will confirm the values the query is using, and the results it is getting. And does the select work correctly in phpmyadmin? thanks for ur respons.. but.. lol ;O that dont help =D and yeah.. its a part of a learning login.. so basicly my username is in the session  thanks for trying  and its solved here is code =D and thank to you sonesay. for helping me =D this happende bcouse i made the thig from scratch.. but..... i got some kind of error.. but i dont remember what error it was... so i found some boxes on net.. and copyed source and edited it to fit what i wanted..  and just so you know be4 u posted.. i solved this.. i got fed up.. and saw trough code. and saw it.. CODE <?php session_start(); include "database.php";
if (!$_SESSION["valid_user"]) { // User not logged in, redirect to login page Header("Location: main.php"); }
$username = $_SESSION["username"];
if(isset($_POST['submit'])){
$email2 = $_POST['email']; $msn2 = $_POST['msn']; $info2 = $_POST['info'];
$updateemail = "UPDATE users SET email='$email2', msn='$msn2', info='$info2' WHERE username='$username'";
mysql_query($updateemail) or die("culd not edit your info"); echo "info updated";
}
$query = mysql_query("SELECT * FROM users WHERE username='$username'");
$all = mysql_fetch_array($query);
$email = $all['email']; $msn = $all['msn']; $info = $all['info'];
echo " <table width=\"100%\" border=0 cellpadding=1 cellspacing=0> <form name=login action='$PHP_SELF' method=post> <tr> <td width=80>Email: </td> <td width='160'><input tabindex=1 type=text name=email value='$email' style='width:150;'></td> </tr> <tr> <td>MSN: </td> <td><input type=text name=msn value='$msn' style='width:150'></td> </tr> <tr> <td>Info: </td> <td><textarea rows='10' cols='45' name='info' id='info'>$info</textarea></td>
</tr> </tr> <tr> <td> <td colspan=\"3\"> <table border=0 cellspacing=0 cellpadding=0 width=100%> <tr> <td width=50%> <input type=\"submit\" name=\"submit\" id=\"submit\" value=\"submit\" /> </form> </table>";
echo "<p><a href=\"member.php\">Click here to go back to info page!</a></p>"; ?> [SOLVED]
Reply
sonesay
Dec 22 2007, 01:20 AM
i need some bigger glasses  CODE <td width=80>Email: </td> <td width='160'><input tabindex=1 type=text name=username value='$email' style='width:150;'></td> </tr> <tr> <td>MSN: </td> <td><input type=text name=password value='$msn' style='width:150'></td> </tr> <tr> <td>Info: </td> <td><textarea rows=\"10\" cols=\"45\" name=\"'info'\" id=\"'info'\">$info</textarea></td>
change the name='' to the corret names CODE <td width='160'><input tabindex=1 type=text name='email' value='$email' style='width:150;'></td> </tr> <tr> <td>MSN: </td> <td><input type=text name='msn' value='$msn' style='width:150'></td> </tr> <tr> <td>Info: </td> <td><textarea rows=\"10\" cols=\"45\" name='info' >$info</textarea></td>
man this is what happens when you ignore the obvious
Reply
jlhaslip
Dec 22 2007, 01:18 AM
CODE $username = $_SESSION["username"]; have you tried single quotes here? Basic debugging would suggest that you display (print) the data in the query before and after the query, along with the results of the query after the select. This will confirm the values the query is using, and the results it is getting. And does the select work correctly in phpmyadmin?
Reply
Similar Topics
Keywords : , mysql, php, som, basic
- Create Table - Mysql Code - Help
(1)
Mysql Error
(3) ok i need some more help from the wonderful coders here at Trap. I'm almost done with my CMS
script, but i'm having a problem with the installer.php file, when it trys to inseret the user
data into the database i keep getting the following error: CODE mySQL Error: You have an
error in your SQL syntax; check the manual that corresponds to your MySQL server version for the
right syntax to use near ';INSERT INTO `members` (`id`, `name`,
`username`, `password`, `email`, `title`) ' at lin....
Html Form!
Using MySQL?! (4) Hey, I need your help again! I need some good working tutorial how I can update my SQL through
HTML form. I did use some tutorials online found with the help of google; but they do not work
properly; I mean there are still small mistakes. I need to have a good tutorial to follow. It
should be based on security and more things. It has to be done in proper way.......
Best Php And Mysql Editor For Noobs
anyone any php or mysql editor that is good for noob (6) hi there guys, from my previous posting, i am a noob in php and mysql programming. I want to know
if there are any php and mysql editors which are best for me as a noob. i appreciate your kindness
....
Php And Mysql Programming
anyone knows a code for mysql and php (2) hi everyone! I am making a program using php and mysql...I am a noob on this so i need your
help guys...I want to make a simple program that will some values and then store them on a database
and then retrieve them...uhmm let me give an example out put of what i need. This is the example
say..: Enter First Name: Enter Last Name:
Enter Age: Enter Address: ..those
are the data needed for input values...my question now is how can I make a database....
Best Sites For Learning Php-mysql
(4) Hi I was reminded of this earlier by a post in a topic, meant to post it but forgot and the topic on
php books reminded me. Well anyway there is tyhschools for learning php (unless someone else knows
a better 1) but I wan't to know what is the best site for using php with mysql (using
phpmyadmin) also whats the difference between postgresql and mysql? though I must admit the
postgresql version of phpmyadmin whatever it's called looks better (visually)!....
Tools Needed!
PHP & MySQL (9) Hello, everyone! I need some tools for those two things to test PHP scripts coming together with
database on my laptop, instead checking them on a web-server which takes time.....
Php + Mysql Question!
While inserting data into MySQL, how can I know if the data I'm in (4) Basically, I want to know if the Data I'm inserting through a Form is already there or not. Sort
of a Username registration page. I have this, but it doesn't appear to work... CODE
$result = mysql_query("SELECT * FROM users WHERE
username='$username'"); if($result == 1) { echo
'<h1>ERROR!</h1>The username you have chosen already exists!'; }
....
Mysql Won't Update
(4) Ok, so I'm making some arcade administration software so I don't have to add games the hard
way, well anyway, one of the features I have is that on the homepage is a featured author and as
such I just have it so it updates one line in the mySQL. Well, the page with the form passes on the
varibles fine and the updating page recieves them because I echoed everything, then I build the
query and I even echo the query and it comes out exactly how I want it to, but for some reason, the
database itself won't update even though all the varibles are there. Here's....
[php/mysql]id Trouble [resolved]
(3) session_start(); include "database.php"; if (!$_SESSION || $_SESSION { // User
not logged in, redirect to login page Header("Location: main.php"); } $result =
mysql_query("select * from users order by id asc"); while($r=mysql_fetch_array($result))
{ $username=$r ; $info=$r ; $msn=$r ; $email=$r ;
$id=$r ; $password=$r ; $userlevel=$r ; echo "
user ID User Level U....
[mysql]get Id Of Loged In User?
(7) how to get the id number of the loged in user? my db is id. username. password. i have tryed a
few things.. but i never seem to get it right /ohmy.gif" style="vertical-align:middle" emoid=":o"
border="0" alt="ohmy.gif" />....
The Artists Tutorials :mysql Basic Commands
The Artists is an online programming unit and gfx designing clan. (0) Let's Talk about basic mysql commands used in php. I will now show you a list of the most common
MySQL FUNCTIONS : QUOTE mysql_connect(MySQL server name,username,password) - opens a connection
to a MySQL server. mysql_select_db(database name,connection id) - selects a database residing on
the MySQL server. The database name parameter referes to an active database on the MySQL server that
was opened with the mysql_connect function. The connection identifier is a reference to the current
MySQL connection. mysql_query(sql query) - sends a query to the currently ac....
Problem With A Mysql Join
Problem with a mysql join (2) Hello I am trying to write a script whereby I can pull an image out of one database table and
display it in relation to its category_id in another table. I am using a my_sql join function that
is joining the tables correctly, however it only shows the one same image from the top field of
those combined rows on every single page. I need it display the image according to its category_id
for that particular page. I am thinking I need to set variables to represent those specific rows but
I'm not sure how to do that. Here is my code CODE { $result = mysql_que....
Getting Php 5 To Work With Mysql
getting PHP 5 to work with MySQL (0) Just thought this would be of extreme help to those who are planning to migrate to php5 and still
continue using MySQL same way as before:.... to get mysql work with the php 5 copy
/dll/libmySQL.dll to the directory where php 5 resides and copy the /extensions/php_mysql.dll to the
directory where php.exe resides.(if you can't find the two above files probably you are using an
old release of php 5.you should check for latest at :http://snaps.php.net/) in additon uncomment
extension line in php.ini and add the following code to a gnereal database file(dbcon.php) in m....
Php And Mysql Applications
(3) Ok I have started useing PHP and MySQL recently and I am wondering how I go about createing an
application. I looked for tutorials and guids at w3schools.com but couldnt find what i was looking
for. All I really need is a list of a few steps to take to get a general idea on were to start when
makeing an application. I would appreciate any help you may have to offer.....
Php, Mysql, Apache
(4) ok, i am hosting a smf (simple machines forum) and in order to do so, i need apache, mysql and php
installed. so i got apachefriends xampp. it works, but idk where to go from there. am i ready to
just host and stuff. or do i need to do a couple more things. basically what i need is a guide on
how to set up a php website. or just confirmation that all i have to do is load the files onto the
website, then im ready to go. thank you....
Some Mysql Basics
(4) Greetings this tutorial will show you some mysql basics.. MySQL is one of the most used database. a
simple config file at the top add this CODE <?php ?> after <?php add
$username= "root"; // Username that has access to your database $password=
""; //Password that has access to your database $host = "localhost"; // The
host where the database is (mostly this is localhost) $db = "databasename"; //
The name of the database where you want to work with //connect to the database mysql_connect(....
Simple Mysql Query Limiting
(9) Simple MySQL Query Limiting CODE <?php // If mypage?limit=blah is not defined returs 5
if ( $_GET['limit'] == NULL ) { $limit = 5; } // Else else {
$limit = $_GET['limit']; } $query = mysql_query("SELECT
* FROM members LIMIT '$limit'") or die(mysql_error()); while
($sql = mysql_fetch_array ($query) ) { echo
$sql['mem_name'] . '<br>'; } ?> Have fun......
Mysql Query
(2) theres a bug somewhere in this query and i can't seem to find it. does anyone else see it?
CODE $query = "insert into templates
(tuid,tname,tdescription,template,archivedefault) values (1,'Sample Archive
Template','A sample archive template that only shows the name of the article with a link to
the default article viewer.','<a
href='viewarticle1.php?aid=[id]'>[articletitle]</a>',FALSE
41;"; ....
Putting Data Of 2 Pages In Mysql At Once
(1) suppose i have a page, page.php?part=1 there i have some text fields. user will give input, but
after taking input, it will not put the data in mysql .. but it will take to the next step..
page.php?part=2 (if any field is left blank, it will not go to next page.. ) . and there also some
fields.. after the user has filled that form also, then it will insert all data (from part1 and
part 2) in mysql. i want to ask, how i can collect data from 2 pages and put in mysql at once.....
Editing Information In A Mysql Database And Deleting Rows
(5) I need help with a couple of things. First, I need to know how to retrieve information from a mysql
database and edit it then re add it to the database. I also would like to know how to easily delete
a mysql row. And I want this done without going to phpMyAdmin. Thanks for the help!....
Importing .csv Into Mysql Database
NEED HELP! (6) I need help importing a .csv contents into a Mysql database. I have this. But its not working.
CODE <?php connection = mysql_connect("******", "**********",
"********") or die ("Unable to connect to server"); $db =
mysql_select_db("b9_259782_CC", $connection) or die ("Unable to select
database"); fopen ('csvranks.csv', 'r');
mysql_query("INSERT INTO test_table (id, name, guild, level, exp) ?> What
am I doing wrong? The mys....
How To Delete A Row In Mysql.
A very simple help required (4) Im using the following code, for very simple work.. it simply gets and print the comments which are
stored in the database. Now it will show like comment 1. comment 2. comment 3. etc etc i want to
add 'delete' option that i can delete any comment. it displays like comment 1.
Delete comment 2. Delete comment 3. Delete
So that when i click on delete, it simply deletes the comment and print the remaining comments. Its
very simple. i hope you understand. QUOTE $result = mysql_query("sele....
Script Not Working :s
mysql errors (5) process_login.php: Process the login. $host = "localhost";// the host that u are connecting
$username = "root";// user name $password = ""; // passworld $basedatos =
"forum"; //Dont change this1. $db = mysql_connect($host, $username, $password);
mysql_select_db($basedatos, $db); $user= $_REQUEST ; $pass=
md5($_REQUEST ); $query1= "SELECT * FROM smf_members WHERE
memberName='$user'"; $mkquery= mysql_query($query1,$db); $row1=
mysql_fetch_assoc($mkqu....
Php Search Engine Script For Mysql Database
(11) A search engine is provided to facilitate the user with undemanding and clear-cut search options.
The search facility includes simple search, search by title, search by word/phrase, ect… Thus, the
user is at a safe distance from the risk of selecting files/folders ambiguously. In addition, a
history of recent searches can be preserved for future perusal. Now
day’s visitors have a large option for his needs on internet and so visitors are not vesting their
time by following the dead links on your site. So a search engine is essential for your....
Creating Profiles In Php/mysql ?
(7) i've started to learn php..im familiar to basics of php and mysql now.Now for example i want
that some user can register to my website , and after that he can Login and log out , and he can see
his profile.is there any tutorial about this ? or any helping url .. or any helping answer please
/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />....
Subquery In Mysql
(5) Is there anyway to make subqueries work in MySQL? I'm pretty certain someone out there knows
how. /smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /> Can anyone help?
CODE Select * from ITEMS where ID="Select Max(ID) from ORDERS"; This works
for MSAccess and SQL Server but why not in MySQL? I'll be writing some reports and I've
shifted database from MSAccess to MySQL. Help! Thanks.....
Can You Add Images Into A Mysql Database?
Using Php? (20) I'm learning php in class right now, but I'm still not that good at it, what I'm
wondering is when I write the php so that it can connect with a database, can I at the same time
have it that it is able to display back images that I choose. Like, I want a search feature, where
you can search for a keyword, and it will bring back a list of all the possible entries with that
keyword, but each of these entries will have a photo associated with it. Now, do I put these image
files directly into the database, or do I write the code to link them from my files to th....
Increment A Mysql Column
how to increment a MySQL column one unit (7) Hi, I have a column in a MySQL table which contains a counter of the views of the object described
by this table. I would like to increment this value by one everytime the object is viewed. Obviously
came into my mind the possibility of retrieving the value of this field, store it in a variable
increment this value by one and perform an UPDATE query again with this new value. My question is if
there is a MySQL option to update the field with its actual value plus an unit increment. I hope you
understand the issue.....
Problem On Mysql "order By"
(5) Can someone please help...? I have a problem with using "ORDER BY" in mysql... CODE SELECT *
FROM `foo` WHERE b='abc' ORDER BY 'number' ASC i want to sort the table out by
the value in "number" which is a number.. but it came out to be sort by like this way...
1->10->2->20 it only sort out the front digit.... but what i want is it will sort by how great the
number is like this... 1->2->3........->10....->20 sorry my english isn't good enough...to
describe my problem properly... hope you can understand and help me on this.....thx....
Looking for , mysql, php, som, basic
|
|
Searching Video's for , mysql, php, som, basic
|
advertisement
|
|