nav33n 472 Purple hazed! Team Colleague Featured Poster

Umm.. I am not sure about preg_replace. But you can do the same with str_replace!

<?php
$txt="' is a single quote \" is a double quote.I want to replace ' with \' and \" with \" ";
echo "Actual text: " .$txt."<br />";
$x=str_replace('"','\"',str_replace("'","\'",$txt));
echo "Replaced text: ". $x;
?>

Hope it helps!
Naveen

Venom Rush commented: Helpful as always ;) +1
nav33n 472 Purple hazed! Team Colleague Featured Poster

He's a 40 yr old monster. =s

:( Aww damn!

Sulley's Boo commented: told you, eww >_< +4
nav33n 472 Purple hazed! Team Colleague Featured Poster

$row here is the recordset returned by the query, $query="select user_id from grads"; In this case, we are putting the values of user_id in a dropdown list.
To learn the basics of php and mysql, I would suggest you to visit this site.
Php is very easy to learn. Once you learn it, I am sure you can make your own login script.

dani190 commented: Great Job with help +1
nav33n 472 Purple hazed! Team Colleague Featured Poster
<?php
	if(isset($_POST['submit'])) {
		for($i=0;$i<count($_FILES['fileupload']);$i++) {
			print $_FILES['fileupload']['name'][$i]."<br />";
		}
	}
	?>
<html>
<body>
<form name="upload" method="post" action="upload.php" enctype="multipart/form-data">
<table>
<tr><td>
<input type="file" name="fileupload[]">
</td></tr>
<tr><td>
<input type="file" name="fileupload[]">
</td></tr>
<tr><td>
<input type="file" name="fileupload[]">
</td></tr>
<tr><td>
<input type="file" name="fileupload[]">
</td></tr>
<tr><td>
<input type="submit" name="submit">
</td></tr>
</table>
</form>
</body>
</html>

This works for me! :)

OmniX commented: Gave me a working example +1
nav33n 472 Purple hazed! Team Colleague Featured Poster

I presume that you don't have much knowledge on php. You can go to w3schools and start learning the basics. But anyway, here is the script that you want. Make sure you enter the username and password correctly for your mysql connection,give the correct database name and specify the correct columns in the query.

<?php
$conn=mysql_connect("localhost","username","password"); 
mysql_select_db("student");
$query="select user_id,student_name from student";
$result=mysql_query($query);
$option="";
while($row=mysql_fetch_array($result)){
   $option.="<option value=".$row['user_id'].">".$row['student_name']."</option>";    
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Etobicoke Collegiate Institute's Grad Survey 2008</title>
</head>
<body>
<form action="handle.php" method="post">
<fieldset><legend>Please complete the following questions. Thanks!</legend>

<label>1. Be on the price is right</label><br />
<select name="priceisright">
  <option value="">Please Choose One Person</option>
  <option value="">Not Voting</option>
	<?php echo $option; ?>
</select>
<br />


</body>
</html>

Edit: If you encounter any errors, let me know.

Cheers,
Naveen

Sulley's Boo commented: jug jug jiyo =D +4
nav33n 472 Purple hazed! Team Colleague Featured Poster

I wouldn't say cure for aids can never be found. You never know how the technology can change and improve. A new cure may be developed to nullify the effect of those viruses(aids), immune the body and do a lot of other things. I am not saying this will happen today/tomorrow/after a week, but it will happen some day. Yes, I am (over)optimistic.

jaepi commented: it's nice to see someone who is over optimistic...but it could kill...hehehe +2
nav33n 472 Purple hazed! Team Colleague Featured Poster

select orderid from bOrders where userid IN (select userid from email = 'John@abc.com'); Thats wrong. You are missing where clause.. :) select orderid from bOrders where userid IN (select userid from bUsers where email = 'John@abc.com'); Cheers,
Nav

Sulley's Boo commented: shabbaaaaash :D +4
nav33n 472 Purple hazed! Team Colleague Featured Poster

:) you are welcome!

tirivamwe commented: Dont give up, keep the spirit of helping. Sometimes i wish if i was like you +3
nav33n 472 Purple hazed! Team Colleague Featured Poster

Simple. By using fgetcsv.

iamthwee commented: I approve! +13
nav33n 472 Purple hazed! Team Colleague Featured Poster

Ok. I see the error. Its your select_db string. mysql_select_db("kishou_website", $connect);/ Its after your query. Put it above the query. :) This should fix it.

kishou commented: just keeps on helping! +1
nav33n 472 Purple hazed! Team Colleague Featured Poster
<?php
if($AuthUserName == "administrator")
{

You have forgotten to close this loop. And please, next time wrap your code in

..

tags.

FireNet commented: wow.. you went and read all the jumbled code ;) +5
nav33n 472 Purple hazed! Team Colleague Featured Poster

yeah.. you can do that as well..

<?php
if(isset($_POST['submit'])){
$conn=mysql_connect("localhost","root","password");
mysql_select_db("test");
	$name = $_POST['name'];
	$age = $_POST['age'];
	$query="insert into table (name,age) values ('$name','$age')";
$result = mysql_query($query);
}
?>
<html>
<body>
<form name="test" method="post" action="samepage.php">
Name: <INPUT TYPE="text" NAME="name" value="<?php echo $name ?>"><br />
Age: <input type="text" name="age" value="<?php echo $age ?>"><br />
<INPUT TYPE="submit" name="submit" value="submit">
</form>
</body>
</html>

:) yep.. thats all.

Nick Evan commented: Good job, keep up the good work! +3
nav33n 472 Purple hazed! Team Colleague Featured Poster

why would it update when you are not changing anything ? You should have a form to make the changes. Here, you are just fetching the record from the table, putting it in a textbox, then giving a link with the same value. Try this instead.

<?php  //page1.php
$link=mysql_connect($hostname, $username, $password);
mysql_select_db($dbid) or die("unable to connect");
$x = $_GET['name'];
$result=mysql_query("SELECT * FROM table1 where name='$x'") or die("ERROR:".mysql_error());
$row=mysql_fetch_array($result,MYSQL_ASSOC); //since it returns only 1 row.
print '<form method="POST" action="page2.php">';
print '<input type="hidden" name="oldname" value="'.$x.'">';
print 'Name<input type="text" maxlength="19" size="53" name="name" value="'.$row['name'].'" />';
print '<input type="submit" name="submit" value="Update">';
mysql_close($link);
?>

<?php //page2.php
$link=mysql_connect($hostname, $username, $password);
mysql_select_db($dbid) or die("unable to connect");
$old_name=$_POST['oldname'];
$new_name=$_POST['name'];
mysql_query("UPDATE table1 SET name='$new_name' where name='$old_name'") or die("ERROR:".mysql_error());
echo "thanks";
mysql_close($link);
?>