-
Posts
169 -
Joined
-
Last visited
Everything posted by aliento
-
when you recieve the data and when you send them
-
or or $myPageVar = (int) $myPageVar{0}. $myPageVar{1};
-
or $myPageVar = (int) $myPageVar;
-
if ($myPageVar == 17) { //returns false }
-
When i have weed i program fast , intelligently i am full of new ideas n technics to solve problems. I have no problem to add extra abilities to my apps and i do it fast. If there is no i have loss of creativity. If i have to finish my work i will but without interest on what i code. I will just write down to finish. Fuck, i have no problem with other drugs but with weed i am a better men
-
Hello, In this case i debug by echo $password, after any line i use $password and i see where changes to fix it.
-
How to check duplicate entry in registration form?
aliento replied to namasteji1's topic in PHP Coding Help
nice. thank you ! -
How to check duplicate entry in registration form?
aliento replied to namasteji1's topic in PHP Coding Help
When the index into an array is number can be used as $something[1] if it is string $something['other']. The $something[other] just now i show it and i disagree, i think is a bug. The (string) is different than (int) and somehow i should know the type when i program. About the string this is ok : $string = "bla bla bla $dolphin"; or "bla bla bla $dolphin['first']" But when i should put the string into a function do_something("bla bla bla $dolphin['first']") is false and will return error but do_something("bla bla bla ".$dolphin['first'].") is ok. -
How to check duplicate entry in registration form?
aliento replied to namasteji1's topic in PHP Coding Help
further more see a $string = 'bla bla bla : $array['whatever'] '; Then it will stop the string at the [' because is the end of the string ! -
How to check duplicate entry in registration form?
aliento replied to namasteji1's topic in PHP Coding Help
-
How to check duplicate entry in registration form?
aliento replied to namasteji1's topic in PHP Coding Help
if it was a single variable its as you say because is an array element should be separated from the query -
How to check duplicate entry in registration form?
aliento replied to namasteji1's topic in PHP Coding Help
<?php session_start();session_destroy(); session_start(); if($_POST["regname"] && $_POST["regemail"] && $_POST["regmobile"] && $_POST["regpass1"] && $_POST["regpass2"] ) { if($_POST["regpass1"]==$_POST["regpass2"]) { $servername="localhost"; $username="root"; $conn= mysql_connect($servername,$username)or die(mysql_error()); mysql_select_db("test",$conn); $sql = "SELECT `id` from users where `email`= ".$_POST['regemail']."' LIMIT 1"; $result=mysql_query($sql,$conn) or die(mysql_error()); $mail_rows = mysql_num_rows($result); $sql = "SELECT `id` from users where `regname`= '".$_POST['regname']."' LIMIT 1"; $result=mysql_query($sql,$conn) or die(mysql_error()); $name_rows = mysql_num_rows($result); if($mail_rows==0&&$name_rows==0) { $sql="insert into users (name,email,mobile,password)values('$_POST[regname]','$_POST[regemail]','$_POST[regmobile]','$_POST[regpass1]')"; $result=mysql_query($sql,$conn) or die(mysql_error()); print "<h1>you have registered sucessfully</h1>"; print "<a href='index.php'>go to login page</a>"; } else echo "duplicated data"; } else print "Passwords doesn't match"; } else print"Invalid input data"; ?> -
Retrieve field with highest value from a MySQL database using PHP
aliento replied to twebman84's topic in PHP Coding Help
query and SELECT all the data then with php make the calculations and print the max. this caqnt be done with a sqql qquery -
How to check duplicate entry in registration form?
aliento replied to namasteji1's topic in PHP Coding Help
<?php session_start();session_destroy(); session_start(); if($_POST["regname"] && $_POST["regemail"] && $_POST["regmobile"] && $_POST["regpass1"] && $_POST["regpass2"] ) { if($_POST["regpass1"]==$_POST["regpass2"]) { $servername="localhost"; $username="root"; $conn= mysql_connect($servername,$username)or die(mysql_error()); mysql_select_db("test",$conn); $sql = "SELECT `id` from users where `email`= '".$_POST[regemail]."' LIMIT 1"; $result=mysql_query($sql,$conn) or die(mysql_error()); $num_rows = mysql_num_rows($result); if($num_rows==0) { $sql="insert into users (name,email,mobile,password)values('$_POST[regname]','$_POST[regemail]','$_POST[regmobile]','$_POST[regpass1]')"; $result=mysql_query($sql,$conn) or die(mysql_error()); print "<h1>you have registered sucessfully</h1>"; print "<a href='index.php'>go to login page</a>"; } else echo "duplicated data"; } else print "Passwords doesn't match"; } else print"Invalid input data"; ?> -
Well done for your DBA class, hard programming. i dont understand and i hate classes.I think if If the code is well constructed classes are useless. Except if the program needs to make complicate calculations for more than one object. I posted the clear article and i am waiting for approval. Thank you for the advises.
-
Thank you for your answer. I have fixed the bugs and i will do a tutorial to explain the usage. I will post it to the correct area the full article. Thank you
-
... it has some problems. 1) when the query returns 1 row and is not other it will return $data['field'] and not $data['field'][1] 2) The fields int the sql query should be without space `field1`,`field2` 3) Maybe is not working and it needs debug. not for the logic but php syntax
-
Hi, i use a function to alert and retrieve data from mysql which i want to share. The db($sql) function when select returns db("SELECT * FROM `user`") -> $data[field][row] db("SELECT `id`,`name` FROM `users` WHERE `id`=1") -> $data['id'] , $data['name'] db("SELECT `name` FROM `users` WHERE `id`=1 LIMIT 1") -> $data It executes the insert update and delete. All in one function. Further more for more easy data administration i have made those functions : db_insert($table,$fields,$values); // fields (array), $values (array) db_delete($table,$field,$is) //Where $field = $is db_select($table,$fields="*",$where='',$order='') db_check_row($table,$field,$is) // check if row excist The code is here the db.php file: * i have not done any debuging. $config['host'] = 'localhost'; $config['user'] = ''; $config['pass'] = ''; $config['db'] = ''; if($debug==true) echo $sql; $db_ff = mysql_connect($config['host'],$config['user'],$config['pass']); $select_db = mysql_select_db($config['db']) or die(mysql_error()); mysql_query("SET NAMES 'utf8'"); function db ($sql,$debug=false) { if(!strisrt($sql,'SELECT')) $result = mysql_query($sql) or die(mysql_error().$sql); else { $temp = explode(" ",$sql); $fields = $temp['1']; $fields = str_replace('`','',$fields); $table = $temp['3']; $table = str_replace('`','',$table); if($fields == '*') { $fields_con = mysql_list_fields($config['db'],$table); for($i=0;$i<mysql_num_fields($fields_con);$i++) {$fields_name[$i]=mysql_field_name($fields_con,$i); } mysql_close; } else { $fields = str_replace(' ','',$fields); if(strpos($fields,',')==true) $fields_name = explode (',',$fields); else $fields_name = $fields; } } $result = mysql_query($sql) or die(mysql_error().$sql); $rows_num = mysql_num_rows($result); $vi=1; if($rows_num>1) while ($row = mysql_fetch_array($result)) { if(!is_array($fields_name)) $db[$fields_name][$vi] = $row[$fields_name]; else for($fi=0;$fi<count($fields_name);$fi++) { $current_field=$fields_name[$fi]; $db[$current_field][$vi]=$row[$current_field]; } $vi = $fi + 1; } if(rows_num==1) if(!is_array($fields_name) while ($row = mysql_fetch_array($result)) { $db=$row[$current_field]; } if(is_array($fields_name)) for($fi=0;$fi<count($fields_name);$fi++) { $current_field=$fields_name[$fi]; $db[$current_field]=$row[$current_field]; } } return $db; } } function db_insert($table,$fields,$values) { if(is_array($fields)) { $count = count($fields)-1; for($i=0;$i<=$count;$i++) { $field = $fields[$i]; $value = $values[$i]; $fields_query = $field; if(is_num($field)) $values_query .= $value; else $values_query .="'".$value."'"; if($count!=$i) {$fields_query .=',';$values_query .=',';} } } else { $field_query=$field; $value_query=$values; } $sql = "INSERT into $table ($fields_query) VALUES ($values_query)"; db($sql); } function db_update($table,$fields,$values,$where = '') { if(is_array($fields)) { $count = count($fields)-1; for($i=0;$i<=$count;$i++) { $field = $fields[$i]; $value = $values[$i]; $fields_query = $field; $part_query = $field; if(is_num($field)) $part_query .= ' = '.$value; else $part_query .=" ='".$field."'"; if($count!=$i) $part_query .=' ,'; } } else { $part_query=$field; if(is_num($field)) $part_query .= ' = '.$value; else $part_query .=" ='".$field."'"; } $sql = "UPDATE $table SET $part_query $where"; db($sql); } function db_delete($table,$field,$is) { $sql = "DELETE FROM $table where $field = '$is'"; db($sql); } function db_select($table,$fields="*",$where='',$order='') { $fields_query = $fields; if(is_array($fields)) { $count = count($fields)-1; for($i=0;$i<=$count;$i++) ($fields_query .= $fields[$i]; if($count!=$i) $fields_query .=',';} } $sql = "SELECT $fields from $table $where $order"; return db($sql); } function db_check_row($table,$field,$is) { db(); $sql = "SELECT $field FROM $table where $field = '$is' limit 1"; $result = mysql_query($sql) or die(mysql_error().$sql); $rows_num = mysql_num_rows($result); if($rows_num==1) return True; else return False; }
-
Hello, i make i web site witharticles and comments . It will have a table comments with the article id. Should i count the comments by a sql query or i should i put an extra field at the articles table with total comments number? Thank you
-
As it seems it cannot be done. I think you can take the previous page with history javascript. Or you can use sessions to save and retrieve the URI. For those purposes i include the file and i am not redirecting the page.
-
Hello, I would like to know how to include a root file in a 4 deep folder using dots. Is it good : include "../../../config.php" or i can simple include "./config.php" ? How does this works? Is it better to write all the path? Thank you
-
WOW !!!! Many thanks!!!
-
Thanks for the count!
-
It works ! Thank you