Jump to content

Search the Community

Showing results for tags 'database'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. I have been doing PHP for a while and am able to do e-commerce and CMS with coding; however, I can't quite figure this issue out right now. I am currently working on a project that will allow people to text photos and information to a website and have the text saved into a database that can then show up on the webpage when someone views it. I know how to get the text information by using APIs but can not figure out how to save it into a MySQL Database! If you have any ideas I would appreciate the help.
  2. insertion of data in database using function in php
  3. I am making a website having a "skills" field which is a dropdown menu dropdown menu which fetch's data from database and assign the Id to the option tag dynamically 1) I dont know if the id is assigned or not below is my code:- <select name="sname[]" id="sname" size="1" multiple="multiple" title="hold ctrl and click multiple options" > <?php include 'conn.php'; $que=mysql_query("select * from field"); while($row=mysql_fetch_array($que)) { $id=$row['id']; $field=$row['field']; echo "<option id="$id">".$field."</option>"; } ?> </select> 2)how do I insert multiple values of the option tag into the database into the database?
  4. i wanted to upload a image in godaddy server with a php script. It worked on my computer, 3owl.com. but when ever i'm trying to upload in godaddy's server, i'm getting an error... The script is <?php include('_header.php'); ?> <------- Database connection is done here. <?php if(!isset($_SESSION['email'])) header("Location:index.php"); ?> <?php $pid=$_REQUEST['uid']; ?> <?php if(isset($_REQUEST['Submit'])){ //define a maxim size for the uploaded images in Kb define ("MAX_SIZE","10000000"); //This function reads the extension of the file. It is used to determine if the file is an image by checking the extension. function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } //This variable is used as a flag. The value is initialized with 0 (meaning no error found) and it will be changed to 1 if an errro occures. If the error occures the file will not be uploaded. $errors=0; //checks if the form has been submitted if(isset($_POST['Submit'])) { //reads the name of the file the user submitted for uploading $image=$_FILES['image']['name']; //if it is not empty if ($image) { //get the original name of the file from the clients machine $filename = stripslashes($_FILES['image']['name']); //get the extension of the file in a lower case format $extension = getExtension($filename); $extension = strtolower($extension); //if it is not a known extension, we will suppose it is an error and will not upload the file, otherwize we will do more tests if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { //print error message echo '<h1>Unknown extension!</h1>'; $errors=1; } else { //get the size of the image in bytes //$_FILES['image']['tmp_name'] is the temporary filename of the file in which the uploaded file was stored on the server $size=filesize($_FILES['image']['tmp_name']); //compare the size with the maxim size we defined and print error if bigger if ($size > MAX_SIZE*1024) { echo '<h1>You have exceeded the size limit!</h1>'; $errors=1; } //we will give an unique name, for example the time in unix time format $image_name=time().'.'.$extension; //the new name will be containing the full path where will be stored (images folder) $newname="upload/".$image_name; //we verify if the image has been uploaded, and print error instead $copied = copy($_FILES['image']['tmp_name'], $newname); <-------------- here i'm getting the error. $sql="INSERT INTO images (image_id,product_id,images_link) VALUES('', '$pid', '$newname')"; $result= mysql_query($sql); if (!$copied) { echo '<h1>Copy unsuccessfull!</h1>'; $errors=1; }}}} //If no errors registred, print the success message if(isset($_POST['Submit']) && !$errors) { echo "<strong><font size='4' color='#2497e0'>Image Added Successfully</font></strong>"; } } ?> <form name="newad" method="post" enctype="multipart/form-data" action=""> <table> <tr><td><input type="file" name="image"></td></tr> <tr><td><input name="Submit" type="submit" value="Upload image"></td></tr> </table> </form> And the error is Warning: copy(upload/1359049130.jpg) [function.copy]: failed to open stream: Permission denied in D:\Hosting\7528824\html\Admin\product1.php on line 82 Any help guyssss.... Thanks in advance...
  5. I have a website that runs on WordPress / PHP & MYSQL Database. I was hoping to build a search form that will access my database and grab result to display in a separate page. Any help would be greatly appreciated. Thank you!
  6. form not posting to database instead its redirecting me to another page with heading "object not found!" <?php $connect= mysql_connect("localhost", "username", "password"); if (!$connect) { die("could'nt connect to db:".mysql_error()); } mysql_select_db("myapp", $connect); $sql="INSERT INTO form(fname,lname,email,password,telephone,sex,dob) VALUES ('','$_POST[fname]', '$_POST[lname]', '$_POST[email]' '$_POST[password]', '$_POST[telephone]', '$_POST[sex]', '$_POST[dob]')"; if (!mysql_query($sql, $connect)) { die("Error:" .mysql_error()); } mysql_close($connect); function spamcheck($field) { $field = filter_var($field, FILTER_SANITIZE_EMAIL); if(filter_var ($field, FILTER_VALIDATE_EMAIL)) { return TRUE; } else { return FALSE; } } if (isset($_POST['email'])) { $mailcheck = spamcheck($_POST['email']); } if($mailcheck == FALSE) { //echo "invalid input"; } else { $email=$_POST['email']; $fname=$_POST['fname']; $lname=$_POST['lname']; $password=$_POST['password']; $retype_password=$password; $telephone=$_POST['telephone']; $sex=$_POST['sex']; $DOB=$_POST['dob']; } function yearOptions() { for ($i = 1910; $i <= date('Y'); $i++) { $s = date('Y') == $i ? ' selected="selected"' : ''; echo '<option '.$s.' value="'.$i.'">'.$i.'</option>'."\n"; } } function monthOptions() { $months = array( 1 => "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ); foreach ( $months as $monthNo => $month ) { ( $monthNo == date('n') ) ? $selected = ' selected="selected"' : $selected = ''; echo '<option value="'.$monthNo.'"'.$selected.'>'.$month.'</option>'."\n"; } } function dayOptions() { for ( $i = 1; $i <= 31; $i++ ) { ( $i == date('j') ) ? $selected = ' selected="selected"' : $selected = ''; echo '<option value="'.$i.'"'.$selected.'>'.$i.'</option>'."\n"; } } $password=$_POST["password"]; $salt=rand(100000,999999); $encrypted= (MD5(MD5($salt.$password))); if($retype_password!=$password) { echo "password mismatch"; } ?> <form action = "register.php" method=post> <fieldset> Firstname: <input type="text" size=30 name="fname"><br> Lastname: <input type="text" size=30 name="lname"><br> Email address: <input type=text size=30 name="email"><br> Password: <input type=password size=30 name="password"><br> Retype Password: <input type=password size=30 name="retype_password"><br> Telephone: <input type=tel size=30 name="telephone"><br> sex: <input type="radio" name="sex" value="male" checked="checked">Male<br/><input type="radio" name="sex" value="female">Female<br> Date of birth: <select name="dob"> <?php dayOptions();?> </select> <select name="dob"> <?php monthOptions();?> </select> <select name="dob"> <?php yearOptions();?> </select><br> <INPUT TYPE=SUBMIT VALUE="Register"> </fieldset> </form>
  7. I am trying to search the database but I failed... It only works if the whole set of charecters that is been searched matches with the database information... My code is follows... <form method="post" action=""> <table> <tr> <td>Enter the categories</td> <td><input type="text" name="search" /></td> </tr> <tr> <td></td> <td><input type="submit" name="submitbutton" value="Search"/></td> </tr> </table></form> <?php if(isset($_REQUEST['submitbutton'])){ $search= mysql_real_escape_string($_REQUEST['search']); $sql= "SELECT * FROM categories WHERE categories_name='$search'"; $result= mysql_query($sql); while ($row = mysql_fetch_array($result)) { if($search==$row['categories_name']){ echo "successfull"; }else{ echo "Not found"; } } } ?> I want to show the required item if any three charecters/letters matches with the database item name...... Thanks in advance...
  8. Hi All, I want to create a webpage that allows a user to import a csv file into a database. Can anyone help me start with this? Or at least refer me to a really good source that can help me get this working.
  9. i am trying to catch the id from the url sent in this way... http://localhost/Form/Admin/members_details.php?uid=14<---------------- This Id I have tried using $_REQUEST but its not workinh... I have done this... $uid=$_REQUEST['uid']; $sql="SELECT * FROM students WHERE student_id='$uid'"; $result= mysql_query($result); while($row=mysql_fetch_array($result)){ .......... ........... ........ There are few codes.... } But i'm getting error in while loop... Error is Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\Form\Admin\members_details.php on line 6 Any help would be grately appreciated...
  10. Hii I am trying to use the id of each student in the next page where it will be called to see their details... The code is shown below... <?php include('header.php'); ?> <div id="content"> <h1>Members</h1> <center><table width="550px"; class="table" cellspacing="10px" cellpadding="10px"> <tr> <td class="border">SL</td> <td class="border">Course Id</td> <td class="border">First Name</td> <td class="border">Last Name</td> <td class="border">Email</td> </tr> <?php $sl =1; $sql="SELECT student_id, course_id, student_fname, student_lname, student_email FROM student"; $result=mysql_query($sql); while($row=mysql_fetch_array($result)){ ?> <tr> <td class="border"><?php echo $sl; ?></td> <td class="border"><?php echo $row['course_id']; ?></td> <td class="border"><?php echo $row['student_fname']; ?></td> <td class="border"><?php echo $row['student_lname']; ?></td> <td class="border"><?php echo $row['student_email']; ?></td> <td class="border">[b][color=#ff0000]<a href="members_details.php?uid=<?php echo $row['student_id'];?>[/color][/b]">User Details</a></td> </tr> <?php $sl++; } ?> </table></center> </div> </div> </div> <?php include('footer.php'); ?> </body> </html> And the code where i want to show is <?php include('header.php'); ?> <?php [color=#ff0000][b]$uid=$_REQUEST['uid'];[/b][/color] $sql="SELECT * FROM student WHERE student_id='$uid'"; $result=mysql_query($result); while($row=mysql_fetch_array($result)){ ?> <div id="content"> <h1>Members</h1> <center><table width="550px"; class="table" cellspacing="10px" cellpadding="10px"> <tr> <td>First Name:</td> <td></td> </tr> <tr> <td>Last Name:</td> <td></td> </tr> <tr> <td>Email Id:</td> <td></td> </tr> <tr> <td>Phone No:</td> <td></td> </tr> <tr> <td>Gender</td> <td></td> </tr> <tr> <td>D.O.B</td> <td></td> </tr> <tr> <td>College:</td> <td></td> </tr> <tr> <td>State:</td> <td></td> </tr> <tr> <td>City:</td> <td></td> </tr> <tr> <td>Country:</td> <td></td> </tr> <tr> <td>Zip:</td> <td></td> </tr> </table></center> <?php } ?> </div> </div> </div> <?php include('footer.php'); ?> </body> </html> Where each blank <td></td> will be filled with their details queried from database... Plz help me out...
  11. Hiii i'm trying to create a login page but i want to add some featues i.e they can upload their profile photo. I know the upload form but i cant think how it will work... How the database will show coreect image for the correct user??? Will I have to store it in the database with users id?? But as far as i know We can store any multimedia in the database, only the links can be recorded in the database... Any help would be grately appreciated.. Thanks in advance...
  12. Hello the community, i have create a little script that connect to the mysql database & search for the email field <? $host = "localhost"; $user = "root"; $password = "password"; $db = "test"; $type = "MYSQL_BOTH"; $conn = mysql_connect($host, $user, $password); mysql_select_db($db) or die("cannot open DB $db"); $file = "http://localhost/tmp/log.txt"; $result = parse_table ( "user",$type,"file" ); mysql_close($conn); function parse_table($tablename,$mode,$file) { $email= "email@email.com"; $fo = fopen($file,"w++"); $sql = "SELECT email FROM user WHERE email = '".$email."'"; $req = mysql_query($sql)or die('Error SQL !<br>'.$sql.'<br>'.mysql_error()); $tbl_array = array(); while($data = mysql_fetch_array($req, $mode)) { foreach($data as $key => $value) { $tbl_array[$key][] = $value; fputs ($fo,$tbl_array[$key]); } } } ?> here is the sql dump /* CREATE TABLE IF NOT EXISTS user ( id int(10) unsigned NOT NULL AUTO_INCREMENT, email varchar(80) NOT NULL, pass char(41) NOT NULL, PRIMARY KEY (id) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; INSERT INTO user (id, email, pass) VALUES (1, 'email@email.com', '664c0750f8c73ec0086e88c8b02bb112''); */ the problem is i got an error the line 20 is while($data = mysql_fetch_array($req, $mode)) { im not sure where the problem come from could you help me to fix the script please ? thx you very much
  13. hello everyone actually i'm trying to delete data from the database that is been queried in the drop down menu.... The code is shown below... <?php require_once 'myconn.php'; $sql = "SELECT course_id, course_name FROM course"; $result = mysql_query($sql); echo "<form method='post' action=''>"; echo "<label>Delete Course</label>"; echo "<select>"; while($row = mysql_fetch_array($result)){ echo "<option value='{$row['course_id']}'>{$row['course_name']}</option>"; } echo "</select>"; echo "<input type='submit' name='submitbtn' value='Delete'>"; if(isset($_REQUEST['submitbtn'])){ $sql1= "DELETE course_name FROM course WHERE course_id='{$row['course_id']}'"; $reslut1= mysql_query($sql1); if(mysql_affected_rows()>0){ header("Location:".$_SERVER['php_SELF']); } } ?> When i press delete button the page get refresh but nothing gets deleted from the list... Can any one help me with it...
  14. Hello, i'm trying to make a "top 10 voters" page, the only thing is, i'm quite new with the use of php in combination with sql. I've searched online a lot after i've figured out how to get, and store the username in the database, and if it already existed it adds 1 to "votes". Now i want to use that data to create a top 10 voters page. The only problem, i can't really find a tutorial for making a top 10. Maybe someone here could help me out with it? I've started writing the code a bit, but i got stuck between the query and fetching the data and looping it. The error i get: The full code as it is now: <? /* MYSQL connectie */ $conn = new Mysqli("localhost", "username", "password", "tylerwx94_cwvote") or die ('Error: ' . mysqli_errno($conn)); /* mysql selectie */ $results = mysqli_query($conn, "SELECT `players` FROM `tylerwx94_cwvote` ORDER BY `votes` DESC LIMIT 10") or die('Error: ' . mysqli_errno($results)); while ($row = mysqli_fetch_assoc($results)) { echo $row['players'] . "\n"; } ?> Any help with my code or link to a good tutorial would be appreciated! Sorry if it is in the wrong section, don't know if it belongs in mysql or php.
  15. why i am getting the above error in this code <?php while($row=mysql_fetch_assoc($result)) { ?>
  16. I have a question... I am trying to figure out how I can search my database for the next available spot open, and if it is not available then the next available in another row. My example is this.... If I have name1, name 2, name3, name4, name5 and the data is joe, jon, tim, null, null Also, this is not always the same... I have many tables like this but some have name1, name 2 while some go up to name10. I need one statement to search any one of these.... How can I do a search that says select the open name in that row. If there are no open rows move to next row and check. I was thinking a loop but not sure how that would work. I appreciate the help! I hope this all makes sense!
  17. Hi Guys, Just want to run past an idea I am having, I want to make sure the logic is sound. Basically, I am making a website statistics feature for my Content Management System. I want to create a function that will work out the most visited pages on the website. I currently collect a multitude of data, which is stored in a table in my database. Each time a person loads a page the data is added to the table. Some of that data includes the page id. My plan is call this data from the database and add the data to an array. As the rows of the table are being looped through, the script would check to see if the pageid is already in the array, and increment the count, and if not add it to the array until it has collected all of the logs. The array would then be sorted and the top 10 pages would be shown in a graph on the website. Does that logic make sense? Is there a simpler way of doing it? Any input would be great. Thanks!
  18. Hi all, I'm experiencing a lot of trouble trying to create a script for my website. I'm making a database dependant menu, and I've spent a couple of days doing trial and error much to no prevail. I'm using Twitter Bootstrap if anyone is familiar with it, and creating a drop down menu. The code for each of these buttons is: <div class="btn-group"> <a class="btn btn-inverse dropdown-toggle" data-toggle="dropdown" href="#"> WOD <span class="caret"></span> </a> <ul class="dropdown-menu"> <!-- dropdown menu links --> <li><a tabindex="-1" href="http://www.google.com.au">View the WOD</a></li> <li><a tabindex="-1" href="#">WOD Archives</a></li> <li class="divider"></li> <li><a tabindex="-1" href="#">Benchmarks</a></li> </ul> </div> So, what I need to be able to do is call each menu that I have in the database, (I have 5), determine if it's a drop down, and if it is, echo the links for it inside of the <ul class="dropdown-menu"> It seems simple to me, but I cannot get it right. Please help! Cheers.
  19. Hi Guys, I'm an amateur coder working on a huge project probably way above my capabilities and thus continue to run into problems. So, I seek your help! In my developing system, I'm making a dynamic website so you can control the front-end from the back-end. To edit the front-end you have a page Manage Layout which allows you to edit the HTML of the home page. Then you just type in my custom elements like, [menu], etc. I'm using preg_replace to change these into the scripts I require. The HTML of the homepage is contained in a database, then when it's executed on the homepage I do the preg replace etc. What I'm doing for my [menu] is: Now, the problem occurs. It executes this 100%, the preg_replace carries it out perfectly, BUT instead of it executing where I've placed it in the overall position on the page, it puts everything on the first line after the <body> tag... The preg_replace simply replaces [menu] with createMenu(); so I would've thought that my function would be executed wherever I had [menu]??? I'm not entirely sure what I've said is clear but lets hope so. Cheers. ABOVE:The menu is being placed on the first line, rather than in the div where I have [menu] (which is consequently to the right of the CrossFit St Marys Logo)
  20. Hi, I'm working on a new site. And i can't get my code to work properly. I have already made a site with this script and it works just fine, but it will not work on my new site (wordpress with PHP enable). What I need is an alternative to this code (the delete button command): <td><a onclick="return confirmSubmit()" <a href="?slettID=<?php echo $row_persondata2['id']; ?>"><img src="images/Delete-button.bmp" name="Image3" width="45" height="20" border="0" id="Image3" /></a><a href="?slettID=<?php echo $row_persondata2['id']; ?>"></a> <script LANGUAGE="Javascript"> <!-- // Skript for Confirmasjon-delete function confirmSubmit() { var agree=confirm("Er du sikker på at du vil slette denne hendelsen?"); if (agree) return true ; else return false ; } // --> </script> <a href="update.php?oppdaterID=<?php echo $row_persondata2['id']; ?>"><img src="images/Update-button.bmp" width="45" height="20" border="0" /></a></td> </tr> <?php } while ($row_persondata2 = mysql_fetch_assoc($persondata2)); ?> </table> Take a look at my attachment. What i want is a delete button that is asking "are you sure?" and then if i click yes it delete that row from the database. Is there an easy alternative? Thanks!
  21. I have a 1 dimensional array from a database output that I need to have in a multidimensional array ($tasks): array 0 => array 'sr_id' => string '4902367' (length=7) 'description' => string 'GLS Jersey Mikes Installation Checklist' (length=39) 'due_date' => string '2012-01-07 23:24:00' (length=19) 'sr_fe_task_id' => string '220958' (length=6) 1 => array 'sr_id' => string '4902367' (length=7) 'description' => string 'Please submit your pictures of the installation area before any work was performed.' (length=83) 'due_date' => string '2012-01-07 23:24:00' (length=19) 'sr_fe_task_id' => string '220959' (length=6) 2 => array 'sr_id' => string '4902367' (length=7) 'description' => string 'Please submit your pictures of the installation area after all work was completed.' (length=82) 'due_date' => string '2012-01-07 23:24:00' (length=19) 'sr_fe_task_id' => string '220960' (length=6) 3 => array 'sr_id' => string '4903303' (length=7) 'description' => string 'Upload pictures of colored patch cables connected to back of router.' (length=116) 'due_date' => string '2012-01-07 23:31:00' (length=19) 'sr_fe_task_id' => string '220961' (length=6) 4 => array 'sr_id' => string '4899664' (length=7) 'description' => string 'Please upload all pictures taken on site.' (length=41) 'due_date' => string '2012-01-17 17:33:00' (length=19) 'sr_fe_task_id' => string '222839' (length=6) Each sr_id may have more than one task under it and each task has a due_date and description under it, but I'm having trouble getting the descriptions and due_dates under each task: ['sr_id'] =>4902367 ['sr_fe_task_id'] => 220958 ['description']=> "GLS Jersey Mikes Installation Checklist" ['due_date']=> '2011-12-08 17:50:00' ['sr_fe_task_id'] => 220959 ['description']=> "Pleease submit your pictures of the installation area." ['due_date']=> '2012-01-07 23:24:00' ['sr_id'] =>4903303 ['sr_fe_task_id'] => 220961 ['description']=> "Upload pictures of colored patch cables connected to back of router." ['due_date']=> '2012-01-07 23:31:00' I've got it to where each sr_id is listed along with all the tasks underneath of them, but can't get it to where each task has the description and due date under it: for ($i=0; $i<COUNT($tasks); $i++){ $task_list[$tasks[$i]['sr_id']]['task_id'][$tasks[$i]['sr_fe_task_id']] =$tasks[$i]['sr_fe_task_id']; foreach ($task_list[$tasks[$i]['sr_id']]['task_id'] as $v){ $task_list[$tasks[$i]['sr_id']]['task_id'][$v][$tasks[$i]['due_date']]; } }
  22. Thank you for the help thus far everyone! I have updated my code with the help of reqinix. Now I have this error: Error: Query was empty Brief - I want the user to enter their eMail into the form and submit it to signup.php; the PHP file will do the following: Generate a random User_ID that is 16 characters long. Check the database to make sure the Unque_ID does not exist. If it does exists the script will generate another random User_ID and attempt again . If it does NOT exist the PHP script will continue. Check the database to make sure the eMail does not exists. If it does exists the fuction will not create a new account and displays "eMail already exists." If it does NOT exists then the script will continue. The PHP script will add the informtion to the table named "eMail" as a new entry. Here is the updated script with requinix's help: <?php $con = mysql_connect("localhost","******","******"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("diamon79_mysql", $con); function generateRandomString($Generate_ID = 16) { return substr(str_shuffle("01234567890123456789"), 0, $Generate_ID); } $searchquery = "SELECT * FROM eMail WHERE `User_ID` = '$Generate_ID'"; $searchresult = mysql_query($searchquery) or die(mysql_error()); if (mysql_num_rows($searchresult) == 0) { $User_Id = $Generate_ID; eMailCheck(); } // no rows found else { generateRandomString(); } function eMailCheck() { $eMail = "$_POST[eMail]"; return $eMail; } $searcheMailquery = "SELECT * FROM eMail WHERE `eMail` = '$eMail'"; $searcheMailresult = mysql_query($searcheMailquery) or die(mysql_error()); if (mysql_num_rows($searcheMailresult) == 0) { PostInformation(); } // no rows found else { echo "eMail already exists"; } function PostInformation() { $sql="INSERT INTO eMail (User_D, eMail) VALUES ('$User_ID','$_POST[eMail]')"; } if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con); ?>
  23. Thank you to everyone who is taking the time to read my post and help me. Brief - I want the user to enter their eMail into the form and submit it to signup.php; the PHP file will do the following: Generate a random User_ID that is 16 characters long. Check the database to make sure the Unque_ID does not exist. If it does exists the script will generate another random User_ID and attempt again . If it does NOT exist the PHP script will continue. Check the database to make sure the eMail does not exists. If it does exists the fuction will not create a new account and displays "eMail already exists." If it does NOT exists then the script will continue. The PHP script will add the informtion to the table named "eMail" as a new entry. I keep getting this error: Parse error: syntax error, unexpected T_FUNCTION in /home/diamon79/public_html/signup.php on line 12 Line 12 is function generateRandomString($User_ID = 16) { The form to submit content: <form action="signup.php" method="post"> eMail: <input type="text" name="eMail"> <input type="submit"> </form> The PHP script the form is posted to: <?php $con = mysql_connect("localhost","*********","*******"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("diamon79_mysql", $con); $eMail == '$_POST[eMail]' function generateRandomString($User_ID = 16) { return substr(str_shuffle("0123456789"), 0, $User_ID); } $searchquery = "SELECT * FROM eMail WHERE `Column_A` = '$User_ID'"; $searchresult = mysql_query($searchquery) or die(mysql_error()); if (mysql_num_rows($searchresult) == 0) { eMailCheck(); } // no rows found else { generateRandomString($User_ID = 16); } function eMailCheck() $searcheMailquery = "SELECT * FROM eMail WHERE `Column_B` = '$eMail'"; $searcheMailresult = mysql_query($searcheMailquery) or die(mysql_error()); if (mysql_num_rows($searcheMailresult) == 0) { PostInformation(); } // no rows found else { echo "eMail already exists"; } function PostInformation() $sql="INSERT INTO eMail (User_ID, eMail) VALUES ('$User_ID','$_POST[eMail]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con); ?> I downloaded Notepad++ to be able to debug the script, but I cannot figure out how to use it properly so I am posting here. Thank you. Brett Hartel
  24. I have this code for adding info to a database from a webpage i wrote. I am getting this error Parse error: syntax error, unexpected '-', expecting ']' in /home/rottorg/public_html/insert.php on line 57 <?php ('$_POST[title]','$_POST[rank]','$_POST[position_number]','$_POST[first_name]','$_POST[middle_name]','$_POST[last_name]','$_POST[street_name]','$_POST[city]','$_POST[state]','$_POST[zip_code]','$_POST[home_phone]','$_POST[work_phone]','$_POST[cell_phone]','$_POST','$_POST[ham_radio]','$_POST[license_type]','$_POST[iCS-100]','$_POST[iCS_200]','$_POST[iCS_230]','$_POST[iCS_300]','$_POST[iCS_400]','$_POST[iCS_700]','$_POST[iCS_702]','$_POST[iCS_706]','$_POST[iCS_707]','$_POST[iCS_800]','$_POST[first_aid]','$_POST[cpr]','$_POST[cert]','$_POST[cert_int]','$_POST[special_skills]')"; ?>
  25. Hello All, I haven't been here in a while. It has been a busy semester. Haven't gotten a lot of time to practice coding in a while, but this question did cross my mind this morning for a project I am working on. Is there a way to connect to a database that is not the host. For example, say I was to create a blog with PHP and I gave that system to multiple users, but I wanted to collect all of the posts from all of the blogs in my database. So each blog has it's own database and different hosts, but I have my own that collects all of the posts and content. Any ideas?? Thanks!
×
×
  • 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.