Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

where my error

Featured Replies

i have error in $query ="insert .....

i don't know what it's

extract($_POST);
//connect to mysql 
if (!($dbc=mysql_connect("localhost","root","")))
die("could not connect to database ");
//select database
$db_selected = mysql_select_db("ehsan",$dbc);
if(!$db_selected)
{
die("cannt connect ");
}
$query= "INSERT INTO tutorial (code,titile,video) VALUES ('$code','$titile','$video')";
if (! mysql_query($query))
die (mysql_error());
mysql_close();
?>
***********************************************************************************
   <form id="form1" name="form1" method="post" action="">
 <p>
   <label for="textfield"></label>
   <input type="text" name="code" id="textfield" />
   code
 </p>
 <p>
   <label for="textfield2"></label>
   <input type="text" name="titile" id="textfield2" />
 title</p>
 <p>
   <label for="textfield3"></label>
   <input type="text" name="video" id="textfield3" />
 video</p>
 <p>
   <input type="submit" name="button" id="button" value="Submit" />
 </p>
</form>


You shouldn't really extract $_POST, its way to insecure. at least add EXTR_PREFIX_ALL:

 

extract($_POST, EXTR_PREFIX_ALL, 'something');

i have error in $query ="insert .....

i don't know what it's

extract($_POST);
//connect to mysql 
if (!($dbc=mysql_connect("localhost","root","")))
die("could not connect to database ");
//select database
$db_selected = mysql_select_db("ehsan",$dbc);
if(!$db_selected)
{
die("cannt connect ");
}
$query= "INSERT INTO tutorial (code,titile,video) VALUES ('$code','$titile','$video')";
if (! mysql_query($query))
die (mysql_error());
mysql_close();
?>
***********************************************************************************
   <form id="form1" name="form1" method="post" action="">
 <p>
   <label for="textfield"></label>
   <input type="text" name="code" id="textfield" />
   code
 </p>
 <p>
   <label for="textfield2"></label>
   <input type="text" name="titile" id="textfield2" />
 title</p>
 <p>
   <label for="textfield3"></label>
   <input type="text" name="video" id="textfield3" />
 video</p>
 <p>
   <input type="submit" name="button" id="button" value="Submit" />
 </p>
</form>


I think it's because you're trying to insert values you haven't yet posted..

 

<html>
   <body>
   <form id="form1" name="form1" method="post" action="">
 <p>
   <label for="textfield"></label>
   <input type="text" name="code" id="textfield" />
   code
 </p>
 <p>
   <label for="textfield2"></label>
   <input type="text" name="titile" id="textfield2" />
 title</p>
 <p>
   <label for="textfield3"></label>
   <input type="text" name="video" id="textfield3" />
 video</p>
 <p>
   <input type="submit" name="submit" id="button" value="Submit" />
 </p>
</form>
   </body>
</html>

<?php
if($_POST){
extract($_POST);
//connect to mysql 
if (!$dbc=mysql_connect("localhost","root",""))
{
die("could not connect to database ");
}
//select database
$db_selected = mysql_select_db("test",$dbc);
if(!$db_selected)
{
       die("cannt connect ");
       }
       $query= "INSERT INTO tutorial (code,titile,video) VALUES ('$code','$titile','$video')";
       if (! mysql_query($query))
       die (mysql_error());
       mysql_close();
	}

       ?>

First display the form.

Then check if values have been posted.

If they have, extract the values and insert into database. if they haven't just display the form.

 

But as someone said, I wouldn't personally use extract().

Samus,

You are right, it is because the values haven't been posted yet, but the solution of putting the form first won't work because they still haven't been posted.

 

ehsan

Just set your variables before you try to use them and your original script will work i recon...

 

$code = 0;

$title = 0;

$video = 0;

 

something like that.

but the solution of putting the form first won't work because they still haven't been posted.

How would you post them without the form then?

  • Author

Samus,

You are right, it is because the values haven't been posted yet, but the solution of putting the form first won't work because they still haven't been posted.

 

ehsan

Just set your variables before you try to use them and your original script will work i recon...

 

$code = 0;

$title = 0;

$video = 0;

 

something like that.

MR SAMUS CODE ID RIGTH

THANK U MR dddougal To participate

Edited by ehsan_cs

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.