[Solved] Getting a Row in PHP [closed]

Remember, that mysql_query returns query resource handler, not result. You must call mysql_fetch_assoc($queryResource) to get the results. In your example: //-select the database to use $mydb=mysql_select_db(“TABLE”); //-query the database table $sql=”select * from Contacts where `Email`= ‘$email_user'”; //-run the query against the mysql query function $queryResource=mysql_query($sql); $result = mysql_fetch_assoc($queryResource); if ($result){ echo “Hello your ID … Read more

[Solved] if statement with $_GET[‘part’]

Wouldn’t this be easier? <?php switch ($_GET[‘part’])) { case ‘1’: ## part 1 ## Some content break; case ‘2’: ## part 2 ## Some content break; case ‘3’: ## Part 3 ## Some content break; default: header(‘Location: index.php?part=1′); } ?> 2 solved if statement with $_GET[‘part’]

[Solved] How to convert PHP arrays?

You just want to loop over the array and build your newly formatted array. <?php $arr = [ ‘please’ => [ ‘text’ => ‘it’ ], ‘use’ => [ ‘text’ => ‘will’ ], ‘google’ => [ ‘text’ => ‘help’ ] ]; $formattedArr = []; foreach ($arr as $k => $v) { $formattedArr[$k] = $v[‘text’]; } 0 … Read more

[Solved] PHP MySQL: managing and manipulating contents [closed]

you can try this code Password Updater <?php $dbhost=”localhost”; $dbuser=”root”; $dbpass=””; $tablename=”users”; //connect the server & select database mysql_connect($dbhost, $dbuser, $dbpass)or die(“cannor connect”); mysql_select_db(‘fb’)or die(“cannort select DB”); //Get values from FORM $mail=$_POST[’email’]; $oldpswd=$_POST[‘old_password’]; $newpswd=$_POST[‘new_password’]; $conpswd=$_POST[‘confirm_password’]; $query = mysql_query(“select * from users where email=”$mail””); while($row = mysql_fetch_array($query)) { if($row[‘pass’] == $oldpswd) { mysql_query(“update users set pass=”$newpswd” … Read more

[Solved] How to inject javascript code that uses php variables into php page

Assign PHP variable’s value to java script variable : <script type=”text/javascript”> var json{ “id”:<?php echo $id;?>, “user” : “<?php echo $user;?>” }; </script> Change this line from your code : $.post(‘full.php’, {msgg: msg, from: json.id, to: json.user} Now you’ll have separate js file like: function send(e){ if(e.keyCode == 13 && !e.shiftKey){ $(document).ready(function(){ //Get the input … Read more

[Solved] Get url as www.abcd.com?curr=USD

<form action=’www.abcd.com/aboutus.php’ method=’get’> <select name=”curr” id=’test’> <option value=”USD”>USD</option> <option value=”Euro”>Euro</option> </select> <input type=”submit” value=”submit”> </form> on your pages simply put <? $curr = $_GET[‘curr’]; ?> now on every link include abcd.com?curr=<? echo $curr ?> 9 solved Get url as www.abcd.com?curr=USD

[Solved] Split PHP Variable in to array?

A regex solution: <?php $str = “ckb=199&ckb=232&ckb=200&ckb=233&ckb=201&ckb=234”; preg_match_all(“/=([^&]+|.*$)/”, $str, $matches); print_r($matches[1]); ?> Output: Array ( [0] => 199 [1] => 232 [2] => 200 [3] => 233 [4] => 201 [5] => 234 ) solved Split PHP Variable in to array?

[Solved] convert the string to an array

Here is one way of doing it $str=”2,100|7,104|15,1110″; $arr1 = explode(“|”,$str); if(sizeof($arr1) > 0 ){ $final_array = array() ; foreach($arr1 as $data){ $arr2 = explode(“,”,$data); $final_array[$arr2[0]] = $arr2[1]; } } print_r($final_array); solved convert the string to an array

[Solved] .htacces – how to use [closed]

Basically, and simple if you were to rewrite www.site.com/news.php?id=123 to www.site.com/this_is_news_title You should create a file called .htaccess and put it inside your htdocs folder and write in it the following Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / RewriteRule ^news/([0-9]+)/.*$ /news.php?id=$1 [QSA,L,NC] Try it and play around with it. solved .htacces … Read more