Jump to content

loudog

Members
  • Posts

    33
  • Joined

  • Last visited

    Never

Everything posted by loudog

  1. I need some php experience....wondering if I can teach myself and what's the proper or best way to learn this or should i pony up some dough for a class?
  2. why d0o i get this "Notice: Undefined index: id in C:\wamp\www\GuestBook\delete_ac.php on line 8" (page1) title delete.php <?php mysql_connect("localhost", "root", "") or die ("connot conect to server"); mysql_select_db("test_take_two") or die ("connot select db"); $sql="SELECT * FROM test_mysql"; $result= mysql_query($sql); ?> <table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td><table width="400%" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td bgcolor="#FFFFFF"> </td> <td colspan="4" bgcolor="#FFFFFF"><strong>Delete data in mysql</strong></td> </tr> <tr> <td align ="center" bgcolor="#FFFFFF"><strong>Id</strong></td> <td align ="center" bgcolor="#FFFFFF"><strong>Name</strong></td> <td align ="center" bgcolor="#FFFFFF"><strong>Lastname</strong></td> <td align ="center" bgcolor="#FFFFFF"><strong>Email</strong></td> <td slign="center" bgcolor="#FFFFFF"> </td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td bgcolor="#FFFFFF"><?php echo $rows['id']; ?></td> <td bgcolor="#FFFFFF"><?php echo $rows['name']; ?></td> <td bgcolor="#FFFFFF"><?php echo $rows['lastname'];?></td> <td bgcolor="#FFFFFF"><?php echo $rows['email']; ?></td> <td bgcolor="#FFFFFF"><a href="delete_ac.php?id=<?php echo $rows['id']; ?>">delete</a> </td> </tr> <?php } mysql_close(); ?> </table></td> </tr> </table> (page2) title delete_ac.php <?php mysql_connect("localhost", "root", "") or die ("connot conect to server"); mysql_select_db("test_take_two") or die("connot select to database"); //get value of id that sent from address bar [i][b]this is line 8->[/b][/i] $id=$_GET['id']; //Delete data in myssql from row that has this id $sql = "DELETE FROM test_mysql WHERE id='$id'"; $result=mysql_query($sql); // If successfully deleted if($result){ echo "Deleted Successfully"; echo "<br>"; echo "<a href='delete.php'>Back to main page</a>"; } else{ echo "ERROR"; } // CLOSE CONNECTION mysql_close(); ?>
  3. loudog

    help plz

    thanks guys for all your help i found the mistake . I didn't put the single colons before, in between, and after the variables on the values and i forgot the space as well. //Insert data into mysql the error was on this line->$sql="INSERT INTO web_members(name,lastname,email)VALUES($name,$lastname,$email)"; the correct way was like this ->$sql="INSERT INTO web_members(name, lastname, email) VALUES ('$name','$lastname','$email')"; $result=mysql_query($sql);
  4. loudog

    help plz

    yes i have the database set up and the error i keep getting its the one thar i have made bold. ($result){ echo "Successful"; echo "<BR>"; echo "<a href='insert.php'>Back to main page</a>"; } else{ echo "ERROR";<- } //close connection mysql_close(); here is my data base config <?php $host=mysql_connect("localhost", "root", "")or die("cannot connect to server"); mysql_select_db("test_create_db")or die("connot select db"); ?>
  5. hey guys i've been copying alot of free php scripts in the web but this last one i keep getting the error message. it won't let me connect . here are the scripts. (page1) insert.php <html> <head> <title>Untitled Document</title> </head> <body> <form name="form1" action=" insert_ac.php" method="post"> <table width="300" border="0" align="center" cellpadding="0" cellspacing="1"> <tr> <td> <table width="100%" border="0 cellspacing="1" cellpadding="3"> <tr> <td colspan="3"><strong>Insert Data Into mySQL Database</strong></td> </tr> <tr> <td width="71">Name</td> <td width=""6>:</td> <td width="301"> <input name="name" type="text" id="name"> </td> </tr> <tr> <td>Lastname</td> <td>:</td> <td> <input name="lastname" type="text" id="lastname"></td> </tr> <tr> <td>Email</td> <td>:</td> <td><input name="email" type="text" id="email"></td> </tr> <tr> <td colspan="3" align="center"><input type ="submit" name="Submit" value="Submit"></td> </tr> </table> </form> </body> </html> (page2) insert_ac.php <?php //Connecting to server and selecting databaase. mysql_connect("localhost", "root", "")or die("cannot connect"); mysql_select_db("test_create_db") or die("cannot select DB"); //Get values from form. $name=$_POST['name']; $lastname=$_POST['lastname']; $email=$_POST['email']; //Insert data into mysql $sql="INSERT INTO web_members(name,lastname,email)VALUES($name,$lastname,$email)"; $result=mysql_query($sql); //if succesfully insert data into database,display message "Successful". if($result){ echo "Successful"; echo "<BR>"; echo "<a href='insert.php'>Back to main page</a>"; } else{ echo "ERROR"; } //close connection mysql_close(); ?>
  6. Hey im dan. im new to the php world and im looking foward to learning from all the best. so that one day i can be the other side and helping others have success and become better people.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.