mark103
Members-
Posts
268 -
Joined
-
Last visited
Everything posted by mark103
-
Cannot write or update data in the database, plz help!
mark103 replied to mark103's topic in PHP Coding Help
Im sorry, but I don't really get it. Could you please post the code, so for future use I would know what you would mean if you post the code? -
Cannot write or update data in the database, plz help!
mark103 replied to mark103's topic in PHP Coding Help
Thanks once again rwwd. However I have got another error Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/username/public_html/mysite.com/testupdate.php on line 64 Error: if (!mysql_query($sql,$con)) what's wrong? -
Cannot write or update data in the database, plz help!
mark103 replied to mark103's topic in PHP Coding Help
Thanks, I have changed and updated the script, but I got an parse error. Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/username/public_html/mysite.com/updatemysql.php on line 62 The error are jumping on this line: ('".$_POST['firstname']."','"'$_POST['lastname']."')"; Think there could a mistake but not too sure. Do you have any idea why I got the error? -
Hi guys, I have a trouble of updating the data in the database by input the data at the end of the url. It have not been added in the table. Here it is updated: <?phpsession_start(); define('DB_HOST', 'localhost'); define('DB_USER', 'myusername'); define('DB_PASSWORD', 'mypassword'); define('DB_DATABASE', 'mydatabasename'); $errmsg_arr = array(); $errflag = false; $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } function clean($var){return mysql_real_escape_string(strip_tags($var)); } $login = clean($_GET['user']); $password = clean($_GET['pass']); $firstname = clean($_GET['firstname']); if($login == '') { $errmsg_arr[] = 'Login ID missing'; $errflag = true; } if($password == '') { $errmsg_arr[] = 'PASSWORD ID missing'; $errflag = true; } if($value == '') { $errmsg_arr[] = 'THE first name IS missing'; $errflag = true; } if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; echo implode('<br />',$errmsg_arr); } else { $qry="SELECT * FROM members WHERE login='$login' AND passwd='$password'"; $result=mysql_query($qry) or die('Error:<br />' . $qry . '<br />' . mysql_error());if(mysql_num_rows($result) > 0) { $row = mysql_fetch_row($result); echo $row[0]; }else {echo 'Username, Password or first name is not found.';close;$sql="INSERT INTO members (firstname, lastname)VALUES('$_POST[firstname]','$_POST[lastname]')";if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); }echo "first name have been updated";}?> It have only login in the database but did not doing any update when I have input the data at the end of the url to get the database update. Do you know why I can't update the data in the database by input the data in the url like this? http://www.mysite.com/updatemysql.php?user=test&pass=test&firstname=shitorwhateveriwanttoinputandgetitupdate Do you have any idea and maybe if I have miss something?
-
jcjones, thanks for your help. I have successfully login into the database by input the username and password in the address bar. Now I needs to write the data in the database table by input the value in the address bar which something would be like this: http://www.mysite.com/writemysql.php?user=test&pass=test&firstname=valuedata Here it is code I have created: <?php session_start(); define('DB_HOST', 'localhost'); define('DB_USER', 'myusername'); define('DB_PASSWORD', 'mypassword'); define('DB_DATABASE', 'mydatabasename'); $errmsg_arr = array(); $errflag = false; $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } function clean($var){ return mysql_real_escape_string(strip_tags($var)); } $login = clean($_GET['user']); $password = clean($_GET['pass']); $value = clean($_GET['value']); if($login == '') { $errmsg_arr[] = 'Login ID missing'; $errflag = true; } if($password == '') { $errmsg_arr[] = 'PASSWORD ID missing'; $errflag = true; } if($value == '') { $errmsg_arr[] = 'THE VALUE IS missing'; $errflag = true; } if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; echo implode('<br />',$errmsg_arr); } else { $qry="SELECT * FROM members WHERE login='$login' AND passwd='$password'"; $result=mysql_query($qry) or die('Error:<br />' . $qry . '<br />' . mysql_error()); if(mysql_num_rows($result) > 0) { $row = mysql_fetch_row($result); echo $row[0]; } else { echo 'Username, Password or value is not found.'; $sql="INSERT INTO members (firstname, lastname) VALUES ('$_POST[firstname]','$_POST[lastname]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; ?> However, I have received an error: Parse error: syntax error, unexpected $end in /home/myusername/public_html/mysite.com/writemysql.php on line 71 The error are jumping on this line: ?> Do you know what the problem is? Hopefully you can help me to get the value update in the database table name members and write the value in fields id firstname by the same row as for each user. Thanks!
-
Thanks for your help jcjones. I think we have found a solution right here. I have successfully login now. Last things I need before I will mark the thread as resolve, how do I write the data to store in the database table by using the same script in your last post? Thanks, Mark
-
do anyone know how to resolve this??????
-
Ok, I have removed this line: $errmsg_arr However, I have received the error which are jumping on this line: ?> The error is: Parse error: syntax error, unexpected $end in /home/myusername/public_html/mysite.com/config.php on line 53 What's the hell is going on? any idea how to resolve?
-
Okay, so do you want me to remove this? if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; session_write_close(); $errmsg_arr
-
Here it is: <?php define('DB_HOST', 'localhost'); define('DB_USER', 'myusername'); define('DB_PASSWORD', 'mypassword'); define('DB_DATABASE', 'mydatabasename'); exit(); session_start(); $errmsg_arr = array(); $errflag = false; $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } function clean(){ $_GET = array_map('mysql_real_escape_string', $_GET); $_GET = array_map('strip_tags', $_GET); return $_GET; } $str = strip_tags($str); return mysql_real_escape_string($str); $login = clean($_GET['login']); $password = clean($_GET['password']); if($login == '') { $errmsg_arr[] = 'Login ID missing'; $errflag = true; } if($password == '') { $errmsg_arr[] = 'PS ID missing'; $errflag = true; } if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; session_write_close(); $errmsg_arr $qry="SELECT members FROM members WHERE login='$login' AND passwd='$password'"; if($result) { $result=mysql_query($qry); echo $result; exit(); }else { die("Query failed"); } ?>
-
Thanks herghost, there is another error has been throw out on this line: $qry="SELECT members FROM members WHERE login='$login' AND passwd='$password'"; Parse error: syntax error, unexpected T_VARIABLE in /home/username/public_html/mysite.com/config.php on line 47 Do you know why I have received the error?
-
can someone tell me if I should remove it or not??????
-
Thanks for your advice rwwd, I have moved the exit call after the header call. However, I have receive another parse error which I am getting this: Parse error: syntax error, unexpected '}' in /home/username/public_html/mysite.com/config.php on line 45 } Should I remove it?
-
Thanks guys, so the exit call I referring to are none. Should I remove them?
-
Hey guys, I am using this script to connect to mysql database. Here it is the code: <?php define('DB_HOST', 'localhost'); define('DB_USER', 'myusername'); define('DB_PASSWORD', 'mypassword'); define('DB_DATABASE', 'mydatabase'); session_start(); $errmsg_arr = array(); $errflag = false; $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } function clean($str) { $str = @trim($str); if(get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } $login = clean($_GET['login']); $password = clean($_GET['password']); if($login == '') { $errmsg_arr[] = 'Login ID missing'; $errflag = true; } if($password == '') { $errmsg_arr[] = 'PS ID missing'; $errflag = true; } if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; session_write_close(); echo "ERROR"; exit(); } $qry="SELECT level FROM users WHERE login='$login' AND passwd='$password'"; if($result) { $result=mysql_query($qry); echo $result; exit(); }else { die("Query failed"); } ?> However, I have received an error which I catch from this line: echo "ERROR"; I have input the correct username, password and the name of the database. Do you have any idea why I have received an error, guess if I have missing something?
-
Parse error: syntax error, unexpected ';', expecting T_CATCH
mark103 replied to mark103's topic in PHP Coding Help
rwwd, I am sorry but I don't know what I have to do with the link you sent. So why cant you post the code which it would be much easier for me to fix my own problem? -
Hi guys, I have a problem with the script. There is a parse error in line 7 which it end of the line. I need your help to make them get correct, as I am not a programmer and know very little PHP. Here it is the code: <?php try { include_once('HideUrlConfig.php'); } ?> Parse error: syntax error, unexpected $end, expecting T_CATCH in /home/username/public_html/mysite.com/myscript.php on line 6 What do I needs to change it with?
-
Can I use both methods to post and get data from php scripts?
-
Hmmmm, but I have got question: will the script post the data and receive them while I uses both methods?? And could you please post the try\catch errors for both scripts?? Thanks alot.
-
Yeah, so is the script are correct? <?php $url = curl_init("yoururl"); curl_exec($url); curl_close($url); } <?php try { include_once('myscript.php'); } Please let me know!
-
I am not going to use mysql_connect.php, only fileyouwant.php. I want to use it on my own site and another site, and it will returns the information if I connect the script on my another host before connect to the mysql database. I guess that it should be possible similar as the previous post I have already posted.
-
What more do you want to know and what got to do with you? I want to hide the url same as mysql config, which it would be like this: <?php $mysql = array ( 'host' => 'localhost', 'user' => 'mysql_user', 'pass' => 'password', 'db' => 'database_name' ); if(!isset($mysqlconn) || !is_resource($mysqlconn)) { $mysqlconn = mysql_connect($mysql['host'], $mysql['user'], $mysql['pass']); if(!$mysqlconn) { throw new Exception ('Unable to connect to MySQL host.'); } if(!mysql_select_db($mysql['db'])) { throw new Exception ('Unable to select database.'); } } <?php try { include_once('mysql_connect.php'); } catch(Exception $e) { // There was an error connecting to the database. Now, just show an error; however, // You probably want to die() or exit() after echoing the error. echo '<p>' . $e->getMessage() . '</p>'; } The database details will be store in the mysql_connect.php, so no one can see it until they catch my details to get access to my server with the host name, username and password. You see the db details in the mysql_connect.php, I want it to hide for url instead of mysql. Hope you get this now?
-
It isn't, it will be in the myscript.php so no body can see the url, only myscript.php, just like this: <?php try { include_once('myscript.php'); } The url will be hidden in that file. Why do you want to know for and what it is important to know?
-
Is it for hidden the url as similar for mysql??
-
are you being a fool? I want to keep the url address that I wish to connect to to be hidden so I could connect it to the mysql database which the db details will be inside that script. Now understand?