imdead
Members-
Posts
116 -
Joined
-
Last visited
Everything posted by imdead
-
I shall show you some clients websites http://www.careervets.com/ http://tennistorrents.com/
-
If thats what you guys call making a web project here, then yes
-
Hey guys, i'm currently writing a social networking system. I've got 8+ years with PHP and MySQL, and was wondering if anybody is out there who is looking for a little project to play around with and help out together? I've got the whole core of the system down! Usersystem,Messaging System,Friends,Status'. Just wanted to see if there was anybody else out there who wanted to come and mess around coding with me, i'll be available to talk to on skype,msn or whatever and we can setup a svn system so we can collaborate easier Thanks
-
No worries everyone! i fixed it myself <?php $sql = mysql_query("SELECT * FROM statuses LEFT JOIN users ON statuses.userid = users.id"); while ($row = mysql_fetch_assoc($sql)) { $status_id = $row['id']; $status = $row['status']; $time_posted = $row['time_posted']; $userid = $row['userid']; $sql2 = mysql_query("SELECT username,avatar_url FROM users WHERE id=$userid LIMIT 1"); while ($row2=mysql_fetch_array($sql2)){ $usernamestatus = $row2['username']; $avatar_url = $row2['avatar_url']; print_r($row); print_r($row2); echo '<div id="content">'; echo "<img src='/photos/$usernamestatus/$avatar_url' height='50px' width='50px' />"; echo "<a href=\"profile.php?id=$userid\">". $usernamestatus ."</a>"; echo "<br />"; echo $status; echo " <span class=x><a href=delete_status.php?id=$status_id>x</a></span>"; echo "<br />"; echo time_ago($time_posted); echo "<br />"; echo "<br />"; echo "</div>"; } } } ?>
-
Right this is what i've got atm, <?php $sql = mysql_query("SELECT * FROM statuses LEFT JOIN users ON statuses.userid = users.id"); while ($row = mysql_fetch_assoc($sql)) { $status_id = $row['id']; $status = $row['status']; $time_posted = $row['time_posted']; $sql2 = mysql_query("SELECT username,avatar_url FROM users WHERE id=$userid LIMIT 1"); while ($row2=mysql_fetch_array($sql2)){ $usernamestatus = $row2['username']; $avatar_url = $row2['avatar_url']; print_r($row); print"<br />"; print_r($row2); echo '<div id="content">'; echo "<img src='/photos/$usernamestatus/$avatar_url' height='50px' width='50px' />"; echo "<a href=\"profile.php?id=$userid\">". $usernamestatus ."</a>"; echo "<br />"; echo $status; echo " <span class=x><a href=delete_status.php?id=$status_id>x</a></span>"; echo "<br />"; echo time_ago($time_posted); echo "<br />"; echo "<br />"; echo "</div>"; } } } ?> Array ( [id] => 1 [status] => test [userid] => 1 [time_posted] => 18:42:36 [username] => ****** [password] => ****** [email] => **** [pm_count] => 1 [avatar_url] => **** [about_me] => [interested] => Women [relationship] => In a Relationship [gender] => Male ) Array ( [0] => ****** [username] => ***** [1] => ***** [avatar_url] =>***** ) From what i can see, there is some serious bug in here. Any ideas?
-
Guys, i'm just doing this on my localhost to see if i can build anything remotely like facebook. For the fun and it's going pretty well , but yeah i know that it's all mucky and horrible. I'm not getting any errors, however it's only displaying 1status, instead of the 100's that are there. Thankyou for your help so far guys.
-
Hey guys, i'm creating a facebook clone. Almost there, got the main/basic features all done, however i've got one piece of code which is really bugging me, don't worry about it being messy and horribley coded. I will be improving and optimising it every chance i get once i've got this down. it's on the main page, i want it to display all recent status' that have been made, i can display them however i think i've bugg'd the SQL somewhere and it's driving my crazy, any help would be greatly appriciated Thanks <?php $sql = mysql_query("SELECT * FROM statuses ORDER BY id DESC"); $sql = mysql_query("SELECT * FROM statuses LEFT JOIN users ON statuses.userid = users.id"); while ($row = mysql_fetch_assoc($sql)) { $status_id = $row['id']; $status = $row['status']; $time_posted = $row['time_posted']; $sql2 = mysql_query("SELECT username,avatar_url FROM users WHERE id=$userid LIMIT 1"); while ($row2=mysql_fetch_array($sql)){ $usernamestatus = $row2['username']; $avatar_url = $row2['avatar_url']; echo '<div id="content">'; echo "<img src='/photos/$usernamestatus/$avatar_url' height='50px' width='50px' />"; echo "<a href=\"profile.php?id=$userid\">". $usernamestatus ."</a>"; echo "<br />"; echo $status; echo " <span class=x><a href=delete_status.php?id=$status_id>x</a></span>"; echo "<br />"; echo time_ago($time_posted); echo "<br />"; echo "<br />"; echo "</div>"; } } } ?>
-
Hey, could anybody tell me whats wrong with this sql? I know it's just a tiny error and i'm gunna kick myself after but i've wrote so much code today i just can't find it $result = ("UPDATE users SET 'about' = '$about', 'interested' = '$interested', 'relationship' = '$relationship', 'gender' = '$gender' WHERE username = '$user'"); Thanks in advanced
-
Hey guys, i've got a slight problem with a code i've been writing. Dont worry about the horrible mess it is atm, basically i've been trying to create a clone of the website CleverBot. This is how i believe it works 1. person asks a question. 2. Bot looks at database for the question and spits out the answer if found. 3. If the answer was not found, just respond "I don't know" or something similar. Store the question in the database. 4. Spit out one of the unanswered questions from the database. Record the answer for future person Make this basic system and add a few hundred "stock" questions and answers, a few features to increase humanishness (like store multiple possible answers for each question) and a few hard-coded answers to "stumpers" like "What time is it?" and swear words. 1. User A says "Where do you live?". 2. Cleverbot says "Huh?" 3. Cleverbot asks User B, later, "Where do you live?". 4. User B responds "I live in Devon." 5. Later, User C asks Cleverbot, "Where do you live?". 6. Cleverbot responds "I live in Devon.", echoing User B. 7. User C corrects Cleverbot with "They say I live in Devon." 8. Cleverbot stores that response in its database. 9. I could say "I live in Devon.", and Cleverbot spits out the correction. Without even knowing it's making a correction. As far as it knows it's just another question with a stored answer. and this is what i've wrote so far, <?php error_reporting(0); // Establish A Connection, And Select Database $conn = mysql_connect("******","****","********"); $db = mysql_select_db("****", $conn); if (empty($_POST['question'])) //// If the question hasn't been set yet { $question = $_POST['question'] = "<br /><font color='#0000FF'>Please ask me a question...</font>"; // set with dummy value echo $question; }else{ $question = $_POST['question']; $question = ucfirst(substr_replace($question, '?', 1000, 0)); /// Make the question have the first letter uppercased, add a question mark to the end of the sentance. $sql = mysql_query("SELECT * FROM qanda WHERE question='$question'"); if(mysql_num_rows($sql) <= 0){ //// If no reply is found, add dummy reply $answer = "I don't know."; if (!empty($answer)){ $f = mysql_query("INSERT INTO qanda (id, question) VALUES ('NULL', '$question')") or die (mysql_error()); /// $s = mysql_query("UPDATE qanda SET answer='$answer' WHERE (question='$question')") or die (mysql_error()); } } echo '<br /><font color="#800080">You:</font> '.$question; while($row = mysql_fetch_array($sql)) { $answer = $row["answer"]; $reply = $row["reply"]; } print '<br /><font color="#0000FF">iThink:</font> '.$answer; if (!empty($reply)){ print '<br /><font color="#0000FF">iThink:</font> '.$reply; } } /// if question is unkown, print 'i dont know', insert question as a reply to a question. ?> <br /> <center> <form name="question" action="index.php" method="post"> <input type="text" name="question" maxlength="2048" name="question2" size="41" title="Question" value="" /> <input type="submit" value="Question me!" /> </form> </center> Keep questions simple!<br /> Don't add a '?', it will be added automatically. I'm looking for a way to go about making the bot add a unknown question to the database, as a response to the question that was asked before, This is how the database works CREATE TABLE IF NOT EXISTS `qanda` ( `id` int(11) NOT NULL AUTO_INCREMENT, `question` longtext NOT NULL, `answer` longtext NOT NULL, `reply` mediumtext NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ; -- -- Dumping data for table `qanda` -- INSERT INTO `qanda` (`id`, `question`, `answer`, `reply`) VALUES (1, 'What is the date?', 'The date today is botdate();', ''), (2, 'What is your name?', 'My name is Bot.', 'What about your name?'), (3, 'Who created you?', 'I was created by, Kevin Cornish. On 15/08/11 at 01:20 AM.', ''), (4, 'How are you?', 'I''m very well thankyou.', 'What about yourself?'), (5, 'Hey.', 'Hello.', ''), (6, 'Hello.', 'Hi.', ''), (7, 'Good, thankyou.', 'You''re welcome.', '');
-
Yes, got it working. Thankyou so much for your help! Enjoy your smoke
-
Thankyou, i think i'm almost there , Error, Editing a Job:Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''hot_job'='no', 'nurse_vet'='Nurse' WHERE id='78' LIMIT 1' at line 1 IN UPDATE jobs SET job_title='', job_description='', job_type='Permanent', job_area='East Anglia', 'hot_job'='no', 'nurse_vet'='Nurse' WHERE id='78' LIMIT 1 Query, $query2 = "UPDATE jobs SET job_title='$job_title', job_description='$job_description', job_type='$job_type', job_area='$job_area', 'hot_job'='$hot', 'nurse_vet'='$nurse_vet' WHERE id='$editid' LIMIT 1"; $sql = mysql_query($query2) or die ('Error: '.mysql_error () . " IN $query2");
-
Thankyou for all your help so far, Editing a Job:UPDATE jobs SET job_title='', job_description='', job_type='Permanent', job_area='East Anglia', 'hot_job'='', 'nurse_vet'='Nurse' WHERE id=Add A New Job! That's what i get when echo'ing out the sql, i can't see why the hot_job enum isn't being filled in =/ <?php include'modules/sides/header.php'; ?> <table cellpadding="0" cellspacing="0" width="100%" id="mainTable"> <tr> <td class="left"> <?php include'modules/sides/left.php';?> </td> <td id="centercolumn"> <table class="cont" cellspacing="0"> <tr> <td id="centerCcolumn"> <div class="block"> <?php if(session_is_registered('username')){ if ($userlevel < 3){ ?> <div class="blockTitle">Administration - Add/Remove Jobs</div> <div class="blockContent"> <?php $action = $_GET["action"]; ////DELETE A JOB //// if ($action == "delete"){ $delid = $_GET['delid']; $query = "DELETE FROM jobs WHERE id=".$delid." LIMIT 1"; $sql = mysql_query($query); echo("Job succesfully deleted! [ <a href='add_jobs.php'>Back</a> ]"); } ////EDIT A JOB //// if ($action == "edit"){ print("<strong>Editing a Job:</strong>"); if ($_POST) { $editid = $_POST['id']; $job_title = $_POST['job_title']; $job_description = $_POST['job_description']; $job_type = $_POST['job_type']; $job_area = $_POST['job_area']; $hot = $_POST['hot']; $nurse_vet = $_POST['nurse_vet']; $query2 = "UPDATE jobs SET job_title='$job_title', job_description='$job_description', job_type='$job_type', job_area='$job_area', 'hot_job'='$hot_job', 'nurse_vet'='$nurse_vet' WHERE id=$editid"; echo $query2; //////$sql = mysql_query($query2) or die ('Error: '.mysql_error () . " IN $s"); }else { $editid = $_GET['editid']; $s = "SELECT * FROM jobs WHERE id=".$editid." LIMIT 1"; $sql = mysql_query($s) or die ('Error: '.mysql_error () . " IN $s"); while ($row = mysql_fetch_array($sql)) { $id = $row['id']; $job_title = $row['job_title']; $job_description = $row['job_description']; $job_type = $row['job_type']; $job_area = $row['job_area']; $hot = $row['hot']; $nurse_vet = $row['nurse_vet']; echo("<table class=main cellspacing=0 cellpadding=5 width=50%>"); echo("<input type='hidden' name='id' value='$id'>"); echo("<form name='add' method='post' action='?action=edit'>"); echo("<tr><td>Job Title: </td><td align='right'><input type='text' size=50 name='job_title' value='$job_title'></td></tr>"); echo("<tr><td>Job Description: </td><td align='right'><textarea size=50 name='job_description'>$job_description</textarea></td></tr>"); echo("<tr><td>Job Type: </td><td align='center'><select name='job_type'><option>Permanent</option><option>Locum or Contract</option></SELECT></td></tr>"); echo("<tr><td>Hot Job? </td><td align='center'>Yes <input type='radio' name='hot' value='Yes'> No <input type='radio' name='hot' value='no' checked></td></tr>"); echo("<tr><td>Nurse or Vet job? </td><td align='center'>Vet <input type='radio' name='nurse_vet' value='Vet'> Nurse <input type='radio' name='nurse_vet' value='Nurse' checked></td></tr>"); echo("<tr><td>Job Area: </td><td align='center'><select name='job_area'><option>East Anglia</option><option>All UK</option><option>London / South East</option><option>Midlands</option><option>North West</option><option>Northern Ireland</option><option>Scotland</option><option>South</option><option>South West</option><option>Southern Ireland</option><option>Wales</option><option>Yorkshire / North East</option></SELECT></td></tr>"); echo("<tr><td></td><td><div align='right'><input type='Submit'></div></td></tr>"); echo("</table>"); } } } ////ADD A JOB //// if ($action == "add"){ $add = $_POST['add']; $job_title = $_POST['job_title']; $job_description = $_POST['job_description']; $job_type = $_POST['job_type']; $job_area = $_POST['job_area']; $hot = $_POST['hot']; $nurse_vet = $_POST['nurse_vet']; $id = mysql_insert_id(); $query = "INSERT INTO jobs (id, job_title, job_description, job_type, job_area, hot_job, nurse_vet) VALUES ('$id', '$job_title', '$job_description', '$job_type', '$job_area', '$hot', '$nurse_vet')"; $sql = mysql_query($query) or die (mysql_error()); } print("<strong>Add A New Job!</strong>"); print("<br />"); print("<br />"); echo("<form name='add' method='post' action='?action=add'>"); echo("<input type='hidden' name='?action=add'>"); echo("<table class=main cellspacing=0 cellpadding=5 width=50%>"); echo("<tr><td>Job Title: </td><td align='right'><input type='text' size=50 name='job_title'></td></tr>"); echo("<tr><td>Job Description: </td><td align='right'><textarea size=50 name='job_description'></textarea></td></tr>"); echo("<tr><td>Job Type: </td><td align='center'><select name='job_type'><option>Permanent</option><option>Locum or Contract</option></SELECT></td></tr>"); echo("<tr><td>Hot Job? </td><td align='center'>Yes <input type='radio' name='hot' value='Yes'> No <input type='radio' name='hot' value='no' checked></td></tr>"); echo("<tr><td>Nurse or Vet job? </td><td align='center'>Vet <input type='radio' name='nurse_vet' value='Vet'> Nurse <input type='radio' name='nurse_vet' value='Nurse' checked></td></tr>"); echo("<tr><td>Job Area: </td><td align='center'><select name='job_area'><option>East Anglia</option><option>All UK</option><option>London / South East</option><option>Midlands</option><option>North West</option><option>Northern Ireland</option><option>Scotland</option><option>South</option><option>South West</option><option>Southern Ireland</option><option>Wales</option><option>Yorkshire / North East</option></SELECT></td></tr>"); echo("<tr><td></td><td><div align='right'><input type='Submit'></form></div></td></tr>"); echo("</table>"); if($success == TRUE) { print("<strong>Success!</strong>"); } echo("<br>"); echo("</form>"); print("<strong>Existing Jobs:</strong>"); print("<br />"); print("<br />"); echo("<table class=main cellspacing=0 cellpadding=5>"); echo("<td>ID:</td><td>Title:</td><td>Description:</td><td>Type:</td><td>Area:</td><td>Nurse/Vet Job:</td><td>Edit (DO NOT USE YET):</td><td>Delete:</td>"); $query = "SELECT * FROM jobs WHERE 1=1"; $sql = mysql_query($query); while ($row = mysql_fetch_array($sql)) { $id = $row['id']; $job_title = $row['job_title']; $job_description = $row['job_description']; $job_type = $row['job_type']; $job_area = $row['job_area']; $nurse_vet = $row['nurse_vet']; $position=18; $job_description2 = substr($job_description, 0, $position); echo("<tr><td><strong>$id</strong></td><td><strong>$job_title</strong></td><td><strong>$job_description2...</strong></td><td><strong>$job_type</strong></td><td><strong>$job_area</strong></td><td><strong>$nurse_vet</strong></td><td><a href='add_jobs.php?action=edit&editid=$id'>Edit</a></td><td><a href='add_jobs.php?action=delete&delid=$id'>Delete</a></td></tr>"); } ?></p></table> </div> </div> <?php }else{echo'Stop hacking';}}?> </td> </tr> </table> <td class="right"> <?php include"modules/sides/right.php"; ?> </td> </tr> </table> <?php include'modules/sides/footer.php';?>
-
Right i think im getting there, i've tidyed the code up abit for you <?php include'modules/sides/header.php'; ?> <table cellpadding="0" cellspacing="0" width="100%" id="mainTable"> <tr> <td class="left"> <?php include'modules/sides/left.php';?> </td> <td id="centercolumn"> <table class="cont" cellspacing="0"> <tr> <td id="centerCcolumn"> <div class="block"> <?php if(session_is_registered('username')){ if ($userlevel = 3){ ?> <div class="blockTitle">Administration - Add/Remove Jobs</div> <div class="blockContent"> <?php $action = $_GET["action"]; ////DELETE A JOB //// if ($action == "delete"){ $delid = $_GET['delid']; $query = "DELETE FROM jobs WHERE id=".$delid." LIMIT 1"; $sql = mysql_query($query); echo("Job succesfully deleted! [ <a href='add_jobs.php'>Back</a> ]"); } ////EDIT A JOB //// if ($action == "edit"){ print("<strong>Editing a Job:</strong>"); if ($_POST) { $editid = $_GET['editid']; $job_title = $_POST['job_title']; $job_description = $_POST['job_description']; $job_type = $_POST['job_type']; $job_area = $_POST['job_area']; $hot = $_POST['hot']; $nurse_vet = $_POST['nurse_vet']; $query2 = "UPDATE jobs SET job_title='$job_title',job_description='$job_description',job_type='$job_type',job_area='$job_area','hot_job'='$hot_job','nurse_vet'='$nurse_vet' WHERE id=$editid"; $sql = mysql_query($query2) or die ('Error: '.mysql_error () . " IN $s"); }else { $editid = $_GET['editid']; $s = "SELECT * FROM jobs WHERE id=".$editid." LIMIT 1"; $sql = mysql_query($s) or die ('Error: '.mysql_error () . " IN $s"); while ($row = mysql_fetch_array($sql)) { $id = $row['id']; $job_title = $row['job_title']; $job_description = $row['job_description']; $job_type = $row['job_type']; $job_area = $row['job_area']; $hot = $row['hot']; $nurse_vet = $row['nurse_vet']; echo("<table class=main cellspacing=0 cellpadding=5 width=50%>"); echo("<input type='hidden' name='id' value='$id'>"); echo("<form name='add' method='post' action='?action=edit'>"); echo("<tr><td>Job Title: </td><td align='right'><input type='text' size=50 name='job_title' value='$job_title'></td></tr>"); echo("<tr><td>Job Description: </td><td align='right'><textarea size=50 name='job_description'>$job_description</textarea></td></tr>"); echo("<tr><td>Job Type: </td><td align='center'><select name='job_type'><option>Permanent</option><option>Locum or Contract</option></SELECT></td></tr>"); echo("<tr><td>Hot Job? </td><td align='center'>Yes <input type='radio' name='hot' value='Yes'> No <input type='radio' name='hot' value='no' checked></td></tr>"); echo("<tr><td>Nurse or Vet job? </td><td align='center'>Vet <input type='radio' name='nurse_vet' value='Vet'> Nurse <input type='radio' name='nurse_vet' value='Nurse' checked></td></tr>"); echo("<tr><td>Job Area: </td><td align='center'><select name='job_area'><option>East Anglia</option><option>All UK</option><option>London / South East</option><option>Midlands</option><option>North West</option><option>Northern Ireland</option><option>Scotland</option><option>South</option><option>South West</option><option>Southern Ireland</option><option>Wales</option><option>Yorkshire / North East</option></SELECT></td></tr>"); echo("<tr><td></td><td><div align='right'><input type='Submit'></div></td></tr>"); echo("</table>"); } } } ////ADD A JOB //// if ($action == "add"){ $add = $_POST['add']; $job_title = $_POST['job_title']; $job_description = $_POST['job_description']; $job_type = $_POST['job_type']; $job_area = $_POST['job_area']; $hot = $_POST['hot']; $nurse_vet = $_POST['nurse_vet']; $id = mysql_insert_id(); $query = "INSERT INTO jobs (id, job_title, job_description, job_type, job_area, hot_job, nurse_vet) VALUES ('$id', '$job_title', '$job_description', '$job_type', '$job_area', '$hot', '$nurse_vet')"; $sql = mysql_query($query) or die (mysql_error()); } print("<strong>Add A New Job!</strong>"); print("<br />"); print("<br />"); echo("<form name='add' method='post' action='?action=add'>"); echo("<input type='hidden' name='?action=add'>"); echo("<table class=main cellspacing=0 cellpadding=5 width=50%>"); echo("<tr><td>Job Title: </td><td align='right'><input type='text' size=50 name='job_title'></td></tr>"); echo("<tr><td>Job Description: </td><td align='right'><textarea size=50 name='job_description'></textarea></td></tr>"); echo("<tr><td>Job Type: </td><td align='center'><select name='job_type'><option>Permanent</option><option>Locum or Contract</option></SELECT></td></tr>"); echo("<tr><td>Hot Job? </td><td align='center'>Yes <input type='radio' name='hot' value='Yes'> No <input type='radio' name='hot' value='no' checked></td></tr>"); echo("<tr><td>Nurse or Vet job? </td><td align='center'>Vet <input type='radio' name='nurse_vet' value='Vet'> Nurse <input type='radio' name='nurse_vet' value='Nurse' checked></td></tr>"); echo("<tr><td>Job Area: </td><td align='center'><select name='job_area'><option>East Anglia</option><option>All UK</option><option>London / South East</option><option>Midlands</option><option>North West</option><option>Northern Ireland</option><option>Scotland</option><option>South</option><option>South West</option><option>Southern Ireland</option><option>Wales</option><option>Yorkshire / North East</option></SELECT></td></tr>"); echo("<tr><td></td><td><div align='right'><input type='Submit'></form></div></td></tr>"); echo("</table>"); if($success == TRUE) { print("<strong>Success!</strong>"); } echo("<br>"); echo("</form>"); print("<strong>Existing Jobs:</strong>"); print("<br />"); print("<br />"); echo("<table class=main cellspacing=0 cellpadding=5>"); echo("<td>ID:</td><td>Title:</td><td>Description:</td><td>Type:</td><td>Area:</td><td>Nurse/Vet Job:</td><td>Edit (DO NOT USE YET):</td><td>Delete:</td>"); $query = "SELECT * FROM jobs WHERE 1=1"; $sql = mysql_query($query); while ($row = mysql_fetch_array($sql)) { $id = $row['id']; $job_title = $row['job_title']; $job_description = $row['job_description']; $job_type = $row['job_type']; $job_area = $row['job_area']; $nurse_vet = $row['nurse_vet']; $position=18; $job_description2 = substr($job_description, 0, $position); echo("<tr><td><strong>$id</strong></td><td><strong>$job_title</strong></td><td><strong>$job_description2...</strong></td><td><strong>$job_type</strong></td><td><strong>$job_area</strong></td><td><strong>$nurse_vet</strong></td><td><a href='add_jobs.php?action=edit&editid=$id'>Edit</a></td><td><a href='add_jobs.php?action=delete&delid=$id'>Delete</a></td></tr>"); } ?></p></table> </div> </div> <?php }else{echo'Stop hacking';}}?> </td> </tr> </table> <td class="right"> <?php include"modules/sides/right.php"; ?> </td> </tr> </table> <?php include'modules/sides/footer.php';?> Right now, it's populating the form but when i'm submitting, the error i'm now getting is Editing a Job:Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''hot_job'='','nurse_vet'='Nurse' WHERE id=' at line 1 IN
-
Right, here's what i've got now if ($action == "edit"){ print("<strong>Editing a Job:</strong>"); $editid = $_GET['editid']; $s = "SELECT * FROM jobs WHERE id=".$editid." LIMIT 1"; $sql = mysql_query($s) or die ('Error: '.mysql_error () . " IN $s"); while ($row = mysql_fetch_array($sql)) { $id = $row['id']; $job_title = $row['job_title']; $job_description = $row['job_description']; $job_type = $row['job_type']; $job_area = $row['job_area']; $query2 = "UPDATE jobs SET job_title='$job_title',job_description='$job_description',job_type='$job_type',job_area='$job_area','hot_job'='$hot_job' WHERE id=$id"; echo("<form name='add' method='post' action='?action=edit'>"); echo("<table class=main cellspacing=0 cellpadding=5 width=50%>"); echo("<input type='hidden' name='id' value='$id'>"); echo("<tr><td>Job Title: </td><td align='right'><input type='text' size=50 name='job_title' value='$job_title'></td></tr>"); echo("<tr><td>Job Description: </td><td align='right'><textarea size=50 name='job_description'>$job_description</textarea></td></tr>"); echo("<tr><td>Job Type: </td><td align='center'><select name='job_type'><option>Permanent</option><option>Locum or Contract</option></SELECT></td></tr>"); echo("<tr><td>Hot Job? </td><td align='center'>Yes <input type='radio' name='hot' value='Yes'> No <input type='radio' name='hot' value='no'></td></tr>"); echo("<tr><td>Job Area: </td><td align='center'><select name='job_area'><option>East Anglia</option><option>All UK</option><option>London / South East</option><option>Midlands</option><option>North West</option><option>Northern Ireland</option><option>Scotland</option><option>South</option><option>South West</option><option>Southern Ireland</option><option>Wales</option><option>Yorkshire / North East</option></SELECT></td></tr>"); echo("<tr><td></td><td><div align='right'><input type='Submit'></div></td></tr>"); echo("</table>"); } The when selecting a job to edit /add_jobs.php?action=edit&editid=75 it prefills all forms with the correct details, once i edit the job and press submit i'm getting Editing a Job:Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 1' at line 1 IN SELECT * FROM jobs WHERE id= LIMIT 1
-
Yeah that error was when i pressed submit, i'll add id as a hidden field now
-
When clicking edit it now spits this error Editing a Job:Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 IN SELECT * FROM jobs WHERE id=
-
Right i've fixed the echo'ing, the form's are prefilling now the code fixed was from $s = 'SELECT * FROM jobs WHERE id="$editid"'; to $s = "SELECT * FROM jobs WHERE id=".$editid." LIMIT 1"; Just got to fix the saving now
-
Nope, when i echo out each row, none of them display. i've removed the hidden field now yeah the form display's it's just all empty
-
It isn't even getting that far, the form's wont even prefill, but i cant see any errors in the mysql?
-
Hey guys, i'm making an edit feature on my website so i can delete,edit or add more jobs, so far i've made the delete and add function's work however i can't seem to get the edit to work This is the edit function if ($action == "edit"){ print("<strong>Editing a Job:</strong>"); $editid = $_GET['editid']; $s = 'SELECT * FROM jobs WHERE id="$editid"'; $sql = mysql_query($s) or die ('Error: '.mysql_error () . " IN $s"); while ($row = mysql_fetch_array($sql)) { $id = $row['id']; $job_title = $row['job_title']; $job_description = $row['job_description']; $job_type = $row['job_type']; $job_area = $row['job_area']; $query2 = "UPDATE jobs SET (job_title, job_description, job_type, job_area, hot_job) VALUES ('$job_title', '$job_description', '$job_type', '$job_area', '$hot') WHERE id=$id"; echo("<form name='add' method='post' action='?action=edit'>"); echo("<input type='hidden' name='?action=edit'>"); echo("<table class=main cellspacing=0 cellpadding=5 width=50%>"); echo("<tr><td>Job Title: </td><td align='right'><input type='text' size=50 name='job_title' value='$job_title'></td></tr>"); echo("<tr><td>Job Description: </td><td align='right'><textarea size=50 name='job_description'>$job_description</textarea></td></tr>"); echo("<tr><td>Job Type: </td><td align='center'><select name='job_type'><option>Permanent</option><option>Locum or Contract</option></SELECT></td></tr>"); echo("<tr><td>Hot Job? </td><td align='center'>Yes <input type='radio' name='hot' value='Yes'> No <input type='radio' name='hot' value='no'></td></tr>"); echo("<tr><td>Job Area: </td><td align='center'><select name='job_area'><option>East Anglia</option><option>All UK</option><option>London / South East</option><option>Midlands</option><option>North West</option><option>Northern Ireland</option><option>Scotland</option><option>South</option><option>South West</option><option>Southern Ireland</option><option>Wales</option><option>Yorkshire / North East</option></SELECT></td></tr>"); echo("<tr><td></td><td><div align='right'><input type='Submit'></div></td></tr>"); echo("</table>"); } Here is the whole code, <?php include'modules/sides/header.php'; ?> <table cellpadding="0" cellspacing="0" width="100%" id="mainTable"> <tr> <td class="left"> <?php include'modules/sides/left.php';?> </td> <td id="centercolumn"> <table class="cont" cellspacing="0"> <tr> <td id="centerCcolumn"> <div class="block"> <?php if(session_is_registered('username')){ if ($userlevel = 3){ ?> <div class="blockTitle">Administration - Add/Remove Jobs</div> <div class="blockContent"> <?php $action = $_GET["action"]; if ($action == "delete"){ $delid = $_GET['delid']; $query = "DELETE FROM jobs WHERE id=".$delid." LIMIT 1"; $sql = mysql_query($query); echo("Job succesfully deleted! [ <a href='add_jobs.php'>Back</a> ]"); } if ($action == "edit"){ print("<strong>Editing a Job:</strong>"); $editid = $_GET['editid']; $s = 'SELECT * FROM jobs WHERE id="$editid"'; $sql = mysql_query($s) or die ('Error: '.mysql_error () . " IN $s"); while ($row = mysql_fetch_array($sql)) { $id = $row['id']; $job_title = $row['job_title']; $job_description = $row['job_description']; $job_type = $row['job_type']; $job_area = $row['job_area']; $query2 = "UPDATE jobs SET (job_title, job_description, job_type, job_area, hot_job) VALUES ('$job_title', '$job_description', '$job_type', '$job_area', '$hot') WHERE id=$id"; echo("<form name='add' method='post' action='?action=edit'>"); echo("<input type='hidden' name='?action=edit'>"); echo("<table class=main cellspacing=0 cellpadding=5 width=50%>"); echo("<tr><td>Job Title: </td><td align='right'><input type='text' size=50 name='job_title' value='$job_title'></td></tr>"); echo("<tr><td>Job Description: </td><td align='right'><textarea size=50 name='job_description'>$job_description</textarea></td></tr>"); echo("<tr><td>Job Type: </td><td align='center'><select name='job_type'><option>Permanent</option><option>Locum or Contract</option></SELECT></td></tr>"); echo("<tr><td>Hot Job? </td><td align='center'>Yes <input type='radio' name='hot' value='Yes'> No <input type='radio' name='hot' value='no'></td></tr>"); echo("<tr><td>Job Area: </td><td align='center'><select name='job_area'><option>East Anglia</option><option>All UK</option><option>London / South East</option><option>Midlands</option><option>North West</option><option>Northern Ireland</option><option>Scotland</option><option>South</option><option>South West</option><option>Southern Ireland</option><option>Wales</option><option>Yorkshire / North East</option></SELECT></td></tr>"); echo("<tr><td></td><td><div align='right'><input type='Submit'></div></td></tr>"); echo("</table>"); } } if ($action == "add"){ $add = $_POST['add']; $job_title = $_POST['job_title']; $job_description = $_POST['job_description']; $job_type = $_POST['job_type']; $job_area = $_POST['job_area']; $hot = $_POST['hot']; $id = mysql_insert_id(); $query = "INSERT INTO jobs (id, job_title, job_description, job_type, job_area, hot_job) VALUES ('$id', '$job_title', '$job_description', '$job_type', '$job_area', '$hot')"; $sql = mysql_query($query) or die (mysql_error()); } print("<strong>Add A New Job!</strong>"); print("<br />"); print("<br />"); echo("<form name='add' method='post' action='?action=add'>"); echo("<input type='hidden' name='?action=add'>"); echo("<table class=main cellspacing=0 cellpadding=5 width=50%>"); echo("<tr><td>Job Title: </td><td align='right'><input type='text' size=50 name='job_title'></td></tr>"); echo("<tr><td>Job Description: </td><td align='right'><textarea size=50 name='job_description'></textarea></td></tr>"); echo("<tr><td>Job Type: </td><td align='center'><select name='job_type'><option>Permanent</option><option>Locum or Contract</option></SELECT></td></tr>"); echo("<tr><td>Hot Job? </td><td align='center'>Yes <input type='radio' name='hot' value='Yes'> No <input type='radio' name='hot' value='no' checked></td></tr>"); echo("<tr><td>Job Area: </td><td align='center'><select name='job_area'><option>East Anglia</option><option>All UK</option><option>London / South East</option><option>Midlands</option><option>North West</option><option>Northern Ireland</option><option>Scotland</option><option>South</option><option>South West</option><option>Southern Ireland</option><option>Wales</option><option>Yorkshire / North East</option></SELECT></td></tr>"); echo("<tr><td></td><td><div align='right'><input type='Submit'></div></td></tr>"); echo("</table>"); if($success == TRUE) { print("<strong>Success!</strong>"); } echo("<br>"); echo("</form>"); print("<strong>Existing Jobs:</strong>"); print("<br />"); print("<br />"); echo("<table class=main cellspacing=0 cellpadding=5>"); echo("<td>ID:</td><td>Title:</td><td>Description:</td><td>Type:</td><td>Area:</td><td>Edit (DO NOT USE YET):</td><td>Delete:</td>"); $query = "SELECT * FROM jobs WHERE 1=1"; $sql = mysql_query($query); while ($row = mysql_fetch_array($sql)) { $id = $row['id']; $job_title = $row['job_title']; $job_description = $row['job_description']; $job_type = $row['job_type']; $job_area = $row['job_area']; $position=18; $job_description2 = substr($job_description, 0, $position); echo("<tr><td><strong>$id</strong></td><td><strong>$job_title</strong></td><td><strong>$job_description2...</strong></td><td><strong>$job_type</strong></td><td><strong>$job_area</strong></td><td><a href='add_jobs.php?action=edit&editid=$id'>Edit</a></td><td><a href='add_jobs.php?action=delete&delid=$id'>Delete</a></td></tr>"); } ?></p></table> </div> </div> <?php }else{echo'Stop hacking';}}?> </td> </tr> </table> <td class="right"> <?php include"modules/sides/right.php"; ?> </td> </tr> </table> <?php include'modules/sides/footer.php';?> Any help would be great, thankyou!
-
Right, i'm now using <?php $action = $_GET["action"]; if ($action == "delete"){ $delid = $_GET['delid']; $query = "DELETE FROM jobs WHERE id=".$delid." LIMIT 1"; $sql = mysql_query($query); echo("Job succesfully deleted! [ <a href='add_jobs.php'>Back</a> ]"); } if ($action == "edit"){ print("<strong>Editing a Job:</strong>"); $editid = $_GET['editid']; $s = 'SELECT * FROM jobs WHERE id="$editid"'; $sql = mysql_query($s) or die ('Error: '.mysql_error () . " IN $s"); while ($row = mysql_fetch_array($sql)) { $id = $row['id']; $job_title = $row['job_title']; $job_description = $row['job_description']; $job_type = $row['job_type']; $job_area = $row['job_area']; $query2 = "UPDATE jobs SET (job_title, job_description, job_type, job_area, hot_job) VALUES ('$job_title', '$job_description', '$job_type', '$job_area', '$hot') WHERE id=$id"; echo("<form name='add' method='post' action='?action=edit'>"); echo("<input type='hidden' name='?action=edit'>"); echo("<table class=main cellspacing=0 cellpadding=5 width=50%>"); echo("<tr><td>Job Title: </td><td align='right'><input type='text' size=50 name='job_title' value='$job_title'></td></tr>"); echo("<tr><td>Job Description: </td><td align='right'><textarea size=50 name='job_description'>$job_description</textarea></td></tr>"); echo("<tr><td>Job Type: </td><td align='center'><select name='job_type'><option>Permanent</option><option>Locum or Contract</option></SELECT></td></tr>"); echo("<tr><td>Hot Job? </td><td align='center'>Yes <input type='radio' name='hot' value='Yes'> No <input type='radio' name='hot' value='no'></td></tr>"); echo("<tr><td>Job Area: </td><td align='center'><select name='job_area'><option>East Anglia</option><option>London / South East</option><option>Midlands</option><option>North West</option><option>Northern Ireland</option><option>Scotland</option><option>South</option><option>South West</option><option>Southern Ireland</option><option>Wales</option><option>Yorkshire / North East</option></SELECT></td></tr>"); echo("<tr><td></td><td><div align='right'><input type='Submit'></div></td></tr>"); echo("</table>"); } } if ($action == "add"){ $add = $_POST['add']; $job_title = $_POST['job_title']; $job_description = $_POST['job_description']; $job_type = $_POST['job_type']; $job_area = $_POST['job_area']; $hot = $_POST['hot']; $id = mysql_insert_id(); $query = "INSERT INTO jobs (id, job_title, job_description, job_type, job_area, hot_job) VALUES ('$id', '$job_title', '$job_description', '$job_type', '$job_area', '$hot')"; $sql = mysql_query($query) or die (mysql_error()); } print("<strong>Add A New Job!</strong>"); print("<br />"); print("<br />"); echo("<form name='add' method='post' action='?action=add'>"); echo("<input type='hidden' name='?action=add'>"); echo("<table class=main cellspacing=0 cellpadding=5 width=50%>"); echo("<tr><td>Job Title: </td><td align='right'><input type='text' size=50 name='job_title'></td></tr>"); echo("<tr><td>Job Description: </td><td align='right'><textarea size=50 name='job_description'></textarea></td></tr>"); echo("<tr><td>Job Type: </td><td align='center'><select name='job_type'><option>Permanent</option><option>Locum or Contract</option></SELECT></td></tr>"); echo("<tr><td>Hot Job? </td><td align='center'>Yes <input type='radio' name='hot' value='Yes'> No <input type='radio' name='hot' value='no' checked></td></tr>"); echo("<tr><td>Job Area: </td><td align='center'><select name='job_area'><option>East Anglia</option><option>London / South East</option><option>Midlands</option><option>North West</option><option>Northern Ireland</option><option>Scotland</option><option>South</option><option>South West</option><option>Southern Ireland</option><option>Wales</option><option>Yorkshire / North East</option></SELECT></td></tr>"); echo("<tr><td></td><td><div align='right'><input type='Submit'></div></td></tr>"); echo("</table>"); if($success == TRUE) { print("<strong>Success!</strong>"); } echo("<br>"); echo("</form>"); print("<strong>Existing Jobs:</strong>"); print("<br />"); print("<br />"); echo("<table class=main cellspacing=0 cellpadding=5>"); echo("<td>ID:</td><td>Title:</td><td>Description:</td><td>Type:</td><td>Area:</td><td>Edit (DO NOT USE YET):</td><td>Delete:</td>"); $query = "SELECT * FROM jobs WHERE 1=1"; $sql = mysql_query($query); while ($row = mysql_fetch_array($sql)) { $id = $row['id']; $job_title = $row['job_title']; $job_description = $row['job_description']; $job_type = $row['job_type']; $job_area = $row['job_area']; $position=18; $job_description2 = substr($job_description, 0, $position); echo("<tr><td><strong>$id</strong></td><td><strong>$job_title</strong></td><td><strong>$job_description2...</strong></td><td><strong>$job_type</strong></td><td><strong>$job_area</strong></td><td><a href='add_jobs.php?action=edit&editid=$id'>Edit</a></td><td><a href='add_jobs.php?action=delete&delid=$id'>Delete</a></td></tr>"); } ?> The error has now gone, however it wont display any of the data from the query. Any help would be greatly thanked
-
Nope, still only working on firefox and ie =/
-
With that, the error is. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 IN SELECT * FROM jobs WHERE id =
-
Hey guys, i've made a script to display a random image. Works perfect on firefox, ie but not chrome =/. Rotate.php <?php // rotate images randomly but w/o dups on same page - format: // <img src='rotate.php?i=0'> - rotate image #0 - use 'i=1' // for second, etc // (c) 2004 David Pankhurst - use freely, but please leave in my credit $images=array( // list of files to rotate - add as needed "images/1.jpg", "images/2.jpg", "images/3.jpg", "images/4.jpg", "images/5.jpg", "images/6.jpg", "images/7.jpg", "images/8.jpg", "images/9.jpg" ); $total=count($images); $secondsFixed=2; // seconds to keep list the same $seedValue=(int)(time()/$secondsFixed); srand($seedValue); for ($i=0;$i<$total;++$i) // shuffle list 'randomly' { $r=rand(0,$total-1); $temp =$images[$i]; $images[$i]=$images[$r]; $images[$r]=$temp; } $index=(int)($_GET['i']); // image index passed in $i=$index%$total; // make sure index always in bounds $file=$images[$i]; header ("Location: $file"); header ("Content-Length: 0"); exit; ?> and then to call it, script.php <img src='rotate.php?i=0' width="90%" height="90%" alt="" />
-
I'm pretty sure it was this line, $sql = mysql_query("SELECT * FROM jobs WHERE id = ".$editid." ") or die ('Error: '.mysql_error ()); Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1