Jump to content

mndasari

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

mndasari's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Code is here ... File: new_form.html <html> <body> <form method="post" action="new_scr.php"> Enter user id: <input type=text name=user_id> <input type=submit value="Submit"> </form> </body> </html> File: new_scr.php <?php $username="xxx"; $password="yyy"; $database="zzz"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $user_id = $_POST['user_id']; $qry = "SELECT * FROM user_tbl where user_id = '" . $user_id . "'"; $result = mysql_query( $qry ) or die(mysql_error()); $row = mysql_fetch_array($result); $user_name = $row['last_name'] . ", " . $row['first_name']; echo "User name: " . $user_name; echo "Script ended."; ?> Here, new_scr.php is printing user name correctly. Later I added line in red color to php file, I reloaded the form in the same browser window (same session) and hit submit button but new echo statement is not printed- somehow its executing the original .php file again (new changes are not effective). I tried clearing browser cache but didnot work. Any suggestions would greatly help!
  2. Hi, I am new to php & have a question about form's action func. My html file contains a form, having method="post" and action="filename.php". This filename.php is in the same dir as of html. I show html page in browser, hit submit button, it executes php script and shows output. But the problem is, now, if I modify php file e.g. add an echo statement, new changes donot get executed at all, same old output is still shown in the browser. Instead, if I run this php script at command line, it works fine. Could you please help! Thanks.
  3. Hi, Problem is not with the query itself. If I run the query in mysql directly it does work! Problem is, evenif I remove all mysql stuff from .php file, leaving only plain php stuff, somehow its still executing the old .php file (having errors!), not sure how? Do I need to clear cache somewhere? in browser? mysql? or in php itself? Thanks.
  4. Error is ... Unknown column 'jimmy' in 'field list' I guess, its picking up the last executed .php file from somewhere (from cache?), so even if I am changing .php file, its not executing new changes. Please help!
  5. Thanks a lot for the reply! The error still displayed on webpage is: Unknown column 'jimmy' in 'field list' jimmy is user_id. This is due to my earlier (wrong) query ... $qry = "SELECT " . $user_id . " FROM user_tbl"; This is obviously wrong and I corrected it as follows ... function get_user_name_from_db($user_id) { $qry = "SELECT * FROM user_tbl where user_id = '". $user_id . "'"; $result = mysql_query( $qry ) or die(mysql_error()); $row = mysql_fetch_array($result); $user_name = $row['last_name'] . ", " . $row['first_name']; return $user_name; } This func get_user_name_from_db() is called from new_scr.php, which is action function for a form. File: new_scr.php is as below ... <?php // Collect inputs ... $user_id = $_POST['f_user_id']; $release_stream = $_POST['f_release_stream']; : : $cust_prio = $_POST['f_cust_prio']; $username="xxx"; $password="yyy"; $database="zzz"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); echo "Content-type: text/html"; echo ""; echo ""; echo ""; echo "<html>"; echo "<head>"; echo "<title>"; echo "</title>"; echo "</head>"; echo "<body>"; echo "<center>"; $user_name = get_user_name_from_db( $user_id ); : : I corrected query, lateron removed mysql stuff altogether from .php, just collecting inputs from form and displaying using php, but still it gives old (same) error. I tried to clear browser cache, restarted browser etc didnot help, may be its got to do with caching of mysql last qry result/error, not sure though! Could you please help! Thanks!
  6. Hi, I am new to PHP and Mysql. Wrote a small php program which queries mysql db on local server based on inputs and displays results. Initially there was some error in the query I wrote, so got an error (since I used die as below ... $result = mysql_query( $qry ) or die(mysql_error()); But now that I corrected query, removed query altogether from php code, but still its showing the same last error message on the resulting webpage. I tried to clear browser cache, called flush status in mysql etc etc but no change. When I run the php program, webpage is still showing the old (last) query error. Could anybody help me please, as to, what could be done! Thanks in advance for the help!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.